babylon.d.txt 2.8 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928
  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 the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Color3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1821. /**
  1822. * Unproject from screen space to object space
  1823. * @param source defines the screen space Vector3 to use
  1824. * @param viewportWidth defines the current width of the viewport
  1825. * @param viewportHeight defines the current height of the viewport
  1826. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1827. * @param transform defines the transform (view x projection) matrix to use
  1828. * @returns the new Vector3
  1829. */
  1830. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1831. /**
  1832. * Unproject from screen space to object space
  1833. * @param source defines the screen space Vector3 to use
  1834. * @param viewportWidth defines the current width of the viewport
  1835. * @param viewportHeight defines the current height of the viewport
  1836. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1837. * @param view defines the view matrix to use
  1838. * @param projection defines the projection matrix to use
  1839. * @returns the new Vector3
  1840. */
  1841. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1842. /**
  1843. * Unproject from screen space to object space
  1844. * @param source defines the screen space Vector3 to use
  1845. * @param viewportWidth defines the current width of the viewport
  1846. * @param viewportHeight defines the current height of the viewport
  1847. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1848. * @param view defines the view matrix to use
  1849. * @param projection defines the projection matrix to use
  1850. * @param result defines the Vector3 where to store the result
  1851. */
  1852. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1853. /**
  1854. * Unproject from screen space to object space
  1855. * @param sourceX defines the screen space x coordinate to use
  1856. * @param sourceY defines the screen space y coordinate to use
  1857. * @param sourceZ defines the screen space z coordinate to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @param result defines the Vector3 where to store the result
  1864. */
  1865. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1866. /**
  1867. * Gets the minimal coordinate values between two Vector3
  1868. * @param left defines the first operand
  1869. * @param right defines the second operand
  1870. * @returns the new Vector3
  1871. */
  1872. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1873. /**
  1874. * Gets the maximal coordinate values between two Vector3
  1875. * @param left defines the first operand
  1876. * @param right defines the second operand
  1877. * @returns the new Vector3
  1878. */
  1879. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1880. /**
  1881. * Returns the distance between the vectors "value1" and "value2"
  1882. * @param value1 defines the first operand
  1883. * @param value2 defines the second operand
  1884. * @returns the distance
  1885. */
  1886. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1887. /**
  1888. * Returns the squared distance between the vectors "value1" and "value2"
  1889. * @param value1 defines the first operand
  1890. * @param value2 defines the second operand
  1891. * @returns the squared distance
  1892. */
  1893. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1894. /**
  1895. * Returns a new Vector3 located at the center between "value1" and "value2"
  1896. * @param value1 defines the first operand
  1897. * @param value2 defines the second operand
  1898. * @returns the new Vector3
  1899. */
  1900. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1901. /**
  1902. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1903. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1904. * to something in order to rotate it from its local system to the given target system
  1905. * Note: axis1, axis2 and axis3 are normalized during this operation
  1906. * @param axis1 defines the first axis
  1907. * @param axis2 defines the second axis
  1908. * @param axis3 defines the third axis
  1909. * @returns a new Vector3
  1910. */
  1911. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1912. /**
  1913. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1914. * @param axis1 defines the first axis
  1915. * @param axis2 defines the second axis
  1916. * @param axis3 defines the third axis
  1917. * @param ref defines the Vector3 where to store the result
  1918. */
  1919. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1920. }
  1921. /**
  1922. * Vector4 class created for EulerAngle class conversion to Quaternion
  1923. */
  1924. export class Vector4 {
  1925. /** x value of the vector */
  1926. x: number;
  1927. /** y value of the vector */
  1928. y: number;
  1929. /** z value of the vector */
  1930. z: number;
  1931. /** w value of the vector */
  1932. w: number;
  1933. /**
  1934. * Creates a Vector4 object from the given floats.
  1935. * @param x x value of the vector
  1936. * @param y y value of the vector
  1937. * @param z z value of the vector
  1938. * @param w w value of the vector
  1939. */
  1940. constructor(
  1941. /** x value of the vector */
  1942. x: number,
  1943. /** y value of the vector */
  1944. y: number,
  1945. /** z value of the vector */
  1946. z: number,
  1947. /** w value of the vector */
  1948. w: number);
  1949. /**
  1950. * Returns the string with the Vector4 coordinates.
  1951. * @returns a string containing all the vector values
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Returns the string "Vector4".
  1956. * @returns "Vector4"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Returns the Vector4 hash code.
  1961. * @returns a unique hash code
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1966. * @returns the resulting array
  1967. */
  1968. asArray(): number[];
  1969. /**
  1970. * Populates the given array from the given index with the Vector4 coordinates.
  1971. * @param array array to populate
  1972. * @param index index of the array to start at (default: 0)
  1973. * @returns the Vector4.
  1974. */
  1975. toArray(array: FloatArray, index?: number): Vector4;
  1976. /**
  1977. * Adds the given vector to the current Vector4.
  1978. * @param otherVector the vector to add
  1979. * @returns the updated Vector4.
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1982. /**
  1983. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1984. * @param otherVector the vector to add
  1985. * @returns the resulting vector
  1986. */
  1987. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1988. /**
  1989. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1990. * @param otherVector the vector to add
  1991. * @param result the vector to store the result
  1992. * @returns the current Vector4.
  1993. */
  1994. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1995. /**
  1996. * Subtract in place the given vector from the current Vector4.
  1997. * @param otherVector the vector to subtract
  1998. * @returns the updated Vector4.
  1999. */
  2000. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2001. /**
  2002. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2003. * @param otherVector the vector to add
  2004. * @returns the new vector with the result
  2005. */
  2006. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2007. /**
  2008. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2009. * @param otherVector the vector to subtract
  2010. * @param result the vector to store the result
  2011. * @returns the current Vector4.
  2012. */
  2013. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2014. /**
  2015. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2016. */
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. * @param x value to subtract
  2020. * @param y value to subtract
  2021. * @param z value to subtract
  2022. * @param w value to subtract
  2023. * @returns new vector containing the result
  2024. */
  2025. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2026. /**
  2027. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2028. * @param x value to subtract
  2029. * @param y value to subtract
  2030. * @param z value to subtract
  2031. * @param w value to subtract
  2032. * @param result the vector to store the result in
  2033. * @returns the current Vector4.
  2034. */
  2035. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2036. /**
  2037. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2038. * @returns a new vector with the negated values
  2039. */
  2040. negate(): Vector4;
  2041. /**
  2042. * Multiplies the current Vector4 coordinates by scale (float).
  2043. * @param scale the number to scale with
  2044. * @returns the updated Vector4.
  2045. */
  2046. scaleInPlace(scale: number): Vector4;
  2047. /**
  2048. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2049. * @param scale the number to scale with
  2050. * @returns a new vector with the result
  2051. */
  2052. scale(scale: number): Vector4;
  2053. /**
  2054. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2055. * @param scale the number to scale with
  2056. * @param result a vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. scaleToRef(scale: number, result: Vector4): Vector4;
  2060. /**
  2061. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2062. * @param scale defines the scale factor
  2063. * @param result defines the Vector4 object where to store the result
  2064. * @returns the unmodified current Vector4
  2065. */
  2066. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2067. /**
  2068. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2069. * @param otherVector the vector to compare against
  2070. * @returns true if they are equal
  2071. */
  2072. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2073. /**
  2074. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2075. * @param otherVector vector to compare against
  2076. * @param epsilon (Default: very small number)
  2077. * @returns true if they are equal
  2078. */
  2079. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2080. /**
  2081. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2082. * @param x x value to compare against
  2083. * @param y y value to compare against
  2084. * @param z z value to compare against
  2085. * @param w w value to compare against
  2086. * @returns true if equal
  2087. */
  2088. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2089. /**
  2090. * Multiplies in place the current Vector4 by the given one.
  2091. * @param otherVector vector to multiple with
  2092. * @returns the updated Vector4.
  2093. */
  2094. multiplyInPlace(otherVector: Vector4): Vector4;
  2095. /**
  2096. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2097. * @param otherVector vector to multiple with
  2098. * @returns resulting new vector
  2099. */
  2100. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2101. /**
  2102. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2103. * @param otherVector vector to multiple with
  2104. * @param result vector to store the result
  2105. * @returns the current Vector4.
  2106. */
  2107. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2108. /**
  2109. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2110. * @param x x value multiply with
  2111. * @param y y value multiply with
  2112. * @param z z value multiply with
  2113. * @param w w value multiply with
  2114. * @returns resulting new vector
  2115. */
  2116. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2117. /**
  2118. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2119. * @param otherVector vector to devide with
  2120. * @returns resulting new vector
  2121. */
  2122. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2123. /**
  2124. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2125. * @param otherVector vector to devide with
  2126. * @param result vector to store the result
  2127. * @returns the current Vector4.
  2128. */
  2129. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2130. /**
  2131. * Divides the current Vector3 coordinates by the given ones.
  2132. * @param otherVector vector to devide with
  2133. * @returns the updated Vector3.
  2134. */
  2135. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2136. /**
  2137. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2138. * @param other defines the second operand
  2139. * @returns the current updated Vector4
  2140. */
  2141. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2142. /**
  2143. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2144. * @param other defines the second operand
  2145. * @returns the current updated Vector4
  2146. */
  2147. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2148. /**
  2149. * Gets a new Vector4 from current Vector4 floored values
  2150. * @returns a new Vector4
  2151. */
  2152. floor(): Vector4;
  2153. /**
  2154. * Gets a new Vector4 from current Vector3 floored values
  2155. * @returns a new Vector4
  2156. */
  2157. fract(): Vector4;
  2158. /**
  2159. * Returns the Vector4 length (float).
  2160. * @returns the length
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Returns the Vector4 squared length (float).
  2165. * @returns the length squared
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalizes in place the Vector4.
  2170. * @returns the updated Vector4.
  2171. */
  2172. normalize(): Vector4;
  2173. /**
  2174. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2175. * @returns this converted to a new vector3
  2176. */
  2177. toVector3(): Vector3;
  2178. /**
  2179. * Returns a new Vector4 copied from the current one.
  2180. * @returns the new cloned vector
  2181. */
  2182. clone(): Vector4;
  2183. /**
  2184. * Updates the current Vector4 with the given one coordinates.
  2185. * @param source the source vector to copy from
  2186. * @returns the updated Vector4.
  2187. */
  2188. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2189. /**
  2190. * Updates the current Vector4 coordinates with the given floats.
  2191. * @param x float to copy from
  2192. * @param y float to copy from
  2193. * @param z float to copy from
  2194. * @param w float to copy from
  2195. * @returns the updated Vector4.
  2196. */
  2197. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2198. /**
  2199. * Updates the current Vector4 coordinates with the given floats.
  2200. * @param x float to set from
  2201. * @param y float to set from
  2202. * @param z float to set from
  2203. * @param w float to set from
  2204. * @returns the updated Vector4.
  2205. */
  2206. set(x: number, y: number, z: number, w: number): Vector4;
  2207. /**
  2208. * Copies the given float to the current Vector3 coordinates
  2209. * @param v defines the x, y, z and w coordinates of the operand
  2210. * @returns the current updated Vector3
  2211. */
  2212. setAll(v: number): Vector4;
  2213. /**
  2214. * Returns a new Vector4 set from the starting index of the given array.
  2215. * @param array the array to pull values from
  2216. * @param offset the offset into the array to start at
  2217. * @returns the new vector
  2218. */
  2219. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2220. /**
  2221. * Updates the given vector "result" from the starting index of the given array.
  2222. * @param array the array to pull values from
  2223. * @param offset the offset into the array to start at
  2224. * @param result the vector to store the result in
  2225. */
  2226. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2227. /**
  2228. * Updates the given vector "result" from the starting index of the given Float32Array.
  2229. * @param array the array to pull values from
  2230. * @param offset the offset into the array to start at
  2231. * @param result the vector to store the result in
  2232. */
  2233. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2234. /**
  2235. * Updates the given vector "result" coordinates from the given floats.
  2236. * @param x float to set from
  2237. * @param y float to set from
  2238. * @param z float to set from
  2239. * @param w float to set from
  2240. * @param result the vector to the floats in
  2241. */
  2242. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2243. /**
  2244. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2245. * @returns the new vector
  2246. */
  2247. static Zero(): Vector4;
  2248. /**
  2249. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2250. * @returns the new vector
  2251. */
  2252. static One(): Vector4;
  2253. /**
  2254. * Returns a new normalized Vector4 from the given one.
  2255. * @param vector the vector to normalize
  2256. * @returns the vector
  2257. */
  2258. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2259. /**
  2260. * Updates the given vector "result" from the normalization of the given one.
  2261. * @param vector the vector to normalize
  2262. * @param result the vector to store the result in
  2263. */
  2264. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2265. /**
  2266. * Returns a vector with the minimum values from the left and right vectors
  2267. * @param left left vector to minimize
  2268. * @param right right vector to minimize
  2269. * @returns a new vector with the minimum of the left and right vector values
  2270. */
  2271. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2272. /**
  2273. * Returns a vector with the maximum values from the left and right vectors
  2274. * @param left left vector to maximize
  2275. * @param right right vector to maximize
  2276. * @returns a new vector with the maximum of the left and right vector values
  2277. */
  2278. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2279. /**
  2280. * Returns the distance (float) between the vectors "value1" and "value2".
  2281. * @param value1 value to calulate the distance between
  2282. * @param value2 value to calulate the distance between
  2283. * @return the distance between the two vectors
  2284. */
  2285. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2286. /**
  2287. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2288. * @param value1 value to calulate the distance between
  2289. * @param value2 value to calulate the distance between
  2290. * @return the distance between the two vectors squared
  2291. */
  2292. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2293. /**
  2294. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2295. * @param value1 value to calulate the center between
  2296. * @param value2 value to calulate the center between
  2297. * @return the center between the two vectors
  2298. */
  2299. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2300. /**
  2301. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2302. * This methods computes transformed normalized direction vectors only.
  2303. * @param vector the vector to transform
  2304. * @param transformation the transformation matrix to apply
  2305. * @returns the new vector
  2306. */
  2307. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2308. /**
  2309. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2310. * This methods computes transformed normalized direction vectors only.
  2311. * @param vector the vector to transform
  2312. * @param transformation the transformation matrix to apply
  2313. * @param result the vector to store the result in
  2314. */
  2315. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2316. /**
  2317. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2318. * This methods computes transformed normalized direction vectors only.
  2319. * @param x value to transform
  2320. * @param y value to transform
  2321. * @param z value to transform
  2322. * @param w value to transform
  2323. * @param transformation the transformation matrix to apply
  2324. * @param result the vector to store the results in
  2325. */
  2326. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2327. /**
  2328. * Creates a new Vector4 from a Vector3
  2329. * @param source defines the source data
  2330. * @param w defines the 4th component (default is 0)
  2331. * @returns a new Vector4
  2332. */
  2333. static FromVector3(source: Vector3, w?: number): Vector4;
  2334. }
  2335. /**
  2336. * Interface for the size containing width and height
  2337. */
  2338. export interface ISize {
  2339. /**
  2340. * Width
  2341. */
  2342. width: number;
  2343. /**
  2344. * Heighht
  2345. */
  2346. height: number;
  2347. }
  2348. /**
  2349. * Size containing widht and height
  2350. */
  2351. export class Size implements ISize {
  2352. /**
  2353. * Width
  2354. */
  2355. width: number;
  2356. /**
  2357. * Height
  2358. */
  2359. height: number;
  2360. /**
  2361. * Creates a Size object from the given width and height (floats).
  2362. * @param width width of the new size
  2363. * @param height height of the new size
  2364. */
  2365. constructor(width: number, height: number);
  2366. /**
  2367. * Returns a string with the Size width and height
  2368. * @returns a string with the Size width and height
  2369. */
  2370. toString(): string;
  2371. /**
  2372. * "Size"
  2373. * @returns the string "Size"
  2374. */
  2375. getClassName(): string;
  2376. /**
  2377. * Returns the Size hash code.
  2378. * @returns a hash code for a unique width and height
  2379. */
  2380. getHashCode(): number;
  2381. /**
  2382. * Updates the current size from the given one.
  2383. * @param src the given size
  2384. */
  2385. copyFrom(src: Size): void;
  2386. /**
  2387. * Updates in place the current Size from the given floats.
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. * @returns the updated Size.
  2391. */
  2392. copyFromFloats(width: number, height: number): Size;
  2393. /**
  2394. * Updates in place the current Size from the given floats.
  2395. * @param width width to set
  2396. * @param height height to set
  2397. * @returns the updated Size.
  2398. */
  2399. set(width: number, height: number): Size;
  2400. /**
  2401. * Multiplies the width and height by numbers
  2402. * @param w factor to multiple the width by
  2403. * @param h factor to multiple the height by
  2404. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2405. */
  2406. multiplyByFloats(w: number, h: number): Size;
  2407. /**
  2408. * Clones the size
  2409. * @returns a new Size copied from the given one.
  2410. */
  2411. clone(): Size;
  2412. /**
  2413. * True if the current Size and the given one width and height are strictly equal.
  2414. * @param other the other size to compare against
  2415. * @returns True if the current Size and the given one width and height are strictly equal.
  2416. */
  2417. equals(other: Size): boolean;
  2418. /**
  2419. * The surface of the Size : width * height (float).
  2420. */
  2421. readonly surface: number;
  2422. /**
  2423. * Create a new size of zero
  2424. * @returns a new Size set to (0.0, 0.0)
  2425. */
  2426. static Zero(): Size;
  2427. /**
  2428. * Sums the width and height of two sizes
  2429. * @param otherSize size to add to this size
  2430. * @returns a new Size set as the addition result of the current Size and the given one.
  2431. */
  2432. add(otherSize: Size): Size;
  2433. /**
  2434. * Subtracts the width and height of two
  2435. * @param otherSize size to subtract to this size
  2436. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2437. */
  2438. subtract(otherSize: Size): Size;
  2439. /**
  2440. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2441. * @param start starting size to lerp between
  2442. * @param end end size to lerp between
  2443. * @param amount amount to lerp between the start and end values
  2444. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2445. */
  2446. static Lerp(start: Size, end: Size, amount: number): Size;
  2447. }
  2448. /**
  2449. * Class used to store quaternion data
  2450. * @see https://en.wikipedia.org/wiki/Quaternion
  2451. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2452. */
  2453. export class Quaternion {
  2454. /** defines the first component (0 by default) */
  2455. x: number;
  2456. /** defines the second component (0 by default) */
  2457. y: number;
  2458. /** defines the third component (0 by default) */
  2459. z: number;
  2460. /** defines the fourth component (1.0 by default) */
  2461. w: number;
  2462. /**
  2463. * Creates a new Quaternion from the given floats
  2464. * @param x defines the first component (0 by default)
  2465. * @param y defines the second component (0 by default)
  2466. * @param z defines the third component (0 by default)
  2467. * @param w defines the fourth component (1.0 by default)
  2468. */
  2469. constructor(
  2470. /** defines the first component (0 by default) */
  2471. x?: number,
  2472. /** defines the second component (0 by default) */
  2473. y?: number,
  2474. /** defines the third component (0 by default) */
  2475. z?: number,
  2476. /** defines the fourth component (1.0 by default) */
  2477. w?: number);
  2478. /**
  2479. * Gets a string representation for the current quaternion
  2480. * @returns a string with the Quaternion coordinates
  2481. */
  2482. toString(): string;
  2483. /**
  2484. * Gets the class name of the quaternion
  2485. * @returns the string "Quaternion"
  2486. */
  2487. getClassName(): string;
  2488. /**
  2489. * Gets a hash code for this quaternion
  2490. * @returns the quaternion hash code
  2491. */
  2492. getHashCode(): number;
  2493. /**
  2494. * Copy the quaternion to an array
  2495. * @returns a new array populated with 4 elements from the quaternion coordinates
  2496. */
  2497. asArray(): number[];
  2498. /**
  2499. * Check if two quaternions are equals
  2500. * @param otherQuaternion defines the second operand
  2501. * @return true if the current quaternion and the given one coordinates are strictly equals
  2502. */
  2503. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2504. /**
  2505. * Clone the current quaternion
  2506. * @returns a new quaternion copied from the current one
  2507. */
  2508. clone(): Quaternion;
  2509. /**
  2510. * Copy a quaternion to the current one
  2511. * @param other defines the other quaternion
  2512. * @returns the updated current quaternion
  2513. */
  2514. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2515. /**
  2516. * Updates the current quaternion with the given float coordinates
  2517. * @param x defines the x coordinate
  2518. * @param y defines the y coordinate
  2519. * @param z defines the z coordinate
  2520. * @param w defines the w coordinate
  2521. * @returns the updated current quaternion
  2522. */
  2523. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2524. /**
  2525. * Updates the current quaternion from the given float coordinates
  2526. * @param x defines the x coordinate
  2527. * @param y defines the y coordinate
  2528. * @param z defines the z coordinate
  2529. * @param w defines the w coordinate
  2530. * @returns the updated current quaternion
  2531. */
  2532. set(x: number, y: number, z: number, w: number): Quaternion;
  2533. /**
  2534. * Adds two quaternions
  2535. * @param other defines the second operand
  2536. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2537. */
  2538. add(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Add a quaternion to the current one
  2541. * @param other defines the quaternion to add
  2542. * @returns the current quaternion
  2543. */
  2544. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2545. /**
  2546. * Subtract two quaternions
  2547. * @param other defines the second operand
  2548. * @returns a new quaternion as the subtraction result of the given one from the current one
  2549. */
  2550. subtract(other: Quaternion): Quaternion;
  2551. /**
  2552. * Multiplies the current quaternion by a scale factor
  2553. * @param value defines the scale factor
  2554. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2555. */
  2556. scale(value: number): Quaternion;
  2557. /**
  2558. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2559. * @param scale defines the scale factor
  2560. * @param result defines the Quaternion object where to store the result
  2561. * @returns the unmodified current quaternion
  2562. */
  2563. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2564. /**
  2565. * Multiplies in place the current quaternion by a scale factor
  2566. * @param value defines the scale factor
  2567. * @returns the current modified quaternion
  2568. */
  2569. scaleInPlace(value: number): Quaternion;
  2570. /**
  2571. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2572. * @param scale defines the scale factor
  2573. * @param result defines the Quaternion object where to store the result
  2574. * @returns the unmodified current quaternion
  2575. */
  2576. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies two quaternions
  2579. * @param q1 defines the second operand
  2580. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2581. */
  2582. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2583. /**
  2584. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2585. * @param q1 defines the second operand
  2586. * @param result defines the target quaternion
  2587. * @returns the current quaternion
  2588. */
  2589. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2590. /**
  2591. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2592. * @param q1 defines the second operand
  2593. * @returns the currentupdated quaternion
  2594. */
  2595. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2596. /**
  2597. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2598. * @param ref defines the target quaternion
  2599. * @returns the current quaternion
  2600. */
  2601. conjugateToRef(ref: Quaternion): Quaternion;
  2602. /**
  2603. * Conjugates in place (1-q) the current quaternion
  2604. * @returns the current updated quaternion
  2605. */
  2606. conjugateInPlace(): Quaternion;
  2607. /**
  2608. * Conjugates in place (1-q) the current quaternion
  2609. * @returns a new quaternion
  2610. */
  2611. conjugate(): Quaternion;
  2612. /**
  2613. * Gets length of current quaternion
  2614. * @returns the quaternion length (float)
  2615. */
  2616. length(): number;
  2617. /**
  2618. * Normalize in place the current quaternion
  2619. * @returns the current updated quaternion
  2620. */
  2621. normalize(): Quaternion;
  2622. /**
  2623. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2624. * @param order is a reserved parameter and is ignore for now
  2625. * @returns a new Vector3 containing the Euler angles
  2626. */
  2627. toEulerAngles(order?: string): Vector3;
  2628. /**
  2629. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2630. * @param result defines the vector which will be filled with the Euler angles
  2631. * @param order is a reserved parameter and is ignore for now
  2632. * @returns the current unchanged quaternion
  2633. */
  2634. toEulerAnglesToRef(result: Vector3): Quaternion;
  2635. /**
  2636. * Updates the given rotation matrix with the current quaternion values
  2637. * @param result defines the target matrix
  2638. * @returns the current unchanged quaternion
  2639. */
  2640. toRotationMatrix(result: Matrix): Quaternion;
  2641. /**
  2642. * Updates the current quaternion from the given rotation matrix values
  2643. * @param matrix defines the source matrix
  2644. * @returns the current updated quaternion
  2645. */
  2646. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2647. /**
  2648. * Creates a new quaternion from a rotation matrix
  2649. * @param matrix defines the source matrix
  2650. * @returns a new quaternion created from the given rotation matrix values
  2651. */
  2652. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2653. /**
  2654. * Updates the given quaternion with the given rotation matrix values
  2655. * @param matrix defines the source matrix
  2656. * @param result defines the target quaternion
  2657. */
  2658. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2659. /**
  2660. * Returns the dot product (float) between the quaternions "left" and "right"
  2661. * @param left defines the left operand
  2662. * @param right defines the right operand
  2663. * @returns the dot product
  2664. */
  2665. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2666. /**
  2667. * Checks if the two quaternions are close to each other
  2668. * @param quat0 defines the first quaternion to check
  2669. * @param quat1 defines the second quaternion to check
  2670. * @returns true if the two quaternions are close to each other
  2671. */
  2672. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2673. /**
  2674. * Creates an empty quaternion
  2675. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2676. */
  2677. static Zero(): Quaternion;
  2678. /**
  2679. * Inverse a given quaternion
  2680. * @param q defines the source quaternion
  2681. * @returns a new quaternion as the inverted current quaternion
  2682. */
  2683. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2684. /**
  2685. * Inverse a given quaternion
  2686. * @param q defines the source quaternion
  2687. * @param result the quaternion the result will be stored in
  2688. * @returns the result quaternion
  2689. */
  2690. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2691. /**
  2692. * Creates an identity quaternion
  2693. * @returns the identity quaternion
  2694. */
  2695. static Identity(): Quaternion;
  2696. /**
  2697. * Gets a boolean indicating if the given quaternion is identity
  2698. * @param quaternion defines the quaternion to check
  2699. * @returns true if the quaternion is identity
  2700. */
  2701. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2702. /**
  2703. * Creates a quaternion from a rotation around an axis
  2704. * @param axis defines the axis to use
  2705. * @param angle defines the angle to use
  2706. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2707. */
  2708. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2709. /**
  2710. * Creates a rotation around an axis and stores it into the given quaternion
  2711. * @param axis defines the axis to use
  2712. * @param angle defines the angle to use
  2713. * @param result defines the target quaternion
  2714. * @returns the target quaternion
  2715. */
  2716. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates a new quaternion from data stored into an array
  2719. * @param array defines the data source
  2720. * @param offset defines the offset in the source array where the data starts
  2721. * @returns a new quaternion
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2724. /**
  2725. * Create a quaternion from Euler rotation angles
  2726. * @param x Pitch
  2727. * @param y Yaw
  2728. * @param z Roll
  2729. * @returns the new Quaternion
  2730. */
  2731. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2732. /**
  2733. * Updates a quaternion from Euler rotation angles
  2734. * @param x Pitch
  2735. * @param y Yaw
  2736. * @param z Roll
  2737. * @param result the quaternion to store the result
  2738. * @returns the updated quaternion
  2739. */
  2740. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Create a quaternion from Euler rotation vector
  2743. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2744. * @returns the new Quaternion
  2745. */
  2746. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2747. /**
  2748. * Updates a quaternion from Euler rotation vector
  2749. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2750. * @param result the quaternion to store the result
  2751. * @returns the updated quaternion
  2752. */
  2753. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2754. /**
  2755. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2756. * @param yaw defines the rotation around Y axis
  2757. * @param pitch defines the rotation around X axis
  2758. * @param roll defines the rotation around Z axis
  2759. * @returns the new quaternion
  2760. */
  2761. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2762. /**
  2763. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2764. * @param yaw defines the rotation around Y axis
  2765. * @param pitch defines the rotation around X axis
  2766. * @param roll defines the rotation around Z axis
  2767. * @param result defines the target quaternion
  2768. */
  2769. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2770. /**
  2771. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2772. * @param alpha defines the rotation around first axis
  2773. * @param beta defines the rotation around second axis
  2774. * @param gamma defines the rotation around third axis
  2775. * @returns the new quaternion
  2776. */
  2777. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2780. * @param alpha defines the rotation around first axis
  2781. * @param beta defines the rotation around second axis
  2782. * @param gamma defines the rotation around third axis
  2783. * @param result defines the target quaternion
  2784. */
  2785. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2786. /**
  2787. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2788. * @param axis1 defines the first axis
  2789. * @param axis2 defines the second axis
  2790. * @param axis3 defines the third axis
  2791. * @returns the new quaternion
  2792. */
  2793. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2794. /**
  2795. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2796. * @param axis1 defines the first axis
  2797. * @param axis2 defines the second axis
  2798. * @param axis3 defines the third axis
  2799. * @param ref defines the target quaternion
  2800. */
  2801. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2802. /**
  2803. * Interpolates between two quaternions
  2804. * @param left defines first quaternion
  2805. * @param right defines second quaternion
  2806. * @param amount defines the gradient to use
  2807. * @returns the new interpolated quaternion
  2808. */
  2809. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2810. /**
  2811. * Interpolates between two quaternions and stores it into a target quaternion
  2812. * @param left defines first quaternion
  2813. * @param right defines second quaternion
  2814. * @param amount defines the gradient to use
  2815. * @param result defines the target quaternion
  2816. */
  2817. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2818. /**
  2819. * Interpolate between two quaternions using Hermite interpolation
  2820. * @param value1 defines first quaternion
  2821. * @param tangent1 defines the incoming tangent
  2822. * @param value2 defines second quaternion
  2823. * @param tangent2 defines the outgoing tangent
  2824. * @param amount defines the target quaternion
  2825. * @returns the new interpolated quaternion
  2826. */
  2827. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2828. }
  2829. /**
  2830. * Class used to store matrix data (4x4)
  2831. */
  2832. export class Matrix {
  2833. private static _updateFlagSeed;
  2834. private static _identityReadOnly;
  2835. private _isIdentity;
  2836. private _isIdentityDirty;
  2837. private _isIdentity3x2;
  2838. private _isIdentity3x2Dirty;
  2839. /**
  2840. * Gets the update flag of the matrix which is an unique number for the matrix.
  2841. * It will be incremented every time the matrix data change.
  2842. * You can use it to speed the comparison between two versions of the same matrix.
  2843. */
  2844. updateFlag: number;
  2845. private readonly _m;
  2846. /**
  2847. * Gets the internal data of the matrix
  2848. */
  2849. readonly m: DeepImmutable<Float32Array>;
  2850. /** @hidden */ markAsUpdated(): void;
  2851. /** @hidden */
  2852. private _updateIdentityStatus;
  2853. /**
  2854. * Creates an empty matrix (filled with zeros)
  2855. */
  2856. constructor();
  2857. /**
  2858. * Check if the current matrix is identity
  2859. * @returns true is the matrix is the identity matrix
  2860. */
  2861. isIdentity(): boolean;
  2862. /**
  2863. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2864. * @returns true is the matrix is the identity matrix
  2865. */
  2866. isIdentityAs3x2(): boolean;
  2867. /**
  2868. * Gets the determinant of the matrix
  2869. * @returns the matrix determinant
  2870. */
  2871. determinant(): number;
  2872. /**
  2873. * Returns the matrix as a Float32Array
  2874. * @returns the matrix underlying array
  2875. */
  2876. toArray(): DeepImmutable<Float32Array>;
  2877. /**
  2878. * Returns the matrix as a Float32Array
  2879. * @returns the matrix underlying array.
  2880. */
  2881. asArray(): DeepImmutable<Float32Array>;
  2882. /**
  2883. * Inverts the current matrix in place
  2884. * @returns the current inverted matrix
  2885. */
  2886. invert(): Matrix;
  2887. /**
  2888. * Sets all the matrix elements to zero
  2889. * @returns the current matrix
  2890. */
  2891. reset(): Matrix;
  2892. /**
  2893. * Adds the current matrix with a second one
  2894. * @param other defines the matrix to add
  2895. * @returns a new matrix as the addition of the current matrix and the given one
  2896. */
  2897. add(other: DeepImmutable<Matrix>): Matrix;
  2898. /**
  2899. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2900. * @param other defines the matrix to add
  2901. * @param result defines the target matrix
  2902. * @returns the current matrix
  2903. */
  2904. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2905. /**
  2906. * Adds in place the given matrix to the current matrix
  2907. * @param other defines the second operand
  2908. * @returns the current updated matrix
  2909. */
  2910. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2911. /**
  2912. * Sets the given matrix to the current inverted Matrix
  2913. * @param other defines the target matrix
  2914. * @returns the unmodified current matrix
  2915. */
  2916. invertToRef(other: Matrix): Matrix;
  2917. /**
  2918. * add a value at the specified position in the current Matrix
  2919. * @param index the index of the value within the matrix. between 0 and 15.
  2920. * @param value the value to be added
  2921. * @returns the current updated matrix
  2922. */
  2923. addAtIndex(index: number, value: number): Matrix;
  2924. /**
  2925. * mutiply the specified position in the current Matrix by a value
  2926. * @param index the index of the value within the matrix. between 0 and 15.
  2927. * @param value the value to be added
  2928. * @returns the current updated matrix
  2929. */
  2930. multiplyAtIndex(index: number, value: number): Matrix;
  2931. /**
  2932. * Inserts the translation vector (using 3 floats) in the current matrix
  2933. * @param x defines the 1st component of the translation
  2934. * @param y defines the 2nd component of the translation
  2935. * @param z defines the 3rd component of the translation
  2936. * @returns the current updated matrix
  2937. */
  2938. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2939. /**
  2940. * Adds the translation vector (using 3 floats) in the current matrix
  2941. * @param x defines the 1st component of the translation
  2942. * @param y defines the 2nd component of the translation
  2943. * @param z defines the 3rd component of the translation
  2944. * @returns the current updated matrix
  2945. */
  2946. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2947. /**
  2948. * Inserts the translation vector in the current matrix
  2949. * @param vector3 defines the translation to insert
  2950. * @returns the current updated matrix
  2951. */
  2952. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2953. /**
  2954. * Gets the translation value of the current matrix
  2955. * @returns a new Vector3 as the extracted translation from the matrix
  2956. */
  2957. getTranslation(): Vector3;
  2958. /**
  2959. * Fill a Vector3 with the extracted translation from the matrix
  2960. * @param result defines the Vector3 where to store the translation
  2961. * @returns the current matrix
  2962. */
  2963. getTranslationToRef(result: Vector3): Matrix;
  2964. /**
  2965. * Remove rotation and scaling part from the matrix
  2966. * @returns the updated matrix
  2967. */
  2968. removeRotationAndScaling(): Matrix;
  2969. /**
  2970. * Multiply two matrices
  2971. * @param other defines the second operand
  2972. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2973. */
  2974. multiply(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Copy the current matrix from the given one
  2977. * @param other defines the source matrix
  2978. * @returns the current updated matrix
  2979. */
  2980. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2981. /**
  2982. * Populates the given array from the starting index with the current matrix values
  2983. * @param array defines the target array
  2984. * @param offset defines the offset in the target array where to start storing values
  2985. * @returns the current matrix
  2986. */
  2987. copyToArray(array: Float32Array, offset?: number): Matrix;
  2988. /**
  2989. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2990. * @param other defines the second operand
  2991. * @param result defines the matrix where to store the multiplication
  2992. * @returns the current matrix
  2993. */
  2994. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2995. /**
  2996. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2997. * @param other defines the second operand
  2998. * @param result defines the array where to store the multiplication
  2999. * @param offset defines the offset in the target array where to start storing values
  3000. * @returns the current matrix
  3001. */
  3002. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3003. /**
  3004. * Check equality between this matrix and a second one
  3005. * @param value defines the second matrix to compare
  3006. * @returns true is the current matrix and the given one values are strictly equal
  3007. */
  3008. equals(value: DeepImmutable<Matrix>): boolean;
  3009. /**
  3010. * Clone the current matrix
  3011. * @returns a new matrix from the current matrix
  3012. */
  3013. clone(): Matrix;
  3014. /**
  3015. * Returns the name of the current matrix class
  3016. * @returns the string "Matrix"
  3017. */
  3018. getClassName(): string;
  3019. /**
  3020. * Gets the hash code of the current matrix
  3021. * @returns the hash code
  3022. */
  3023. getHashCode(): number;
  3024. /**
  3025. * Decomposes the current Matrix into a translation, rotation and scaling components
  3026. * @param scale defines the scale vector3 given as a reference to update
  3027. * @param rotation defines the rotation quaternion given as a reference to update
  3028. * @param translation defines the translation vector3 given as a reference to update
  3029. * @returns true if operation was successful
  3030. */
  3031. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3032. /**
  3033. * Gets specific row of the matrix
  3034. * @param index defines the number of the row to get
  3035. * @returns the index-th row of the current matrix as a new Vector4
  3036. */
  3037. getRow(index: number): Nullable<Vector4>;
  3038. /**
  3039. * Sets the index-th row of the current matrix to the vector4 values
  3040. * @param index defines the number of the row to set
  3041. * @param row defines the target vector4
  3042. * @returns the updated current matrix
  3043. */
  3044. setRow(index: number, row: Vector4): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix
  3047. * @returns the new transposed matrix
  3048. */
  3049. transpose(): Matrix;
  3050. /**
  3051. * Compute the transpose of the matrix and store it in a given matrix
  3052. * @param result defines the target matrix
  3053. * @returns the current matrix
  3054. */
  3055. transposeToRef(result: Matrix): Matrix;
  3056. /**
  3057. * Sets the index-th row of the current matrix with the given 4 x float values
  3058. * @param index defines the row index
  3059. * @param x defines the x component to set
  3060. * @param y defines the y component to set
  3061. * @param z defines the z component to set
  3062. * @param w defines the w component to set
  3063. * @returns the updated current matrix
  3064. */
  3065. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3066. /**
  3067. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3068. * @param scale defines the scale factor
  3069. * @returns a new matrix
  3070. */
  3071. scale(scale: number): Matrix;
  3072. /**
  3073. * Scale the current matrix values by a factor to a given result matrix
  3074. * @param scale defines the scale factor
  3075. * @param result defines the matrix to store the result
  3076. * @returns the current matrix
  3077. */
  3078. scaleToRef(scale: number, result: Matrix): Matrix;
  3079. /**
  3080. * Scale the current matrix values by a factor and add the result to a given matrix
  3081. * @param scale defines the scale factor
  3082. * @param result defines the Matrix to store the result
  3083. * @returns the current matrix
  3084. */
  3085. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3086. /**
  3087. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3088. * @param ref matrix to store the result
  3089. */
  3090. toNormalMatrix(ref: Matrix): void;
  3091. /**
  3092. * Gets only rotation part of the current matrix
  3093. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3094. */
  3095. getRotationMatrix(): Matrix;
  3096. /**
  3097. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3098. * @param result defines the target matrix to store data to
  3099. * @returns the current matrix
  3100. */
  3101. getRotationMatrixToRef(result: Matrix): Matrix;
  3102. /**
  3103. * Toggles model matrix from being right handed to left handed in place and vice versa
  3104. */
  3105. toggleModelMatrixHandInPlace(): void;
  3106. /**
  3107. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleProjectionMatrixHandInPlace(): void;
  3110. /**
  3111. * Creates a matrix from an array
  3112. * @param array defines the source array
  3113. * @param offset defines an offset in the source array
  3114. * @returns a new Matrix set from the starting index of the given array
  3115. */
  3116. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3117. /**
  3118. * Copy the content of an array into a given matrix
  3119. * @param array defines the source array
  3120. * @param offset defines an offset in the source array
  3121. * @param result defines the target matrix
  3122. */
  3123. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3124. /**
  3125. * Stores an array into a matrix after having multiplied each component by a given factor
  3126. * @param array defines the source array
  3127. * @param offset defines the offset in the source array
  3128. * @param scale defines the scaling factor
  3129. * @param result defines the target matrix
  3130. */
  3131. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3132. /**
  3133. * Gets an identity matrix that must not be updated
  3134. */
  3135. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3136. /**
  3137. * Stores a list of values (16) inside a given matrix
  3138. * @param initialM11 defines 1st value of 1st row
  3139. * @param initialM12 defines 2nd value of 1st row
  3140. * @param initialM13 defines 3rd value of 1st row
  3141. * @param initialM14 defines 4th value of 1st row
  3142. * @param initialM21 defines 1st value of 2nd row
  3143. * @param initialM22 defines 2nd value of 2nd row
  3144. * @param initialM23 defines 3rd value of 2nd row
  3145. * @param initialM24 defines 4th value of 2nd row
  3146. * @param initialM31 defines 1st value of 3rd row
  3147. * @param initialM32 defines 2nd value of 3rd row
  3148. * @param initialM33 defines 3rd value of 3rd row
  3149. * @param initialM34 defines 4th value of 3rd row
  3150. * @param initialM41 defines 1st value of 4th row
  3151. * @param initialM42 defines 2nd value of 4th row
  3152. * @param initialM43 defines 3rd value of 4th row
  3153. * @param initialM44 defines 4th value of 4th row
  3154. * @param result defines the target matrix
  3155. */
  3156. 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;
  3157. /**
  3158. * Creates new matrix from a list of values (16)
  3159. * @param initialM11 defines 1st value of 1st row
  3160. * @param initialM12 defines 2nd value of 1st row
  3161. * @param initialM13 defines 3rd value of 1st row
  3162. * @param initialM14 defines 4th value of 1st row
  3163. * @param initialM21 defines 1st value of 2nd row
  3164. * @param initialM22 defines 2nd value of 2nd row
  3165. * @param initialM23 defines 3rd value of 2nd row
  3166. * @param initialM24 defines 4th value of 2nd row
  3167. * @param initialM31 defines 1st value of 3rd row
  3168. * @param initialM32 defines 2nd value of 3rd row
  3169. * @param initialM33 defines 3rd value of 3rd row
  3170. * @param initialM34 defines 4th value of 3rd row
  3171. * @param initialM41 defines 1st value of 4th row
  3172. * @param initialM42 defines 2nd value of 4th row
  3173. * @param initialM43 defines 3rd value of 4th row
  3174. * @param initialM44 defines 4th value of 4th row
  3175. * @returns the new matrix
  3176. */
  3177. 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;
  3178. /**
  3179. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3180. * @param scale defines the scale vector3
  3181. * @param rotation defines the rotation quaternion
  3182. * @param translation defines the translation vector3
  3183. * @returns a new matrix
  3184. */
  3185. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3186. /**
  3187. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3188. * @param scale defines the scale vector3
  3189. * @param rotation defines the rotation quaternion
  3190. * @param translation defines the translation vector3
  3191. * @param result defines the target matrix
  3192. */
  3193. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3194. /**
  3195. * Creates a new identity matrix
  3196. * @returns a new identity matrix
  3197. */
  3198. static Identity(): Matrix;
  3199. /**
  3200. * Creates a new identity matrix and stores the result in a given matrix
  3201. * @param result defines the target matrix
  3202. */
  3203. static IdentityToRef(result: Matrix): void;
  3204. /**
  3205. * Creates a new zero matrix
  3206. * @returns a new zero matrix
  3207. */
  3208. static Zero(): Matrix;
  3209. /**
  3210. * Creates a new rotation matrix for "angle" radians around the X axis
  3211. * @param angle defines the angle (in radians) to use
  3212. * @return the new matrix
  3213. */
  3214. static RotationX(angle: number): Matrix;
  3215. /**
  3216. * Creates a new matrix as the invert of a given matrix
  3217. * @param source defines the source matrix
  3218. * @returns the new matrix
  3219. */
  3220. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3223. * @param angle defines the angle (in radians) to use
  3224. * @param result defines the target matrix
  3225. */
  3226. static RotationXToRef(angle: number, result: Matrix): void;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis
  3229. * @param angle defines the angle (in radians) to use
  3230. * @return the new matrix
  3231. */
  3232. static RotationY(angle: number): Matrix;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3235. * @param angle defines the angle (in radians) to use
  3236. * @param result defines the target matrix
  3237. */
  3238. static RotationYToRef(angle: number, result: Matrix): void;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis
  3241. * @param angle defines the angle (in radians) to use
  3242. * @return the new matrix
  3243. */
  3244. static RotationZ(angle: number): Matrix;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3247. * @param angle defines the angle (in radians) to use
  3248. * @param result defines the target matrix
  3249. */
  3250. static RotationZToRef(angle: number, result: Matrix): void;
  3251. /**
  3252. * Creates a new rotation matrix for "angle" radians around the given axis
  3253. * @param axis defines the axis to use
  3254. * @param angle defines the angle (in radians) to use
  3255. * @return the new matrix
  3256. */
  3257. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3258. /**
  3259. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3260. * @param axis defines the axis to use
  3261. * @param angle defines the angle (in radians) to use
  3262. * @param result defines the target matrix
  3263. */
  3264. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3265. /**
  3266. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3267. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3268. * @param from defines the vector to align
  3269. * @param to defines the vector to align to
  3270. * @param result defines the target matrix
  3271. */
  3272. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3273. /**
  3274. * Creates a rotation matrix
  3275. * @param yaw defines the yaw angle in radians (Y axis)
  3276. * @param pitch defines the pitch angle in radians (X axis)
  3277. * @param roll defines the roll angle in radians (X axis)
  3278. * @returns the new rotation matrix
  3279. */
  3280. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3281. /**
  3282. * Creates a rotation matrix and stores it in a given matrix
  3283. * @param yaw defines the yaw angle in radians (Y axis)
  3284. * @param pitch defines the pitch angle in radians (X axis)
  3285. * @param roll defines the roll angle in radians (X axis)
  3286. * @param result defines the target matrix
  3287. */
  3288. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3289. /**
  3290. * Creates a scaling matrix
  3291. * @param x defines the scale factor on X axis
  3292. * @param y defines the scale factor on Y axis
  3293. * @param z defines the scale factor on Z axis
  3294. * @returns the new matrix
  3295. */
  3296. static Scaling(x: number, y: number, z: number): Matrix;
  3297. /**
  3298. * Creates a scaling matrix and stores it in a given matrix
  3299. * @param x defines the scale factor on X axis
  3300. * @param y defines the scale factor on Y axis
  3301. * @param z defines the scale factor on Z axis
  3302. * @param result defines the target matrix
  3303. */
  3304. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3305. /**
  3306. * Creates a translation matrix
  3307. * @param x defines the translation on X axis
  3308. * @param y defines the translation on Y axis
  3309. * @param z defines the translationon Z axis
  3310. * @returns the new matrix
  3311. */
  3312. static Translation(x: number, y: number, z: number): Matrix;
  3313. /**
  3314. * Creates a translation matrix and stores it in a given matrix
  3315. * @param x defines the translation on X axis
  3316. * @param y defines the translation on Y axis
  3317. * @param z defines the translationon Z axis
  3318. * @param result defines the target matrix
  3319. */
  3320. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3321. /**
  3322. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3323. * @param startValue defines the start value
  3324. * @param endValue defines the end value
  3325. * @param gradient defines the gradient factor
  3326. * @returns the new matrix
  3327. */
  3328. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3329. /**
  3330. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3331. * @param startValue defines the start value
  3332. * @param endValue defines the end value
  3333. * @param gradient defines the gradient factor
  3334. * @param result defines the Matrix object where to store data
  3335. */
  3336. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3337. /**
  3338. * Builds a new matrix whose values are computed by:
  3339. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3340. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3341. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3342. * @param startValue defines the first matrix
  3343. * @param endValue defines the second matrix
  3344. * @param gradient defines the gradient between the two matrices
  3345. * @returns the new matrix
  3346. */
  3347. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3348. /**
  3349. * Update a matrix to values which are computed by:
  3350. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3351. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3352. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3353. * @param startValue defines the first matrix
  3354. * @param endValue defines the second matrix
  3355. * @param gradient defines the gradient between the two matrices
  3356. * @param result defines the target matrix
  3357. */
  3358. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3359. /**
  3360. * 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"
  3361. * This function works in left handed mode
  3362. * @param eye defines the final position of the entity
  3363. * @param target defines where the entity should look at
  3364. * @param up defines the up vector for the entity
  3365. * @returns the new matrix
  3366. */
  3367. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3368. /**
  3369. * 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".
  3370. * This function works in left handed mode
  3371. * @param eye defines the final position of the entity
  3372. * @param target defines where the entity should look at
  3373. * @param up defines the up vector for the entity
  3374. * @param result defines the target matrix
  3375. */
  3376. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3377. /**
  3378. * 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"
  3379. * This function works in right handed mode
  3380. * @param eye defines the final position of the entity
  3381. * @param target defines where the entity should look at
  3382. * @param up defines the up vector for the entity
  3383. * @returns the new matrix
  3384. */
  3385. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3386. /**
  3387. * 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".
  3388. * This function works in right handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @param result defines the target matrix
  3393. */
  3394. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3395. /**
  3396. * Create a left-handed orthographic projection matrix
  3397. * @param width defines the viewport width
  3398. * @param height defines the viewport height
  3399. * @param znear defines the near clip plane
  3400. * @param zfar defines the far clip plane
  3401. * @returns a new matrix as a left-handed orthographic projection matrix
  3402. */
  3403. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3404. /**
  3405. * Store a left-handed orthographic projection to a given matrix
  3406. * @param width defines the viewport width
  3407. * @param height defines the viewport height
  3408. * @param znear defines the near clip plane
  3409. * @param zfar defines the far clip plane
  3410. * @param result defines the target matrix
  3411. */
  3412. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3413. /**
  3414. * Create a left-handed orthographic projection matrix
  3415. * @param left defines the viewport left coordinate
  3416. * @param right defines the viewport right coordinate
  3417. * @param bottom defines the viewport bottom coordinate
  3418. * @param top defines the viewport top coordinate
  3419. * @param znear defines the near clip plane
  3420. * @param zfar defines the far clip plane
  3421. * @returns a new matrix as a left-handed orthographic projection matrix
  3422. */
  3423. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3424. /**
  3425. * Stores a left-handed orthographic projection into a given matrix
  3426. * @param left defines the viewport left coordinate
  3427. * @param right defines the viewport right coordinate
  3428. * @param bottom defines the viewport bottom coordinate
  3429. * @param top defines the viewport top coordinate
  3430. * @param znear defines the near clip plane
  3431. * @param zfar defines the far clip plane
  3432. * @param result defines the target matrix
  3433. */
  3434. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3435. /**
  3436. * Creates a right-handed orthographic projection matrix
  3437. * @param left defines the viewport left coordinate
  3438. * @param right defines the viewport right coordinate
  3439. * @param bottom defines the viewport bottom coordinate
  3440. * @param top defines the viewport top coordinate
  3441. * @param znear defines the near clip plane
  3442. * @param zfar defines the far clip plane
  3443. * @returns a new matrix as a right-handed orthographic projection matrix
  3444. */
  3445. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3446. /**
  3447. * Stores a right-handed orthographic projection into a given matrix
  3448. * @param left defines the viewport left coordinate
  3449. * @param right defines the viewport right coordinate
  3450. * @param bottom defines the viewport bottom coordinate
  3451. * @param top defines the viewport top coordinate
  3452. * @param znear defines the near clip plane
  3453. * @param zfar defines the far clip plane
  3454. * @param result defines the target matrix
  3455. */
  3456. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3457. /**
  3458. * Creates a left-handed perspective projection matrix
  3459. * @param width defines the viewport width
  3460. * @param height defines the viewport height
  3461. * @param znear defines the near clip plane
  3462. * @param zfar defines the far clip plane
  3463. * @returns a new matrix as a left-handed perspective projection matrix
  3464. */
  3465. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3466. /**
  3467. * Creates a left-handed perspective projection matrix
  3468. * @param fov defines the horizontal field of view
  3469. * @param aspect defines the aspect ratio
  3470. * @param znear defines the near clip plane
  3471. * @param zfar defines the far clip plane
  3472. * @returns a new matrix as a left-handed perspective projection matrix
  3473. */
  3474. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3475. /**
  3476. * Stores a left-handed perspective projection into a given matrix
  3477. * @param fov defines the horizontal field of view
  3478. * @param aspect defines the aspect ratio
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3483. */
  3484. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3485. /**
  3486. * Creates a right-handed perspective projection matrix
  3487. * @param fov defines the horizontal field of view
  3488. * @param aspect defines the aspect ratio
  3489. * @param znear defines the near clip plane
  3490. * @param zfar defines the far clip plane
  3491. * @returns a new matrix as a right-handed perspective projection matrix
  3492. */
  3493. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3494. /**
  3495. * Stores a right-handed perspective projection into a given matrix
  3496. * @param fov defines the horizontal field of view
  3497. * @param aspect defines the aspect ratio
  3498. * @param znear defines the near clip plane
  3499. * @param zfar defines the far clip plane
  3500. * @param result defines the target matrix
  3501. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3502. */
  3503. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3504. /**
  3505. * Stores a perspective projection for WebVR info a given matrix
  3506. * @param fov defines the field of view
  3507. * @param znear defines the near clip plane
  3508. * @param zfar defines the far clip plane
  3509. * @param result defines the target matrix
  3510. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3511. */
  3512. static PerspectiveFovWebVRToRef(fov: {
  3513. upDegrees: number;
  3514. downDegrees: number;
  3515. leftDegrees: number;
  3516. rightDegrees: number;
  3517. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3518. /**
  3519. * Computes a complete transformation matrix
  3520. * @param viewport defines the viewport to use
  3521. * @param world defines the world matrix
  3522. * @param view defines the view matrix
  3523. * @param projection defines the projection matrix
  3524. * @param zmin defines the near clip plane
  3525. * @param zmax defines the far clip plane
  3526. * @returns the transformation matrix
  3527. */
  3528. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3529. /**
  3530. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3531. * @param matrix defines the matrix to use
  3532. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3533. */
  3534. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3535. /**
  3536. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3537. * @param matrix defines the matrix to use
  3538. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3539. */
  3540. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3541. /**
  3542. * Compute the transpose of a given matrix
  3543. * @param matrix defines the matrix to transpose
  3544. * @returns the new matrix
  3545. */
  3546. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3547. /**
  3548. * Compute the transpose of a matrix and store it in a target matrix
  3549. * @param matrix defines the matrix to transpose
  3550. * @param result defines the target matrix
  3551. */
  3552. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3553. /**
  3554. * Computes a reflection matrix from a plane
  3555. * @param plane defines the reflection plane
  3556. * @returns a new matrix
  3557. */
  3558. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3559. /**
  3560. * Computes a reflection matrix from a plane
  3561. * @param plane defines the reflection plane
  3562. * @param result defines the target matrix
  3563. */
  3564. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3565. /**
  3566. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3567. * @param xaxis defines the value of the 1st axis
  3568. * @param yaxis defines the value of the 2nd axis
  3569. * @param zaxis defines the value of the 3rd axis
  3570. * @param result defines the target matrix
  3571. */
  3572. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3573. /**
  3574. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3575. * @param quat defines the quaternion to use
  3576. * @param result defines the target matrix
  3577. */
  3578. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3579. }
  3580. /**
  3581. * Represens a plane by the equation ax + by + cz + d = 0
  3582. */
  3583. export class Plane {
  3584. /**
  3585. * Normal of the plane (a,b,c)
  3586. */
  3587. normal: Vector3;
  3588. /**
  3589. * d component of the plane
  3590. */
  3591. d: number;
  3592. /**
  3593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3594. * @param a a component of the plane
  3595. * @param b b component of the plane
  3596. * @param c c component of the plane
  3597. * @param d d component of the plane
  3598. */
  3599. constructor(a: number, b: number, c: number, d: number);
  3600. /**
  3601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3602. */
  3603. asArray(): number[];
  3604. /**
  3605. * @returns a new plane copied from the current Plane.
  3606. */
  3607. clone(): Plane;
  3608. /**
  3609. * @returns the string "Plane".
  3610. */
  3611. getClassName(): string;
  3612. /**
  3613. * @returns the Plane hash code.
  3614. */
  3615. getHashCode(): number;
  3616. /**
  3617. * Normalize the current Plane in place.
  3618. * @returns the updated Plane.
  3619. */
  3620. normalize(): Plane;
  3621. /**
  3622. * Applies a transformation the plane and returns the result
  3623. * @param transformation the transformation matrix to be applied to the plane
  3624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3625. */
  3626. transform(transformation: DeepImmutable<Matrix>): Plane;
  3627. /**
  3628. * Calcualtte the dot product between the point and the plane normal
  3629. * @param point point to calculate the dot product with
  3630. * @returns the dot product (float) of the point coordinates and the plane normal.
  3631. */
  3632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3633. /**
  3634. * Updates the current Plane from the plane defined by the three given points.
  3635. * @param point1 one of the points used to contruct the plane
  3636. * @param point2 one of the points used to contruct the plane
  3637. * @param point3 one of the points used to contruct the plane
  3638. * @returns the updated Plane.
  3639. */
  3640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3641. /**
  3642. * Checks if the plane is facing a given direction
  3643. * @param direction the direction to check if the plane is facing
  3644. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3645. * @returns True is the vector "direction" is the same side than the plane normal.
  3646. */
  3647. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3648. /**
  3649. * Calculates the distance to a point
  3650. * @param point point to calculate distance to
  3651. * @returns the signed distance (float) from the given point to the Plane.
  3652. */
  3653. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3654. /**
  3655. * Creates a plane from an array
  3656. * @param array the array to create a plane from
  3657. * @returns a new Plane from the given array.
  3658. */
  3659. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3660. /**
  3661. * Creates a plane from three points
  3662. * @param point1 point used to create the plane
  3663. * @param point2 point used to create the plane
  3664. * @param point3 point used to create the plane
  3665. * @returns a new Plane defined by the three given points.
  3666. */
  3667. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Creates a plane from an origin point and a normal
  3670. * @param origin origin of the plane to be constructed
  3671. * @param normal normal of the plane to be constructed
  3672. * @returns a new Plane the normal vector to this plane at the given origin point.
  3673. * Note : the vector "normal" is updated because normalized.
  3674. */
  3675. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3676. /**
  3677. * Calculates the distance from a plane and a point
  3678. * @param origin origin of the plane to be constructed
  3679. * @param normal normal of the plane to be constructed
  3680. * @param point point to calculate distance to
  3681. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3682. */
  3683. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3684. }
  3685. /**
  3686. * Class used to represent a viewport on screen
  3687. */
  3688. export class Viewport {
  3689. /** viewport left coordinate */
  3690. x: number;
  3691. /** viewport top coordinate */
  3692. y: number;
  3693. /**viewport width */
  3694. width: number;
  3695. /** viewport height */
  3696. height: number;
  3697. /**
  3698. * Creates a Viewport object located at (x, y) and sized (width, height)
  3699. * @param x defines viewport left coordinate
  3700. * @param y defines viewport top coordinate
  3701. * @param width defines the viewport width
  3702. * @param height defines the viewport height
  3703. */
  3704. constructor(
  3705. /** viewport left coordinate */
  3706. x: number,
  3707. /** viewport top coordinate */
  3708. y: number,
  3709. /**viewport width */
  3710. width: number,
  3711. /** viewport height */
  3712. height: number);
  3713. /**
  3714. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3715. * @param renderWidth defines the rendering width
  3716. * @param renderHeight defines the rendering height
  3717. * @returns a new Viewport
  3718. */
  3719. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3720. /**
  3721. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3722. * @param renderWidth defines the rendering width
  3723. * @param renderHeight defines the rendering height
  3724. * @param ref defines the target viewport
  3725. * @returns the current viewport
  3726. */
  3727. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3728. /**
  3729. * Returns a new Viewport copied from the current one
  3730. * @returns a new Viewport
  3731. */
  3732. clone(): Viewport;
  3733. }
  3734. /**
  3735. * Reprasents a camera frustum
  3736. */
  3737. export class Frustum {
  3738. /**
  3739. * Gets the planes representing the frustum
  3740. * @param transform matrix to be applied to the returned planes
  3741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3742. */
  3743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3744. /**
  3745. * Gets the near frustum plane transformed by the transform matrix
  3746. * @param transform transformation matrix to be applied to the resulting frustum plane
  3747. * @param frustumPlane the resuling frustum plane
  3748. */
  3749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3750. /**
  3751. * Gets the far frustum plane transformed by the transform matrix
  3752. * @param transform transformation matrix to be applied to the resulting frustum plane
  3753. * @param frustumPlane the resuling frustum plane
  3754. */
  3755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3756. /**
  3757. * Gets the left frustum plane transformed by the transform matrix
  3758. * @param transform transformation matrix to be applied to the resulting frustum plane
  3759. * @param frustumPlane the resuling frustum plane
  3760. */
  3761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3762. /**
  3763. * Gets the right frustum plane transformed by the transform matrix
  3764. * @param transform transformation matrix to be applied to the resulting frustum plane
  3765. * @param frustumPlane the resuling frustum plane
  3766. */
  3767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3768. /**
  3769. * Gets the top frustum plane transformed by the transform matrix
  3770. * @param transform transformation matrix to be applied to the resulting frustum plane
  3771. * @param frustumPlane the resuling frustum plane
  3772. */
  3773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3774. /**
  3775. * Gets the bottom frustum plane transformed by the transform matrix
  3776. * @param transform transformation matrix to be applied to the resulting frustum plane
  3777. * @param frustumPlane the resuling frustum plane
  3778. */
  3779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3780. /**
  3781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3782. * @param transform transformation matrix to be applied to the resulting frustum planes
  3783. * @param frustumPlanes the resuling frustum planes
  3784. */
  3785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3786. }
  3787. /** Defines supported spaces */
  3788. export enum Space {
  3789. /** Local (object) space */
  3790. LOCAL = 0,
  3791. /** World space */
  3792. WORLD = 1,
  3793. /** Bone space */
  3794. BONE = 2
  3795. }
  3796. /** Defines the 3 main axes */
  3797. export class Axis {
  3798. /** X axis */
  3799. static X: Vector3;
  3800. /** Y axis */
  3801. static Y: Vector3;
  3802. /** Z axis */
  3803. static Z: Vector3;
  3804. }
  3805. /** Class used to represent a Bezier curve */
  3806. export class BezierCurve {
  3807. /**
  3808. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3809. * @param t defines the time
  3810. * @param x1 defines the left coordinate on X axis
  3811. * @param y1 defines the left coordinate on Y axis
  3812. * @param x2 defines the right coordinate on X axis
  3813. * @param y2 defines the right coordinate on Y axis
  3814. * @returns the interpolated value
  3815. */
  3816. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3817. }
  3818. /**
  3819. * Defines potential orientation for back face culling
  3820. */
  3821. export enum Orientation {
  3822. /**
  3823. * Clockwise
  3824. */
  3825. CW = 0,
  3826. /** Counter clockwise */
  3827. CCW = 1
  3828. }
  3829. /**
  3830. * Defines angle representation
  3831. */
  3832. export class Angle {
  3833. private _radians;
  3834. /**
  3835. * Creates an Angle object of "radians" radians (float).
  3836. * @param radians the angle in radians
  3837. */
  3838. constructor(radians: number);
  3839. /**
  3840. * Get value in degrees
  3841. * @returns the Angle value in degrees (float)
  3842. */
  3843. degrees(): number;
  3844. /**
  3845. * Get value in radians
  3846. * @returns the Angle value in radians (float)
  3847. */
  3848. radians(): number;
  3849. /**
  3850. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3851. * @param a defines first vector
  3852. * @param b defines second vector
  3853. * @returns a new Angle
  3854. */
  3855. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3856. /**
  3857. * Gets a new Angle object from the given float in radians
  3858. * @param radians defines the angle value in radians
  3859. * @returns a new Angle
  3860. */
  3861. static FromRadians(radians: number): Angle;
  3862. /**
  3863. * Gets a new Angle object from the given float in degrees
  3864. * @param degrees defines the angle value in degrees
  3865. * @returns a new Angle
  3866. */
  3867. static FromDegrees(degrees: number): Angle;
  3868. }
  3869. /**
  3870. * This represents an arc in a 2d space.
  3871. */
  3872. export class Arc2 {
  3873. /** Defines the start point of the arc */
  3874. startPoint: Vector2;
  3875. /** Defines the mid point of the arc */
  3876. midPoint: Vector2;
  3877. /** Defines the end point of the arc */
  3878. endPoint: Vector2;
  3879. /**
  3880. * Defines the center point of the arc.
  3881. */
  3882. centerPoint: Vector2;
  3883. /**
  3884. * Defines the radius of the arc.
  3885. */
  3886. radius: number;
  3887. /**
  3888. * Defines the angle of the arc (from mid point to end point).
  3889. */
  3890. angle: Angle;
  3891. /**
  3892. * Defines the start angle of the arc (from start point to middle point).
  3893. */
  3894. startAngle: Angle;
  3895. /**
  3896. * Defines the orientation of the arc (clock wise/counter clock wise).
  3897. */
  3898. orientation: Orientation;
  3899. /**
  3900. * Creates an Arc object from the three given points : start, middle and end.
  3901. * @param startPoint Defines the start point of the arc
  3902. * @param midPoint Defines the midlle point of the arc
  3903. * @param endPoint Defines the end point of the arc
  3904. */
  3905. constructor(
  3906. /** Defines the start point of the arc */
  3907. startPoint: Vector2,
  3908. /** Defines the mid point of the arc */
  3909. midPoint: Vector2,
  3910. /** Defines the end point of the arc */
  3911. endPoint: Vector2);
  3912. }
  3913. /**
  3914. * Represents a 2D path made up of multiple 2D points
  3915. */
  3916. export class Path2 {
  3917. private _points;
  3918. private _length;
  3919. /**
  3920. * If the path start and end point are the same
  3921. */
  3922. closed: boolean;
  3923. /**
  3924. * Creates a Path2 object from the starting 2D coordinates x and y.
  3925. * @param x the starting points x value
  3926. * @param y the starting points y value
  3927. */
  3928. constructor(x: number, y: number);
  3929. /**
  3930. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3931. * @param x the added points x value
  3932. * @param y the added points y value
  3933. * @returns the updated Path2.
  3934. */
  3935. addLineTo(x: number, y: number): Path2;
  3936. /**
  3937. * 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.
  3938. * @param midX middle point x value
  3939. * @param midY middle point y value
  3940. * @param endX end point x value
  3941. * @param endY end point y value
  3942. * @param numberOfSegments (default: 36)
  3943. * @returns the updated Path2.
  3944. */
  3945. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3946. /**
  3947. * Closes the Path2.
  3948. * @returns the Path2.
  3949. */
  3950. close(): Path2;
  3951. /**
  3952. * Gets the sum of the distance between each sequential point in the path
  3953. * @returns the Path2 total length (float).
  3954. */
  3955. length(): number;
  3956. /**
  3957. * Gets the points which construct the path
  3958. * @returns the Path2 internal array of points.
  3959. */
  3960. getPoints(): Vector2[];
  3961. /**
  3962. * Retreives the point at the distance aways from the starting point
  3963. * @param normalizedLengthPosition the length along the path to retreive the point from
  3964. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3965. */
  3966. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3967. /**
  3968. * Creates a new path starting from an x and y position
  3969. * @param x starting x value
  3970. * @param y starting y value
  3971. * @returns a new Path2 starting at the coordinates (x, y).
  3972. */
  3973. static StartingAt(x: number, y: number): Path2;
  3974. }
  3975. /**
  3976. * Represents a 3D path made up of multiple 3D points
  3977. */
  3978. export class Path3D {
  3979. /**
  3980. * an array of Vector3, the curve axis of the Path3D
  3981. */
  3982. path: Vector3[];
  3983. private _curve;
  3984. private _distances;
  3985. private _tangents;
  3986. private _normals;
  3987. private _binormals;
  3988. private _raw;
  3989. /**
  3990. * new Path3D(path, normal, raw)
  3991. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3992. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3993. * @param path an array of Vector3, the curve axis of the Path3D
  3994. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3995. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3996. */
  3997. constructor(
  3998. /**
  3999. * an array of Vector3, the curve axis of the Path3D
  4000. */
  4001. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4002. /**
  4003. * Returns the Path3D array of successive Vector3 designing its curve.
  4004. * @returns the Path3D array of successive Vector3 designing its curve.
  4005. */
  4006. getCurve(): Vector3[];
  4007. /**
  4008. * Returns an array populated with tangent vectors on each Path3D curve point.
  4009. * @returns an array populated with tangent vectors on each Path3D curve point.
  4010. */
  4011. getTangents(): Vector3[];
  4012. /**
  4013. * Returns an array populated with normal vectors on each Path3D curve point.
  4014. * @returns an array populated with normal vectors on each Path3D curve point.
  4015. */
  4016. getNormals(): Vector3[];
  4017. /**
  4018. * Returns an array populated with binormal vectors on each Path3D curve point.
  4019. * @returns an array populated with binormal vectors on each Path3D curve point.
  4020. */
  4021. getBinormals(): Vector3[];
  4022. /**
  4023. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4024. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4025. */
  4026. getDistances(): number[];
  4027. /**
  4028. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4029. * @param path path which all values are copied into the curves points
  4030. * @param firstNormal which should be projected onto the curve
  4031. * @returns the same object updated.
  4032. */
  4033. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4034. private _compute;
  4035. private _getFirstNonNullVector;
  4036. private _getLastNonNullVector;
  4037. private _normalVector;
  4038. }
  4039. /**
  4040. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4041. * A Curve3 is designed from a series of successive Vector3.
  4042. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4043. */
  4044. export class Curve3 {
  4045. private _points;
  4046. private _length;
  4047. /**
  4048. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4049. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4050. * @param v1 (Vector3) the control point
  4051. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4052. * @param nbPoints (integer) the wanted number of points in the curve
  4053. * @returns the created Curve3
  4054. */
  4055. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4056. /**
  4057. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4058. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4059. * @param v1 (Vector3) the first control point
  4060. * @param v2 (Vector3) the second control point
  4061. * @param v3 (Vector3) the end point of the Cubic Bezier
  4062. * @param nbPoints (integer) the wanted number of points in the curve
  4063. * @returns the created Curve3
  4064. */
  4065. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4066. /**
  4067. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4068. * @param p1 (Vector3) the origin point of the Hermite Spline
  4069. * @param t1 (Vector3) the tangent vector at the origin point
  4070. * @param p2 (Vector3) the end point of the Hermite Spline
  4071. * @param t2 (Vector3) the tangent vector at the end point
  4072. * @param nbPoints (integer) the wanted number of points in the curve
  4073. * @returns the created Curve3
  4074. */
  4075. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4076. /**
  4077. * Returns a Curve3 object along a CatmullRom Spline curve :
  4078. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4079. * @param nbPoints (integer) the wanted number of points between each curve control points
  4080. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4081. * @returns the created Curve3
  4082. */
  4083. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4084. /**
  4085. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4086. * A Curve3 is designed from a series of successive Vector3.
  4087. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4088. * @param points points which make up the curve
  4089. */
  4090. constructor(points: Vector3[]);
  4091. /**
  4092. * @returns the Curve3 stored array of successive Vector3
  4093. */
  4094. getPoints(): Vector3[];
  4095. /**
  4096. * @returns the computed length (float) of the curve.
  4097. */
  4098. length(): number;
  4099. /**
  4100. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4101. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4102. * curveA and curveB keep unchanged.
  4103. * @param curve the curve to continue from this curve
  4104. * @returns the newly constructed curve
  4105. */
  4106. continue(curve: DeepImmutable<Curve3>): Curve3;
  4107. private _computeLength;
  4108. }
  4109. /**
  4110. * Contains position and normal vectors for a vertex
  4111. */
  4112. export class PositionNormalVertex {
  4113. /** the position of the vertex (defaut: 0,0,0) */
  4114. position: Vector3;
  4115. /** the normal of the vertex (defaut: 0,1,0) */
  4116. normal: Vector3;
  4117. /**
  4118. * Creates a PositionNormalVertex
  4119. * @param position the position of the vertex (defaut: 0,0,0)
  4120. * @param normal the normal of the vertex (defaut: 0,1,0)
  4121. */
  4122. constructor(
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position?: Vector3,
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal?: Vector3);
  4127. /**
  4128. * Clones the PositionNormalVertex
  4129. * @returns the cloned PositionNormalVertex
  4130. */
  4131. clone(): PositionNormalVertex;
  4132. }
  4133. /**
  4134. * Contains position, normal and uv vectors for a vertex
  4135. */
  4136. export class PositionNormalTextureVertex {
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position: Vector3;
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal: Vector3;
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv: Vector2;
  4143. /**
  4144. * Creates a PositionNormalTextureVertex
  4145. * @param position the position of the vertex (defaut: 0,0,0)
  4146. * @param normal the normal of the vertex (defaut: 0,1,0)
  4147. * @param uv the uv of the vertex (default: 0,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3,
  4154. /** the uv of the vertex (default: 0,0) */
  4155. uv?: Vector2);
  4156. /**
  4157. * Clones the PositionNormalTextureVertex
  4158. * @returns the cloned PositionNormalTextureVertex
  4159. */
  4160. clone(): PositionNormalTextureVertex;
  4161. }
  4162. /**
  4163. * @hidden
  4164. */
  4165. export class Tmp {
  4166. static Color3: Color3[];
  4167. static Color4: Color4[];
  4168. static Vector2: Vector2[];
  4169. static Vector3: Vector3[];
  4170. static Vector4: Vector4[];
  4171. static Quaternion: Quaternion[];
  4172. static Matrix: Matrix[];
  4173. }
  4174. }
  4175. declare module BABYLON {
  4176. /**
  4177. * Class used to enable access to offline support
  4178. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4179. */
  4180. export interface IOfflineProvider {
  4181. /**
  4182. * Gets a boolean indicating if scene must be saved in the database
  4183. */
  4184. enableSceneOffline: boolean;
  4185. /**
  4186. * Gets a boolean indicating if textures must be saved in the database
  4187. */
  4188. enableTexturesOffline: boolean;
  4189. /**
  4190. * Open the offline support and make it available
  4191. * @param successCallback defines the callback to call on success
  4192. * @param errorCallback defines the callback to call on error
  4193. */
  4194. open(successCallback: () => void, errorCallback: () => void): void;
  4195. /**
  4196. * Loads an image from the offline support
  4197. * @param url defines the url to load from
  4198. * @param image defines the target DOM image
  4199. */
  4200. loadImage(url: string, image: HTMLImageElement): void;
  4201. /**
  4202. * Loads a file from offline support
  4203. * @param url defines the URL to load from
  4204. * @param sceneLoaded defines a callback to call on success
  4205. * @param progressCallBack defines a callback to call when progress changed
  4206. * @param errorCallback defines a callback to call on error
  4207. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4208. */
  4209. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4210. }
  4211. }
  4212. declare module BABYLON {
  4213. /**
  4214. * A class serves as a medium between the observable and its observers
  4215. */
  4216. export class EventState {
  4217. /**
  4218. * Create a new EventState
  4219. * @param mask defines the mask associated with this state
  4220. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4221. * @param target defines the original target of the state
  4222. * @param currentTarget defines the current target of the state
  4223. */
  4224. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4225. /**
  4226. * Initialize the current event state
  4227. * @param mask defines the mask associated with this state
  4228. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4229. * @param target defines the original target of the state
  4230. * @param currentTarget defines the current target of the state
  4231. * @returns the current event state
  4232. */
  4233. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4234. /**
  4235. * An Observer can set this property to true to prevent subsequent observers of being notified
  4236. */
  4237. skipNextObservers: boolean;
  4238. /**
  4239. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4240. */
  4241. mask: number;
  4242. /**
  4243. * The object that originally notified the event
  4244. */
  4245. target?: any;
  4246. /**
  4247. * The current object in the bubbling phase
  4248. */
  4249. currentTarget?: any;
  4250. /**
  4251. * This will be populated with the return value of the last function that was executed.
  4252. * If it is the first function in the callback chain it will be the event data.
  4253. */
  4254. lastReturnValue?: any;
  4255. }
  4256. /**
  4257. * Represent an Observer registered to a given Observable object.
  4258. */
  4259. export class Observer<T> {
  4260. /**
  4261. * Defines the callback to call when the observer is notified
  4262. */
  4263. callback: (eventData: T, eventState: EventState) => void;
  4264. /**
  4265. * Defines the mask of the observer (used to filter notifications)
  4266. */
  4267. mask: number;
  4268. /**
  4269. * Defines the current scope used to restore the JS context
  4270. */
  4271. scope: any;
  4272. /** @hidden */ willBeUnregistered: boolean;
  4273. /**
  4274. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4275. */
  4276. unregisterOnNextCall: boolean;
  4277. /**
  4278. * Creates a new observer
  4279. * @param callback defines the callback to call when the observer is notified
  4280. * @param mask defines the mask of the observer (used to filter notifications)
  4281. * @param scope defines the current scope used to restore the JS context
  4282. */
  4283. constructor(
  4284. /**
  4285. * Defines the callback to call when the observer is notified
  4286. */
  4287. callback: (eventData: T, eventState: EventState) => void,
  4288. /**
  4289. * Defines the mask of the observer (used to filter notifications)
  4290. */
  4291. mask: number,
  4292. /**
  4293. * Defines the current scope used to restore the JS context
  4294. */
  4295. scope?: any);
  4296. }
  4297. /**
  4298. * Represent a list of observers registered to multiple Observables object.
  4299. */
  4300. export class MultiObserver<T> {
  4301. private _observers;
  4302. private _observables;
  4303. /**
  4304. * Release associated resources
  4305. */
  4306. dispose(): void;
  4307. /**
  4308. * Raise a callback when one of the observable will notify
  4309. * @param observables defines a list of observables to watch
  4310. * @param callback defines the callback to call on notification
  4311. * @param mask defines the mask used to filter notifications
  4312. * @param scope defines the current scope used to restore the JS context
  4313. * @returns the new MultiObserver
  4314. */
  4315. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4316. }
  4317. /**
  4318. * The Observable class is a simple implementation of the Observable pattern.
  4319. *
  4320. * 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.
  4321. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4322. * 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).
  4323. * 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.
  4324. */
  4325. export class Observable<T> {
  4326. private _observers;
  4327. private _eventState;
  4328. private _onObserverAdded;
  4329. /**
  4330. * Creates a new observable
  4331. * @param onObserverAdded defines a callback to call when a new observer is added
  4332. */
  4333. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4334. /**
  4335. * Create a new Observer with the specified callback
  4336. * @param callback the callback that will be executed for that Observer
  4337. * @param mask the mask used to filter observers
  4338. * @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.
  4339. * @param scope optional scope for the callback to be called from
  4340. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4341. * @returns the new observer created for the callback
  4342. */
  4343. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4344. /**
  4345. * Create a new Observer with the specified callback and unregisters after the next notification
  4346. * @param callback the callback that will be executed for that Observer
  4347. * @returns the new observer created for the callback
  4348. */
  4349. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4350. /**
  4351. * Remove an Observer from the Observable object
  4352. * @param observer the instance of the Observer to remove
  4353. * @returns false if it doesn't belong to this Observable
  4354. */
  4355. remove(observer: Nullable<Observer<T>>): boolean;
  4356. /**
  4357. * Remove a callback from the Observable object
  4358. * @param callback the callback to remove
  4359. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4360. * @returns false if it doesn't belong to this Observable
  4361. */
  4362. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4363. private _deferUnregister;
  4364. private _remove;
  4365. /**
  4366. * Moves the observable to the top of the observer list making it get called first when notified
  4367. * @param observer the observer to move
  4368. */
  4369. makeObserverTopPriority(observer: Observer<T>): void;
  4370. /**
  4371. * Moves the observable to the bottom of the observer list making it get called last when notified
  4372. * @param observer the observer to move
  4373. */
  4374. makeObserverBottomPriority(observer: Observer<T>): void;
  4375. /**
  4376. * Notify all Observers by calling their respective callback with the given data
  4377. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4378. * @param eventData defines the data to send to all observers
  4379. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4380. * @param target defines the original target of the state
  4381. * @param currentTarget defines the current target of the state
  4382. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4383. */
  4384. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4385. /**
  4386. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4387. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4388. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4389. * and it is crucial that all callbacks will be executed.
  4390. * The order of the callbacks is kept, callbacks are not executed parallel.
  4391. *
  4392. * @param eventData The data to be sent to each callback
  4393. * @param mask is used to filter observers defaults to -1
  4394. * @param target defines the callback target (see EventState)
  4395. * @param currentTarget defines he current object in the bubbling phase
  4396. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4397. */
  4398. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4399. /**
  4400. * Notify a specific observer
  4401. * @param observer defines the observer to notify
  4402. * @param eventData defines the data to be sent to each callback
  4403. * @param mask is used to filter observers defaults to -1
  4404. */
  4405. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4406. /**
  4407. * Gets a boolean indicating if the observable has at least one observer
  4408. * @returns true is the Observable has at least one Observer registered
  4409. */
  4410. hasObservers(): boolean;
  4411. /**
  4412. * Clear the list of observers
  4413. */
  4414. clear(): void;
  4415. /**
  4416. * Clone the current observable
  4417. * @returns a new observable
  4418. */
  4419. clone(): Observable<T>;
  4420. /**
  4421. * Does this observable handles observer registered with a given mask
  4422. * @param mask defines the mask to be tested
  4423. * @return whether or not one observer registered with the given mask is handeled
  4424. **/
  4425. hasSpecificMask(mask?: number): boolean;
  4426. }
  4427. }
  4428. declare module BABYLON {
  4429. /**
  4430. * Class used to help managing file picking and drag'n'drop
  4431. * File Storage
  4432. */
  4433. export class FilesInputStore {
  4434. /**
  4435. * List of files ready to be loaded
  4436. */
  4437. static FilesToLoad: {
  4438. [key: string]: File;
  4439. };
  4440. }
  4441. }
  4442. declare module BABYLON {
  4443. /** Defines the cross module used constants to avoid circular dependncies */
  4444. export class Constants {
  4445. /** Defines that alpha blending is disabled */
  4446. static readonly ALPHA_DISABLE: number;
  4447. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4448. static readonly ALPHA_ADD: number;
  4449. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4450. static readonly ALPHA_COMBINE: number;
  4451. /** Defines that alpha blending to DEST - SRC * DEST */
  4452. static readonly ALPHA_SUBTRACT: number;
  4453. /** Defines that alpha blending to SRC * DEST */
  4454. static readonly ALPHA_MULTIPLY: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4456. static readonly ALPHA_MAXIMIZED: number;
  4457. /** Defines that alpha blending to SRC + DEST */
  4458. static readonly ALPHA_ONEONE: number;
  4459. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4460. static readonly ALPHA_PREMULTIPLIED: number;
  4461. /**
  4462. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4463. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4464. */
  4465. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4466. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4467. static readonly ALPHA_INTERPOLATE: number;
  4468. /**
  4469. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4470. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4471. */
  4472. static readonly ALPHA_SCREENMODE: number;
  4473. /** Defines that the ressource is not delayed*/
  4474. static readonly DELAYLOADSTATE_NONE: number;
  4475. /** Defines that the ressource was successfully delay loaded */
  4476. static readonly DELAYLOADSTATE_LOADED: number;
  4477. /** Defines that the ressource is currently delay loading */
  4478. static readonly DELAYLOADSTATE_LOADING: number;
  4479. /** Defines that the ressource is delayed and has not started loading */
  4480. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4481. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4482. static readonly NEVER: number;
  4483. /** 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 */
  4484. static readonly ALWAYS: number;
  4485. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4486. static readonly LESS: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4488. static readonly EQUAL: number;
  4489. /** 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 */
  4490. static readonly LEQUAL: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4492. static readonly GREATER: number;
  4493. /** 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 */
  4494. static readonly GEQUAL: number;
  4495. /** 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 */
  4496. static readonly NOTEQUAL: number;
  4497. /** Passed to stencilOperation to specify that stencil value must be kept */
  4498. static readonly KEEP: number;
  4499. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4500. static readonly REPLACE: number;
  4501. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4502. static readonly INCR: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4504. static readonly DECR: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4506. static readonly INVERT: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4508. static readonly INCR_WRAP: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4510. static readonly DECR_WRAP: number;
  4511. /** Texture is not repeating outside of 0..1 UVs */
  4512. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4513. /** Texture is repeating outside of 0..1 UVs */
  4514. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4515. /** Texture is repeating and mirrored */
  4516. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4517. /** ALPHA */
  4518. static readonly TEXTUREFORMAT_ALPHA: number;
  4519. /** LUMINANCE */
  4520. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4521. /** LUMINANCE_ALPHA */
  4522. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4523. /** RGB */
  4524. static readonly TEXTUREFORMAT_RGB: number;
  4525. /** RGBA */
  4526. static readonly TEXTUREFORMAT_RGBA: number;
  4527. /** RED */
  4528. static readonly TEXTUREFORMAT_RED: number;
  4529. /** RED (2nd reference) */
  4530. static readonly TEXTUREFORMAT_R: number;
  4531. /** RG */
  4532. static readonly TEXTUREFORMAT_RG: number;
  4533. /** RED_INTEGER */
  4534. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4535. /** RED_INTEGER (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4537. /** RG_INTEGER */
  4538. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4539. /** RGB_INTEGER */
  4540. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4541. /** RGBA_INTEGER */
  4542. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4543. /** UNSIGNED_BYTE */
  4544. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4545. /** UNSIGNED_BYTE (2nd reference) */
  4546. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4547. /** FLOAT */
  4548. static readonly TEXTURETYPE_FLOAT: number;
  4549. /** HALF_FLOAT */
  4550. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4551. /** BYTE */
  4552. static readonly TEXTURETYPE_BYTE: number;
  4553. /** SHORT */
  4554. static readonly TEXTURETYPE_SHORT: number;
  4555. /** UNSIGNED_SHORT */
  4556. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4557. /** INT */
  4558. static readonly TEXTURETYPE_INT: number;
  4559. /** UNSIGNED_INT */
  4560. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4561. /** UNSIGNED_SHORT_4_4_4_4 */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4563. /** UNSIGNED_SHORT_5_5_5_1 */
  4564. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4565. /** UNSIGNED_SHORT_5_6_5 */
  4566. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4567. /** UNSIGNED_INT_2_10_10_10_REV */
  4568. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4569. /** UNSIGNED_INT_24_8 */
  4570. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4571. /** UNSIGNED_INT_10F_11F_11F_REV */
  4572. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4573. /** UNSIGNED_INT_5_9_9_9_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4575. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4576. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4577. /** nearest is mag = nearest and min = nearest and mip = linear */
  4578. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4579. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4580. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4581. /** Trilinear is mag = linear and min = linear and mip = linear */
  4582. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4589. /** mag = nearest and min = nearest and mip = nearest */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4591. /** mag = nearest and min = linear and mip = nearest */
  4592. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4593. /** mag = nearest and min = linear and mip = linear */
  4594. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = linear and mip = none */
  4596. static readonly TEXTURE_NEAREST_LINEAR: number;
  4597. /** mag = nearest and min = nearest and mip = none */
  4598. static readonly TEXTURE_NEAREST_NEAREST: number;
  4599. /** mag = linear and min = nearest and mip = nearest */
  4600. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4601. /** mag = linear and min = nearest and mip = linear */
  4602. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4603. /** mag = linear and min = linear and mip = none */
  4604. static readonly TEXTURE_LINEAR_LINEAR: number;
  4605. /** mag = linear and min = nearest and mip = none */
  4606. static readonly TEXTURE_LINEAR_NEAREST: number;
  4607. /** Explicit coordinates mode */
  4608. static readonly TEXTURE_EXPLICIT_MODE: number;
  4609. /** Spherical coordinates mode */
  4610. static readonly TEXTURE_SPHERICAL_MODE: number;
  4611. /** Planar coordinates mode */
  4612. static readonly TEXTURE_PLANAR_MODE: number;
  4613. /** Cubic coordinates mode */
  4614. static readonly TEXTURE_CUBIC_MODE: number;
  4615. /** Projection coordinates mode */
  4616. static readonly TEXTURE_PROJECTION_MODE: number;
  4617. /** Skybox coordinates mode */
  4618. static readonly TEXTURE_SKYBOX_MODE: number;
  4619. /** Inverse Cubic coordinates mode */
  4620. static readonly TEXTURE_INVCUBIC_MODE: number;
  4621. /** Equirectangular coordinates mode */
  4622. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4623. /** Equirectangular Fixed coordinates mode */
  4624. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4625. /** Equirectangular Fixed Mirrored coordinates mode */
  4626. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4627. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4628. static readonly SCALEMODE_FLOOR: number;
  4629. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4630. static readonly SCALEMODE_NEAREST: number;
  4631. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4632. static readonly SCALEMODE_CEILING: number;
  4633. /**
  4634. * The dirty texture flag value
  4635. */
  4636. static readonly MATERIAL_TextureDirtyFlag: number;
  4637. /**
  4638. * The dirty light flag value
  4639. */
  4640. static readonly MATERIAL_LightDirtyFlag: number;
  4641. /**
  4642. * The dirty fresnel flag value
  4643. */
  4644. static readonly MATERIAL_FresnelDirtyFlag: number;
  4645. /**
  4646. * The dirty attribute flag value
  4647. */
  4648. static readonly MATERIAL_AttributesDirtyFlag: number;
  4649. /**
  4650. * The dirty misc flag value
  4651. */
  4652. static readonly MATERIAL_MiscDirtyFlag: number;
  4653. /**
  4654. * The all dirty flag value
  4655. */
  4656. static readonly MATERIAL_AllDirtyFlag: number;
  4657. /**
  4658. * Returns the triangle fill mode
  4659. */
  4660. static readonly MATERIAL_TriangleFillMode: number;
  4661. /**
  4662. * Returns the wireframe mode
  4663. */
  4664. static readonly MATERIAL_WireFrameFillMode: number;
  4665. /**
  4666. * Returns the point fill mode
  4667. */
  4668. static readonly MATERIAL_PointFillMode: number;
  4669. /**
  4670. * Returns the point list draw mode
  4671. */
  4672. static readonly MATERIAL_PointListDrawMode: number;
  4673. /**
  4674. * Returns the line list draw mode
  4675. */
  4676. static readonly MATERIAL_LineListDrawMode: number;
  4677. /**
  4678. * Returns the line loop draw mode
  4679. */
  4680. static readonly MATERIAL_LineLoopDrawMode: number;
  4681. /**
  4682. * Returns the line strip draw mode
  4683. */
  4684. static readonly MATERIAL_LineStripDrawMode: number;
  4685. /**
  4686. * Returns the triangle strip draw mode
  4687. */
  4688. static readonly MATERIAL_TriangleStripDrawMode: number;
  4689. /**
  4690. * Returns the triangle fan draw mode
  4691. */
  4692. static readonly MATERIAL_TriangleFanDrawMode: number;
  4693. /**
  4694. * Stores the clock-wise side orientation
  4695. */
  4696. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4697. /**
  4698. * Stores the counter clock-wise side orientation
  4699. */
  4700. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4701. /**
  4702. * Nothing
  4703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4704. */
  4705. static readonly ACTION_NothingTrigger: number;
  4706. /**
  4707. * On pick
  4708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4709. */
  4710. static readonly ACTION_OnPickTrigger: number;
  4711. /**
  4712. * On left pick
  4713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4714. */
  4715. static readonly ACTION_OnLeftPickTrigger: number;
  4716. /**
  4717. * On right pick
  4718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4719. */
  4720. static readonly ACTION_OnRightPickTrigger: number;
  4721. /**
  4722. * On center pick
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnCenterPickTrigger: number;
  4726. /**
  4727. * On pick down
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnPickDownTrigger: number;
  4731. /**
  4732. * On double pick
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnDoublePickTrigger: number;
  4736. /**
  4737. * On pick up
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPickUpTrigger: number;
  4741. /**
  4742. * On pick out.
  4743. * This trigger will only be raised if you also declared a OnPickDown
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickOutTrigger: number;
  4747. /**
  4748. * On long press
  4749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4750. */
  4751. static readonly ACTION_OnLongPressTrigger: number;
  4752. /**
  4753. * On pointer over
  4754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4755. */
  4756. static readonly ACTION_OnPointerOverTrigger: number;
  4757. /**
  4758. * On pointer out
  4759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4760. */
  4761. static readonly ACTION_OnPointerOutTrigger: number;
  4762. /**
  4763. * On every frame
  4764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4765. */
  4766. static readonly ACTION_OnEveryFrameTrigger: number;
  4767. /**
  4768. * On intersection enter
  4769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4770. */
  4771. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4772. /**
  4773. * On intersection exit
  4774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4775. */
  4776. static readonly ACTION_OnIntersectionExitTrigger: number;
  4777. /**
  4778. * On key down
  4779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4780. */
  4781. static readonly ACTION_OnKeyDownTrigger: number;
  4782. /**
  4783. * On key up
  4784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4785. */
  4786. static readonly ACTION_OnKeyUpTrigger: number;
  4787. /**
  4788. * Billboard mode will only apply to Y axis
  4789. */
  4790. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4791. /**
  4792. * Billboard mode will apply to all axes
  4793. */
  4794. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4795. /**
  4796. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4797. */
  4798. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4799. /**
  4800. * Gets or sets base Assets URL
  4801. */
  4802. static readonly PARTICLES_BaseAssetsUrl: string;
  4803. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4804. * Test order :
  4805. * Is the bounding sphere outside the frustum ?
  4806. * If not, are the bounding box vertices outside the frustum ?
  4807. * It not, then the cullable object is in the frustum.
  4808. */
  4809. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4810. /** Culling strategy : Bounding Sphere Only.
  4811. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4812. * It's also less accurate than the standard because some not visible objects can still be selected.
  4813. * Test : is the bounding sphere outside the frustum ?
  4814. * If not, then the cullable object is in the frustum.
  4815. */
  4816. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4817. /** Culling strategy : Optimistic Inclusion.
  4818. * This in an inclusion test first, then the standard exclusion test.
  4819. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4820. * 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.
  4821. * Anyway, it's as accurate as the standard strategy.
  4822. * Test :
  4823. * Is the cullable object bounding sphere center in the frustum ?
  4824. * If not, apply the default culling strategy.
  4825. */
  4826. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4827. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4828. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4829. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4830. * 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.
  4831. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4832. * Test :
  4833. * Is the cullable object bounding sphere center in the frustum ?
  4834. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4835. */
  4836. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4837. /**
  4838. * No logging while loading
  4839. */
  4840. static readonly SCENELOADER_NO_LOGGING: number;
  4841. /**
  4842. * Minimal logging while loading
  4843. */
  4844. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4845. /**
  4846. * Summary logging while loading
  4847. */
  4848. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4849. /**
  4850. * Detailled logging while loading
  4851. */
  4852. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4853. }
  4854. }
  4855. declare module BABYLON {
  4856. /**
  4857. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4858. * Babylon.js
  4859. */
  4860. export class DomManagement {
  4861. /**
  4862. * Checks if the window object exists
  4863. * @returns true if the window object exists
  4864. */
  4865. static IsWindowObjectExist(): boolean;
  4866. /**
  4867. * Extracts text content from a DOM element hierarchy
  4868. * @param element defines the root element
  4869. * @returns a string
  4870. */
  4871. static GetDOMTextContent(element: HTMLElement): string;
  4872. }
  4873. }
  4874. declare module BABYLON {
  4875. /**
  4876. * Logger used througouht the application to allow configuration of
  4877. * the log level required for the messages.
  4878. */
  4879. export class Logger {
  4880. /**
  4881. * No log
  4882. */
  4883. static readonly NoneLogLevel: number;
  4884. /**
  4885. * Only message logs
  4886. */
  4887. static readonly MessageLogLevel: number;
  4888. /**
  4889. * Only warning logs
  4890. */
  4891. static readonly WarningLogLevel: number;
  4892. /**
  4893. * Only error logs
  4894. */
  4895. static readonly ErrorLogLevel: number;
  4896. /**
  4897. * All logs
  4898. */
  4899. static readonly AllLogLevel: number;
  4900. private static _LogCache;
  4901. /**
  4902. * Gets a value indicating the number of loading errors
  4903. * @ignorenaming
  4904. */
  4905. static errorsCount: number;
  4906. /**
  4907. * Callback called when a new log is added
  4908. */
  4909. static OnNewCacheEntry: (entry: string) => void;
  4910. private static _AddLogEntry;
  4911. private static _FormatMessage;
  4912. private static _LogDisabled;
  4913. private static _LogEnabled;
  4914. private static _WarnDisabled;
  4915. private static _WarnEnabled;
  4916. private static _ErrorDisabled;
  4917. private static _ErrorEnabled;
  4918. /**
  4919. * Log a message to the console
  4920. */
  4921. static Log: (message: string) => void;
  4922. /**
  4923. * Write a warning message to the console
  4924. */
  4925. static Warn: (message: string) => void;
  4926. /**
  4927. * Write an error message to the console
  4928. */
  4929. static Error: (message: string) => void;
  4930. /**
  4931. * Gets current log cache (list of logs)
  4932. */
  4933. static readonly LogCache: string;
  4934. /**
  4935. * Clears the log cache
  4936. */
  4937. static ClearLogCache(): void;
  4938. /**
  4939. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4940. */
  4941. static LogLevels: number;
  4942. }
  4943. }
  4944. declare module BABYLON {
  4945. /** @hidden */
  4946. export class _TypeStore {
  4947. /** @hidden */
  4948. static RegisteredTypes: {
  4949. [key: string]: Object;
  4950. };
  4951. /** @hidden */
  4952. static GetClass(fqdn: string): any;
  4953. }
  4954. }
  4955. declare module BABYLON {
  4956. /**
  4957. * Class containing a set of static utilities functions for deep copy.
  4958. */
  4959. export class DeepCopier {
  4960. /**
  4961. * Tries to copy an object by duplicating every property
  4962. * @param source defines the source object
  4963. * @param destination defines the target object
  4964. * @param doNotCopyList defines a list of properties to avoid
  4965. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4966. */
  4967. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4968. }
  4969. }
  4970. declare module BABYLON {
  4971. /**
  4972. * Class containing a set of static utilities functions for precision date
  4973. */
  4974. export class PrecisionDate {
  4975. /**
  4976. * Gets either window.performance.now() if supported or Date.now() else
  4977. */
  4978. static readonly Now: number;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /** @hidden */
  4983. export class _DevTools {
  4984. static WarnImport(name: string): string;
  4985. }
  4986. }
  4987. declare module BABYLON {
  4988. /**
  4989. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4990. */
  4991. export class WebRequest {
  4992. private _xhr;
  4993. /**
  4994. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4995. * i.e. when loading files, where the server/service expects an Authorization header
  4996. */
  4997. static CustomRequestHeaders: {
  4998. [key: string]: string;
  4999. };
  5000. /**
  5001. * Add callback functions in this array to update all the requests before they get sent to the network
  5002. */
  5003. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5004. private _injectCustomRequestHeaders;
  5005. /**
  5006. * Gets or sets a function to be called when loading progress changes
  5007. */
  5008. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5009. /**
  5010. * Returns client's state
  5011. */
  5012. readonly readyState: number;
  5013. /**
  5014. * Returns client's status
  5015. */
  5016. readonly status: number;
  5017. /**
  5018. * Returns client's status as a text
  5019. */
  5020. readonly statusText: string;
  5021. /**
  5022. * Returns client's response
  5023. */
  5024. readonly response: any;
  5025. /**
  5026. * Returns client's response url
  5027. */
  5028. readonly responseURL: string;
  5029. /**
  5030. * Returns client's response as text
  5031. */
  5032. readonly responseText: string;
  5033. /**
  5034. * Gets or sets the expected response type
  5035. */
  5036. responseType: XMLHttpRequestResponseType;
  5037. /** @hidden */
  5038. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5039. /** @hidden */
  5040. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5041. /**
  5042. * Cancels any network activity
  5043. */
  5044. abort(): void;
  5045. /**
  5046. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5047. * @param body defines an optional request body
  5048. */
  5049. send(body?: Document | BodyInit | null): void;
  5050. /**
  5051. * Sets the request method, request URL
  5052. * @param method defines the method to use (GET, POST, etc..)
  5053. * @param url defines the url to connect with
  5054. */
  5055. open(method: string, url: string): void;
  5056. }
  5057. }
  5058. declare module BABYLON {
  5059. /**
  5060. * Class used to evalaute queries containing `and` and `or` operators
  5061. */
  5062. export class AndOrNotEvaluator {
  5063. /**
  5064. * Evaluate a query
  5065. * @param query defines the query to evaluate
  5066. * @param evaluateCallback defines the callback used to filter result
  5067. * @returns true if the query matches
  5068. */
  5069. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5070. private static _HandleParenthesisContent;
  5071. private static _SimplifyNegation;
  5072. }
  5073. }
  5074. declare module BABYLON {
  5075. /**
  5076. * Class used to store custom tags
  5077. */
  5078. export class Tags {
  5079. /**
  5080. * Adds support for tags on the given object
  5081. * @param obj defines the object to use
  5082. */
  5083. static EnableFor(obj: any): void;
  5084. /**
  5085. * Removes tags support
  5086. * @param obj defines the object to use
  5087. */
  5088. static DisableFor(obj: any): void;
  5089. /**
  5090. * Gets a boolean indicating if the given object has tags
  5091. * @param obj defines the object to use
  5092. * @returns a boolean
  5093. */
  5094. static HasTags(obj: any): boolean;
  5095. /**
  5096. * Gets the tags available on a given object
  5097. * @param obj defines the object to use
  5098. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5099. * @returns the tags
  5100. */
  5101. static GetTags(obj: any, asString?: boolean): any;
  5102. /**
  5103. * Adds tags to an object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5106. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5107. */
  5108. static AddTagsTo(obj: any, tagsString: string): void;
  5109. /**
  5110. * @hidden
  5111. */ private static _AddTagTo(obj: any, tag: string): void;
  5112. /**
  5113. * Removes specific tags from a specific object
  5114. * @param obj defines the object to use
  5115. * @param tagsString defines the tags to remove
  5116. */
  5117. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5118. /**
  5119. * @hidden
  5120. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5121. /**
  5122. * Defines if tags hosted on an object match a given query
  5123. * @param obj defines the object to use
  5124. * @param tagsQuery defines the tag query
  5125. * @returns a boolean
  5126. */
  5127. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5128. }
  5129. }
  5130. declare module BABYLON {
  5131. /**
  5132. * Manages the defines for the Material
  5133. */
  5134. export class MaterialDefines {
  5135. private _keys;
  5136. private _isDirty;
  5137. /** @hidden */ renderId: number;
  5138. /** @hidden */ areLightsDirty: boolean;
  5139. /** @hidden */ areAttributesDirty: boolean;
  5140. /** @hidden */ areTexturesDirty: boolean;
  5141. /** @hidden */ areFresnelDirty: boolean;
  5142. /** @hidden */ areMiscDirty: boolean;
  5143. /** @hidden */ areImageProcessingDirty: boolean;
  5144. /** @hidden */ normals: boolean;
  5145. /** @hidden */ uvs: boolean;
  5146. /** @hidden */ needNormals: boolean;
  5147. /** @hidden */ needUVs: boolean;
  5148. /**
  5149. * Specifies if the material needs to be re-calculated
  5150. */
  5151. readonly isDirty: boolean;
  5152. /**
  5153. * Marks the material to indicate that it has been re-calculated
  5154. */
  5155. markAsProcessed(): void;
  5156. /**
  5157. * Marks the material to indicate that it needs to be re-calculated
  5158. */
  5159. markAsUnprocessed(): void;
  5160. /**
  5161. * Marks the material to indicate all of its defines need to be re-calculated
  5162. */
  5163. markAllAsDirty(): void;
  5164. /**
  5165. * Marks the material to indicate that image processing needs to be re-calculated
  5166. */
  5167. markAsImageProcessingDirty(): void;
  5168. /**
  5169. * Marks the material to indicate the lights need to be re-calculated
  5170. */
  5171. markAsLightDirty(): void;
  5172. /**
  5173. * Marks the attribute state as changed
  5174. */
  5175. markAsAttributesDirty(): void;
  5176. /**
  5177. * Marks the texture state as changed
  5178. */
  5179. markAsTexturesDirty(): void;
  5180. /**
  5181. * Marks the fresnel state as changed
  5182. */
  5183. markAsFresnelDirty(): void;
  5184. /**
  5185. * Marks the misc state as changed
  5186. */
  5187. markAsMiscDirty(): void;
  5188. /**
  5189. * Rebuilds the material defines
  5190. */
  5191. rebuild(): void;
  5192. /**
  5193. * Specifies if two material defines are equal
  5194. * @param other - A material define instance to compare to
  5195. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5196. */
  5197. isEqual(other: MaterialDefines): boolean;
  5198. /**
  5199. * Clones this instance's defines to another instance
  5200. * @param other - material defines to clone values to
  5201. */
  5202. cloneTo(other: MaterialDefines): void;
  5203. /**
  5204. * Resets the material define values
  5205. */
  5206. reset(): void;
  5207. /**
  5208. * Converts the material define values to a string
  5209. * @returns - String of material define information
  5210. */
  5211. toString(): string;
  5212. }
  5213. }
  5214. declare module BABYLON {
  5215. /**
  5216. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5217. */
  5218. export class PerformanceMonitor {
  5219. private _enabled;
  5220. private _rollingFrameTime;
  5221. private _lastFrameTimeMs;
  5222. /**
  5223. * constructor
  5224. * @param frameSampleSize The number of samples required to saturate the sliding window
  5225. */
  5226. constructor(frameSampleSize?: number);
  5227. /**
  5228. * Samples current frame
  5229. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5230. */
  5231. sampleFrame(timeMs?: number): void;
  5232. /**
  5233. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5234. */
  5235. readonly averageFrameTime: number;
  5236. /**
  5237. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5238. */
  5239. readonly averageFrameTimeVariance: number;
  5240. /**
  5241. * Returns the frame time of the most recent frame
  5242. */
  5243. readonly instantaneousFrameTime: number;
  5244. /**
  5245. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5246. */
  5247. readonly averageFPS: number;
  5248. /**
  5249. * Returns the average framerate in frames per second using the most recent frame time
  5250. */
  5251. readonly instantaneousFPS: number;
  5252. /**
  5253. * Returns true if enough samples have been taken to completely fill the sliding window
  5254. */
  5255. readonly isSaturated: boolean;
  5256. /**
  5257. * Enables contributions to the sliding window sample set
  5258. */
  5259. enable(): void;
  5260. /**
  5261. * Disables contributions to the sliding window sample set
  5262. * Samples will not be interpolated over the disabled period
  5263. */
  5264. disable(): void;
  5265. /**
  5266. * Returns true if sampling is enabled
  5267. */
  5268. readonly isEnabled: boolean;
  5269. /**
  5270. * Resets performance monitor
  5271. */
  5272. reset(): void;
  5273. }
  5274. /**
  5275. * RollingAverage
  5276. *
  5277. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5278. */
  5279. export class RollingAverage {
  5280. /**
  5281. * Current average
  5282. */
  5283. average: number;
  5284. /**
  5285. * Current variance
  5286. */
  5287. variance: number;
  5288. protected _samples: Array<number>;
  5289. protected _sampleCount: number;
  5290. protected _pos: number;
  5291. protected _m2: number;
  5292. /**
  5293. * constructor
  5294. * @param length The number of samples required to saturate the sliding window
  5295. */
  5296. constructor(length: number);
  5297. /**
  5298. * Adds a sample to the sample set
  5299. * @param v The sample value
  5300. */
  5301. add(v: number): void;
  5302. /**
  5303. * Returns previously added values or null if outside of history or outside the sliding window domain
  5304. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5305. * @return Value previously recorded with add() or null if outside of range
  5306. */
  5307. history(i: number): number;
  5308. /**
  5309. * Returns true if enough samples have been taken to completely fill the sliding window
  5310. * @return true if sample-set saturated
  5311. */
  5312. isSaturated(): boolean;
  5313. /**
  5314. * Resets the rolling average (equivalent to 0 samples taken so far)
  5315. */
  5316. reset(): void;
  5317. /**
  5318. * Wraps a value around the sample range boundaries
  5319. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5320. * @return Wrapped position in sample range
  5321. */
  5322. protected _wrapPosition(i: number): number;
  5323. }
  5324. }
  5325. declare module BABYLON {
  5326. /**
  5327. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5328. * The underlying implementation relies on an associative array to ensure the best performances.
  5329. * The value can be anything including 'null' but except 'undefined'
  5330. */
  5331. export class StringDictionary<T> {
  5332. /**
  5333. * This will clear this dictionary and copy the content from the 'source' one.
  5334. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5335. * @param source the dictionary to take the content from and copy to this dictionary
  5336. */
  5337. copyFrom(source: StringDictionary<T>): void;
  5338. /**
  5339. * Get a value based from its key
  5340. * @param key the given key to get the matching value from
  5341. * @return the value if found, otherwise undefined is returned
  5342. */
  5343. get(key: string): T | undefined;
  5344. /**
  5345. * Get a value from its key or add it if it doesn't exist.
  5346. * This method will ensure you that a given key/data will be present in the dictionary.
  5347. * @param key the given key to get the matching value from
  5348. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5349. * The factory will only be invoked if there's no data for the given key.
  5350. * @return the value corresponding to the key.
  5351. */
  5352. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5353. /**
  5354. * Get a value from its key if present in the dictionary otherwise add it
  5355. * @param key the key to get the value from
  5356. * @param val if there's no such key/value pair in the dictionary add it with this value
  5357. * @return the value corresponding to the key
  5358. */
  5359. getOrAdd(key: string, val: T): T;
  5360. /**
  5361. * Check if there's a given key in the dictionary
  5362. * @param key the key to check for
  5363. * @return true if the key is present, false otherwise
  5364. */
  5365. contains(key: string): boolean;
  5366. /**
  5367. * Add a new key and its corresponding value
  5368. * @param key the key to add
  5369. * @param value the value corresponding to the key
  5370. * @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
  5371. */
  5372. add(key: string, value: T): boolean;
  5373. /**
  5374. * Update a specific value associated to a key
  5375. * @param key defines the key to use
  5376. * @param value defines the value to store
  5377. * @returns true if the value was updated (or false if the key was not found)
  5378. */
  5379. set(key: string, value: T): boolean;
  5380. /**
  5381. * Get the element of the given key and remove it from the dictionary
  5382. * @param key defines the key to search
  5383. * @returns the value associated with the key or null if not found
  5384. */
  5385. getAndRemove(key: string): Nullable<T>;
  5386. /**
  5387. * Remove a key/value from the dictionary.
  5388. * @param key the key to remove
  5389. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5390. */
  5391. remove(key: string): boolean;
  5392. /**
  5393. * Clear the whole content of the dictionary
  5394. */
  5395. clear(): void;
  5396. /**
  5397. * Gets the current count
  5398. */
  5399. readonly count: number;
  5400. /**
  5401. * Execute a callback on each key/val of the dictionary.
  5402. * Note that you can remove any element in this dictionary in the callback implementation
  5403. * @param callback the callback to execute on a given key/value pair
  5404. */
  5405. forEach(callback: (key: string, val: T) => void): void;
  5406. /**
  5407. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5408. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5409. * Note that you can remove any element in this dictionary in the callback implementation
  5410. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5411. * @returns the first item
  5412. */
  5413. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5414. private _count;
  5415. private _data;
  5416. }
  5417. }
  5418. declare module BABYLON {
  5419. /**
  5420. * Helper class that provides a small promise polyfill
  5421. */
  5422. export class PromisePolyfill {
  5423. /**
  5424. * Static function used to check if the polyfill is required
  5425. * If this is the case then the function will inject the polyfill to window.Promise
  5426. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5427. */
  5428. static Apply(force?: boolean): void;
  5429. }
  5430. }
  5431. declare module BABYLON {
  5432. /**
  5433. * Class used to store data that will be store in GPU memory
  5434. */
  5435. export class Buffer {
  5436. private _engine;
  5437. private _buffer;
  5438. /** @hidden */ data: Nullable<DataArray>;
  5439. private _updatable;
  5440. private _instanced;
  5441. /**
  5442. * Gets the byte stride.
  5443. */
  5444. readonly byteStride: number;
  5445. /**
  5446. * Constructor
  5447. * @param engine the engine
  5448. * @param data the data to use for this buffer
  5449. * @param updatable whether the data is updatable
  5450. * @param stride the stride (optional)
  5451. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5452. * @param instanced whether the buffer is instanced (optional)
  5453. * @param useBytes set to true if the stride in in bytes (optional)
  5454. */
  5455. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5456. /**
  5457. * Create a new VertexBuffer based on the current buffer
  5458. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5459. * @param offset defines offset in the buffer (0 by default)
  5460. * @param size defines the size in floats of attributes (position is 3 for instance)
  5461. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5462. * @param instanced defines if the vertex buffer contains indexed data
  5463. * @param useBytes defines if the offset and stride are in bytes
  5464. * @returns the new vertex buffer
  5465. */
  5466. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5467. /**
  5468. * Gets a boolean indicating if the Buffer is updatable?
  5469. * @returns true if the buffer is updatable
  5470. */
  5471. isUpdatable(): boolean;
  5472. /**
  5473. * Gets current buffer's data
  5474. * @returns a DataArray or null
  5475. */
  5476. getData(): Nullable<DataArray>;
  5477. /**
  5478. * Gets underlying native buffer
  5479. * @returns underlying native buffer
  5480. */
  5481. getBuffer(): Nullable<WebGLBuffer>;
  5482. /**
  5483. * Gets the stride in float32 units (i.e. byte stride / 4).
  5484. * May not be an integer if the byte stride is not divisible by 4.
  5485. * DEPRECATED. Use byteStride instead.
  5486. * @returns the stride in float32 units
  5487. */
  5488. getStrideSize(): number;
  5489. /**
  5490. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5491. * @param data defines the data to store
  5492. */
  5493. create(data?: Nullable<DataArray>): void;
  5494. /** @hidden */ rebuild(): void;
  5495. /**
  5496. * Update current buffer data
  5497. * @param data defines the data to store
  5498. */
  5499. update(data: DataArray): void;
  5500. /**
  5501. * Updates the data directly.
  5502. * @param data the new data
  5503. * @param offset the new offset
  5504. * @param vertexCount the vertex count (optional)
  5505. * @param useBytes set to true if the offset is in bytes
  5506. */
  5507. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5508. /**
  5509. * Release all resources
  5510. */
  5511. dispose(): void;
  5512. }
  5513. /**
  5514. * Specialized buffer used to store vertex data
  5515. */
  5516. export class VertexBuffer {
  5517. /** @hidden */ buffer: Buffer;
  5518. private _kind;
  5519. private _size;
  5520. private _ownsBuffer;
  5521. private _instanced;
  5522. private _instanceDivisor;
  5523. /**
  5524. * The byte type.
  5525. */
  5526. static readonly BYTE: number;
  5527. /**
  5528. * The unsigned byte type.
  5529. */
  5530. static readonly UNSIGNED_BYTE: number;
  5531. /**
  5532. * The short type.
  5533. */
  5534. static readonly SHORT: number;
  5535. /**
  5536. * The unsigned short type.
  5537. */
  5538. static readonly UNSIGNED_SHORT: number;
  5539. /**
  5540. * The integer type.
  5541. */
  5542. static readonly INT: number;
  5543. /**
  5544. * The unsigned integer type.
  5545. */
  5546. static readonly UNSIGNED_INT: number;
  5547. /**
  5548. * The float type.
  5549. */
  5550. static readonly FLOAT: number;
  5551. /**
  5552. * Gets or sets the instance divisor when in instanced mode
  5553. */
  5554. instanceDivisor: number;
  5555. /**
  5556. * Gets the byte stride.
  5557. */
  5558. readonly byteStride: number;
  5559. /**
  5560. * Gets the byte offset.
  5561. */
  5562. readonly byteOffset: number;
  5563. /**
  5564. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5565. */
  5566. readonly normalized: boolean;
  5567. /**
  5568. * Gets the data type of each component in the array.
  5569. */
  5570. readonly type: number;
  5571. /**
  5572. * Constructor
  5573. * @param engine the engine
  5574. * @param data the data to use for this vertex buffer
  5575. * @param kind the vertex buffer kind
  5576. * @param updatable whether the data is updatable
  5577. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5578. * @param stride the stride (optional)
  5579. * @param instanced whether the buffer is instanced (optional)
  5580. * @param offset the offset of the data (optional)
  5581. * @param size the number of components (optional)
  5582. * @param type the type of the component (optional)
  5583. * @param normalized whether the data contains normalized data (optional)
  5584. * @param useBytes set to true if stride and offset are in bytes (optional)
  5585. */
  5586. 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);
  5587. /** @hidden */ rebuild(): void;
  5588. /**
  5589. * Returns the kind of the VertexBuffer (string)
  5590. * @returns a string
  5591. */
  5592. getKind(): string;
  5593. /**
  5594. * Gets a boolean indicating if the VertexBuffer is updatable?
  5595. * @returns true if the buffer is updatable
  5596. */
  5597. isUpdatable(): boolean;
  5598. /**
  5599. * Gets current buffer's data
  5600. * @returns a DataArray or null
  5601. */
  5602. getData(): Nullable<DataArray>;
  5603. /**
  5604. * Gets underlying native buffer
  5605. * @returns underlying native buffer
  5606. */
  5607. getBuffer(): Nullable<WebGLBuffer>;
  5608. /**
  5609. * Gets the stride in float32 units (i.e. byte stride / 4).
  5610. * May not be an integer if the byte stride is not divisible by 4.
  5611. * DEPRECATED. Use byteStride instead.
  5612. * @returns the stride in float32 units
  5613. */
  5614. getStrideSize(): number;
  5615. /**
  5616. * Returns the offset as a multiple of the type byte length.
  5617. * DEPRECATED. Use byteOffset instead.
  5618. * @returns the offset in bytes
  5619. */
  5620. getOffset(): number;
  5621. /**
  5622. * Returns the number of components per vertex attribute (integer)
  5623. * @returns the size in float
  5624. */
  5625. getSize(): number;
  5626. /**
  5627. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5628. * @returns true if this buffer is instanced
  5629. */
  5630. getIsInstanced(): boolean;
  5631. /**
  5632. * Returns the instancing divisor, zero for non-instanced (integer).
  5633. * @returns a number
  5634. */
  5635. getInstanceDivisor(): number;
  5636. /**
  5637. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5638. * @param data defines the data to store
  5639. */
  5640. create(data?: DataArray): void;
  5641. /**
  5642. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5643. * This function will create a new buffer if the current one is not updatable
  5644. * @param data defines the data to store
  5645. */
  5646. update(data: DataArray): void;
  5647. /**
  5648. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5649. * Returns the directly updated WebGLBuffer.
  5650. * @param data the new data
  5651. * @param offset the new offset
  5652. * @param useBytes set to true if the offset is in bytes
  5653. */
  5654. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5655. /**
  5656. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5657. */
  5658. dispose(): void;
  5659. /**
  5660. * Enumerates each value of this vertex buffer as numbers.
  5661. * @param count the number of values to enumerate
  5662. * @param callback the callback function called for each value
  5663. */
  5664. forEach(count: number, callback: (value: number, index: number) => void): void;
  5665. /**
  5666. * Positions
  5667. */
  5668. static readonly PositionKind: string;
  5669. /**
  5670. * Normals
  5671. */
  5672. static readonly NormalKind: string;
  5673. /**
  5674. * Tangents
  5675. */
  5676. static readonly TangentKind: string;
  5677. /**
  5678. * Texture coordinates
  5679. */
  5680. static readonly UVKind: string;
  5681. /**
  5682. * Texture coordinates 2
  5683. */
  5684. static readonly UV2Kind: string;
  5685. /**
  5686. * Texture coordinates 3
  5687. */
  5688. static readonly UV3Kind: string;
  5689. /**
  5690. * Texture coordinates 4
  5691. */
  5692. static readonly UV4Kind: string;
  5693. /**
  5694. * Texture coordinates 5
  5695. */
  5696. static readonly UV5Kind: string;
  5697. /**
  5698. * Texture coordinates 6
  5699. */
  5700. static readonly UV6Kind: string;
  5701. /**
  5702. * Colors
  5703. */
  5704. static readonly ColorKind: string;
  5705. /**
  5706. * Matrix indices (for bones)
  5707. */
  5708. static readonly MatricesIndicesKind: string;
  5709. /**
  5710. * Matrix weights (for bones)
  5711. */
  5712. static readonly MatricesWeightsKind: string;
  5713. /**
  5714. * Additional matrix indices (for bones)
  5715. */
  5716. static readonly MatricesIndicesExtraKind: string;
  5717. /**
  5718. * Additional matrix weights (for bones)
  5719. */
  5720. static readonly MatricesWeightsExtraKind: string;
  5721. /**
  5722. * Deduces the stride given a kind.
  5723. * @param kind The kind string to deduce
  5724. * @returns The deduced stride
  5725. */
  5726. static DeduceStride(kind: string): number;
  5727. /**
  5728. * Gets the byte length of the given type.
  5729. * @param type the type
  5730. * @returns the number of bytes
  5731. */
  5732. static GetTypeByteLength(type: number): number;
  5733. /**
  5734. * Enumerates each value of the given parameters as numbers.
  5735. * @param data the data to enumerate
  5736. * @param byteOffset the byte offset of the data
  5737. * @param byteStride the byte stride of the data
  5738. * @param componentCount the number of components per element
  5739. * @param componentType the type of the component
  5740. * @param count the total number of components
  5741. * @param normalized whether the data is normalized
  5742. * @param callback the callback function called for each value
  5743. */
  5744. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5745. private static _GetFloatValue;
  5746. }
  5747. }
  5748. declare module BABYLON {
  5749. /**
  5750. * Class representing spherical polynomial coefficients to the 3rd degree
  5751. */
  5752. export class SphericalPolynomial {
  5753. /**
  5754. * The x coefficients of the spherical polynomial
  5755. */
  5756. x: Vector3;
  5757. /**
  5758. * The y coefficients of the spherical polynomial
  5759. */
  5760. y: Vector3;
  5761. /**
  5762. * The z coefficients of the spherical polynomial
  5763. */
  5764. z: Vector3;
  5765. /**
  5766. * The xx coefficients of the spherical polynomial
  5767. */
  5768. xx: Vector3;
  5769. /**
  5770. * The yy coefficients of the spherical polynomial
  5771. */
  5772. yy: Vector3;
  5773. /**
  5774. * The zz coefficients of the spherical polynomial
  5775. */
  5776. zz: Vector3;
  5777. /**
  5778. * The xy coefficients of the spherical polynomial
  5779. */
  5780. xy: Vector3;
  5781. /**
  5782. * The yz coefficients of the spherical polynomial
  5783. */
  5784. yz: Vector3;
  5785. /**
  5786. * The zx coefficients of the spherical polynomial
  5787. */
  5788. zx: Vector3;
  5789. /**
  5790. * Adds an ambient color to the spherical polynomial
  5791. * @param color the color to add
  5792. */
  5793. addAmbient(color: Color3): void;
  5794. /**
  5795. * Scales the spherical polynomial by the given amount
  5796. * @param scale the amount to scale
  5797. */
  5798. scale(scale: number): void;
  5799. /**
  5800. * Gets the spherical polynomial from harmonics
  5801. * @param harmonics the spherical harmonics
  5802. * @returns the spherical polynomial
  5803. */
  5804. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5805. /**
  5806. * Constructs a spherical polynomial from an array.
  5807. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5808. * @returns the spherical polynomial
  5809. */
  5810. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5811. }
  5812. /**
  5813. * Class representing spherical harmonics coefficients to the 3rd degree
  5814. */
  5815. export class SphericalHarmonics {
  5816. /**
  5817. * The l0,0 coefficients of the spherical harmonics
  5818. */
  5819. l00: Vector3;
  5820. /**
  5821. * The l1,-1 coefficients of the spherical harmonics
  5822. */
  5823. l1_1: Vector3;
  5824. /**
  5825. * The l1,0 coefficients of the spherical harmonics
  5826. */
  5827. l10: Vector3;
  5828. /**
  5829. * The l1,1 coefficients of the spherical harmonics
  5830. */
  5831. l11: Vector3;
  5832. /**
  5833. * The l2,-2 coefficients of the spherical harmonics
  5834. */
  5835. l2_2: Vector3;
  5836. /**
  5837. * The l2,-1 coefficients of the spherical harmonics
  5838. */
  5839. l2_1: Vector3;
  5840. /**
  5841. * The l2,0 coefficients of the spherical harmonics
  5842. */
  5843. l20: Vector3;
  5844. /**
  5845. * The l2,1 coefficients of the spherical harmonics
  5846. */
  5847. l21: Vector3;
  5848. /**
  5849. * The l2,2 coefficients of the spherical harmonics
  5850. */
  5851. lL22: Vector3;
  5852. /**
  5853. * Adds a light to the spherical harmonics
  5854. * @param direction the direction of the light
  5855. * @param color the color of the light
  5856. * @param deltaSolidAngle the delta solid angle of the light
  5857. */
  5858. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5859. /**
  5860. * Scales the spherical harmonics by the given amount
  5861. * @param scale the amount to scale
  5862. */
  5863. scale(scale: number): void;
  5864. /**
  5865. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5866. *
  5867. * ```
  5868. * E_lm = A_l * L_lm
  5869. * ```
  5870. *
  5871. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5872. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5873. * the scaling factors are given in equation 9.
  5874. */
  5875. convertIncidentRadianceToIrradiance(): void;
  5876. /**
  5877. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5878. *
  5879. * ```
  5880. * L = (1/pi) * E * rho
  5881. * ```
  5882. *
  5883. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5884. */
  5885. convertIrradianceToLambertianRadiance(): void;
  5886. /**
  5887. * Gets the spherical harmonics from polynomial
  5888. * @param polynomial the spherical polynomial
  5889. * @returns the spherical harmonics
  5890. */
  5891. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5892. /**
  5893. * Constructs a spherical harmonics from an array.
  5894. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5895. * @returns the spherical harmonics
  5896. */
  5897. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5898. }
  5899. }
  5900. declare module BABYLON {
  5901. /**
  5902. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5903. */
  5904. export interface CubeMapInfo {
  5905. /**
  5906. * The pixel array for the front face.
  5907. * This is stored in format, left to right, up to down format.
  5908. */
  5909. front: Nullable<ArrayBufferView>;
  5910. /**
  5911. * The pixel array for the back face.
  5912. * This is stored in format, left to right, up to down format.
  5913. */
  5914. back: Nullable<ArrayBufferView>;
  5915. /**
  5916. * The pixel array for the left face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. left: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the right face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. right: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the up face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. up: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the down face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. down: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The size of the cubemap stored.
  5937. *
  5938. * Each faces will be size * size pixels.
  5939. */
  5940. size: number;
  5941. /**
  5942. * The format of the texture.
  5943. *
  5944. * RGBA, RGB.
  5945. */
  5946. format: number;
  5947. /**
  5948. * The type of the texture data.
  5949. *
  5950. * UNSIGNED_INT, FLOAT.
  5951. */
  5952. type: number;
  5953. /**
  5954. * Specifies whether the texture is in gamma space.
  5955. */
  5956. gammaSpace: boolean;
  5957. }
  5958. /**
  5959. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5960. */
  5961. export class PanoramaToCubeMapTools {
  5962. private static FACE_FRONT;
  5963. private static FACE_BACK;
  5964. private static FACE_RIGHT;
  5965. private static FACE_LEFT;
  5966. private static FACE_DOWN;
  5967. private static FACE_UP;
  5968. /**
  5969. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5970. *
  5971. * @param float32Array The source data.
  5972. * @param inputWidth The width of the input panorama.
  5973. * @param inputHeight The height of the input panorama.
  5974. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5975. * @return The cubemap data
  5976. */
  5977. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5978. private static CreateCubemapTexture;
  5979. private static CalcProjectionSpherical;
  5980. }
  5981. }
  5982. declare module BABYLON {
  5983. /**
  5984. * Helper class dealing with the extraction of spherical polynomial dataArray
  5985. * from a cube map.
  5986. */
  5987. export class CubeMapToSphericalPolynomialTools {
  5988. private static FileFaces;
  5989. /**
  5990. * Converts a texture to the according Spherical Polynomial data.
  5991. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5992. *
  5993. * @param texture The texture to extract the information from.
  5994. * @return The Spherical Polynomial data.
  5995. */
  5996. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5997. /**
  5998. * Converts a cubemap to the according Spherical Polynomial data.
  5999. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6000. *
  6001. * @param cubeInfo The Cube map to extract the information from.
  6002. * @return The Spherical Polynomial data.
  6003. */
  6004. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6005. }
  6006. }
  6007. declare module BABYLON {
  6008. /**
  6009. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6010. * during the life time of the application.
  6011. */
  6012. export class EngineStore {
  6013. /** Gets the list of created engines */
  6014. static Instances: Engine[];
  6015. /**
  6016. * Gets the latest created engine
  6017. */
  6018. static readonly LastCreatedEngine: Nullable<Engine>;
  6019. /**
  6020. * Gets the latest created scene
  6021. */
  6022. static readonly LastCreatedScene: Nullable<Scene>;
  6023. }
  6024. }
  6025. declare module BABYLON {
  6026. /**
  6027. * Define options used to create a render target texture
  6028. */
  6029. export class RenderTargetCreationOptions {
  6030. /**
  6031. * Specifies is mipmaps must be generated
  6032. */
  6033. generateMipMaps?: boolean;
  6034. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6035. generateDepthBuffer?: boolean;
  6036. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6037. generateStencilBuffer?: boolean;
  6038. /** Defines texture type (int by default) */
  6039. type?: number;
  6040. /** Defines sampling mode (trilinear by default) */
  6041. samplingMode?: number;
  6042. /** Defines format (RGBA by default) */
  6043. format?: number;
  6044. }
  6045. }
  6046. declare module BABYLON {
  6047. /**
  6048. * @hidden
  6049. **/
  6050. export class _AlphaState {
  6051. private _isAlphaBlendDirty;
  6052. private _isBlendFunctionParametersDirty;
  6053. private _isBlendEquationParametersDirty;
  6054. private _isBlendConstantsDirty;
  6055. private _alphaBlend;
  6056. private _blendFunctionParameters;
  6057. private _blendEquationParameters;
  6058. private _blendConstants;
  6059. /**
  6060. * Initializes the state.
  6061. */
  6062. constructor();
  6063. readonly isDirty: boolean;
  6064. alphaBlend: boolean;
  6065. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6066. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6067. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6068. reset(): void;
  6069. apply(gl: WebGLRenderingContext): void;
  6070. }
  6071. }
  6072. declare module BABYLON {
  6073. /**
  6074. * @hidden
  6075. **/
  6076. export class _DepthCullingState {
  6077. private _isDepthTestDirty;
  6078. private _isDepthMaskDirty;
  6079. private _isDepthFuncDirty;
  6080. private _isCullFaceDirty;
  6081. private _isCullDirty;
  6082. private _isZOffsetDirty;
  6083. private _isFrontFaceDirty;
  6084. private _depthTest;
  6085. private _depthMask;
  6086. private _depthFunc;
  6087. private _cull;
  6088. private _cullFace;
  6089. private _zOffset;
  6090. private _frontFace;
  6091. /**
  6092. * Initializes the state.
  6093. */
  6094. constructor();
  6095. readonly isDirty: boolean;
  6096. zOffset: number;
  6097. cullFace: Nullable<number>;
  6098. cull: Nullable<boolean>;
  6099. depthFunc: Nullable<number>;
  6100. depthMask: boolean;
  6101. depthTest: boolean;
  6102. frontFace: Nullable<number>;
  6103. reset(): void;
  6104. apply(gl: WebGLRenderingContext): void;
  6105. }
  6106. }
  6107. declare module BABYLON {
  6108. /**
  6109. * @hidden
  6110. **/
  6111. export class _StencilState {
  6112. /** 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 */
  6113. static readonly ALWAYS: number;
  6114. /** Passed to stencilOperation to specify that stencil value must be kept */
  6115. static readonly KEEP: number;
  6116. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6117. static readonly REPLACE: number;
  6118. private _isStencilTestDirty;
  6119. private _isStencilMaskDirty;
  6120. private _isStencilFuncDirty;
  6121. private _isStencilOpDirty;
  6122. private _stencilTest;
  6123. private _stencilMask;
  6124. private _stencilFunc;
  6125. private _stencilFuncRef;
  6126. private _stencilFuncMask;
  6127. private _stencilOpStencilFail;
  6128. private _stencilOpDepthFail;
  6129. private _stencilOpStencilDepthPass;
  6130. readonly isDirty: boolean;
  6131. stencilFunc: number;
  6132. stencilFuncRef: number;
  6133. stencilFuncMask: number;
  6134. stencilOpStencilFail: number;
  6135. stencilOpDepthFail: number;
  6136. stencilOpStencilDepthPass: number;
  6137. stencilMask: number;
  6138. stencilTest: boolean;
  6139. constructor();
  6140. reset(): void;
  6141. apply(gl: WebGLRenderingContext): void;
  6142. }
  6143. }
  6144. declare module BABYLON {
  6145. /**
  6146. * @hidden
  6147. **/
  6148. export class _TimeToken { startTimeQuery: Nullable<WebGLQuery>; endTimeQuery: Nullable<WebGLQuery>; timeElapsedQuery: Nullable<WebGLQuery>; timeElapsedQueryEnded: boolean;
  6149. }
  6150. }
  6151. declare module BABYLON {
  6152. /**
  6153. * Class used to store data associated with WebGL texture data for the engine
  6154. * This class should not be used directly
  6155. */
  6156. export class InternalTexture {
  6157. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6158. /**
  6159. * The source of the texture data is unknown
  6160. */
  6161. static DATASOURCE_UNKNOWN: number;
  6162. /**
  6163. * Texture data comes from an URL
  6164. */
  6165. static DATASOURCE_URL: number;
  6166. /**
  6167. * Texture data is only used for temporary storage
  6168. */
  6169. static DATASOURCE_TEMP: number;
  6170. /**
  6171. * Texture data comes from raw data (ArrayBuffer)
  6172. */
  6173. static DATASOURCE_RAW: number;
  6174. /**
  6175. * Texture content is dynamic (video or dynamic texture)
  6176. */
  6177. static DATASOURCE_DYNAMIC: number;
  6178. /**
  6179. * Texture content is generated by rendering to it
  6180. */
  6181. static DATASOURCE_RENDERTARGET: number;
  6182. /**
  6183. * Texture content is part of a multi render target process
  6184. */
  6185. static DATASOURCE_MULTIRENDERTARGET: number;
  6186. /**
  6187. * Texture data comes from a cube data file
  6188. */
  6189. static DATASOURCE_CUBE: number;
  6190. /**
  6191. * Texture data comes from a raw cube data
  6192. */
  6193. static DATASOURCE_CUBERAW: number;
  6194. /**
  6195. * Texture data come from a prefiltered cube data file
  6196. */
  6197. static DATASOURCE_CUBEPREFILTERED: number;
  6198. /**
  6199. * Texture content is raw 3D data
  6200. */
  6201. static DATASOURCE_RAW3D: number;
  6202. /**
  6203. * Texture content is a depth texture
  6204. */
  6205. static DATASOURCE_DEPTHTEXTURE: number;
  6206. /**
  6207. * Texture data comes from a raw cube data encoded with RGBD
  6208. */
  6209. static DATASOURCE_CUBERAW_RGBD: number;
  6210. /**
  6211. * Defines if the texture is ready
  6212. */
  6213. isReady: boolean;
  6214. /**
  6215. * Defines if the texture is a cube texture
  6216. */
  6217. isCube: boolean;
  6218. /**
  6219. * Defines if the texture contains 3D data
  6220. */
  6221. is3D: boolean;
  6222. /**
  6223. * Defines if the texture contains multiview data
  6224. */
  6225. isMultiview: boolean;
  6226. /**
  6227. * Gets the URL used to load this texture
  6228. */
  6229. url: string;
  6230. /**
  6231. * Gets the sampling mode of the texture
  6232. */
  6233. samplingMode: number;
  6234. /**
  6235. * Gets a boolean indicating if the texture needs mipmaps generation
  6236. */
  6237. generateMipMaps: boolean;
  6238. /**
  6239. * Gets the number of samples used by the texture (WebGL2+ only)
  6240. */
  6241. samples: number;
  6242. /**
  6243. * Gets the type of the texture (int, float...)
  6244. */
  6245. type: number;
  6246. /**
  6247. * Gets the format of the texture (RGB, RGBA...)
  6248. */
  6249. format: number;
  6250. /**
  6251. * Observable called when the texture is loaded
  6252. */
  6253. onLoadedObservable: Observable<InternalTexture>;
  6254. /**
  6255. * Gets the width of the texture
  6256. */
  6257. width: number;
  6258. /**
  6259. * Gets the height of the texture
  6260. */
  6261. height: number;
  6262. /**
  6263. * Gets the depth of the texture
  6264. */
  6265. depth: number;
  6266. /**
  6267. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6268. */
  6269. baseWidth: number;
  6270. /**
  6271. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6272. */
  6273. baseHeight: number;
  6274. /**
  6275. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6276. */
  6277. baseDepth: number;
  6278. /**
  6279. * Gets a boolean indicating if the texture is inverted on Y axis
  6280. */
  6281. invertY: boolean;
  6282. /** @hidden */ invertVScale: boolean;
  6283. /** @hidden */ associatedChannel: number;
  6284. /** @hidden */ dataSource: number;
  6285. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6286. /** @hidden */ bufferView: Nullable<ArrayBufferView>;
  6287. /** @hidden */ bufferViewArray: Nullable<ArrayBufferView[]>;
  6288. /** @hidden */ bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6289. /** @hidden */ size: number;
  6290. /** @hidden */ extension: string;
  6291. /** @hidden */ files: Nullable<string[]>;
  6292. /** @hidden */ workingCanvas: Nullable<HTMLCanvasElement>;
  6293. /** @hidden */ workingContext: Nullable<CanvasRenderingContext2D>;
  6294. /** @hidden */ framebuffer: Nullable<WebGLFramebuffer>;
  6295. /** @hidden */ depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6296. /** @hidden */ MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6297. /** @hidden */ MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6298. /** @hidden */ attachments: Nullable<number[]>;
  6299. /** @hidden */ cachedCoordinatesMode: Nullable<number>;
  6300. /** @hidden */ cachedWrapU: Nullable<number>;
  6301. /** @hidden */ cachedWrapV: Nullable<number>;
  6302. /** @hidden */ cachedWrapR: Nullable<number>;
  6303. /** @hidden */ cachedAnisotropicFilteringLevel: Nullable<number>;
  6304. /** @hidden */ isDisabled: boolean;
  6305. /** @hidden */ compression: Nullable<string>;
  6306. /** @hidden */ generateStencilBuffer: boolean;
  6307. /** @hidden */ generateDepthBuffer: boolean;
  6308. /** @hidden */ comparisonFunction: number;
  6309. /** @hidden */ sphericalPolynomial: Nullable<SphericalPolynomial>;
  6310. /** @hidden */ lodGenerationScale: number;
  6311. /** @hidden */ lodGenerationOffset: number;
  6312. /** @hidden */ colorTextureArray: Nullable<WebGLTexture>;
  6313. /** @hidden */ depthStencilTextureArray: Nullable<WebGLTexture>;
  6314. /** @hidden */ lodTextureHigh: Nullable<BaseTexture>;
  6315. /** @hidden */ lodTextureMid: Nullable<BaseTexture>;
  6316. /** @hidden */ lodTextureLow: Nullable<BaseTexture>;
  6317. /** @hidden */ isRGBD: boolean;
  6318. /** @hidden */ webGLTexture: Nullable<WebGLTexture>;
  6319. /** @hidden */ references: number;
  6320. private _engine;
  6321. /**
  6322. * Gets the Engine the texture belongs to.
  6323. * @returns The babylon engine
  6324. */
  6325. getEngine(): Engine;
  6326. /**
  6327. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6328. */
  6329. readonly dataSource: number;
  6330. /**
  6331. * Creates a new InternalTexture
  6332. * @param engine defines the engine to use
  6333. * @param dataSource defines the type of data that will be used
  6334. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6335. */
  6336. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6337. /**
  6338. * Increments the number of references (ie. the number of Texture that point to it)
  6339. */
  6340. incrementReferences(): void;
  6341. /**
  6342. * Change the size of the texture (not the size of the content)
  6343. * @param width defines the new width
  6344. * @param height defines the new height
  6345. * @param depth defines the new depth (1 by default)
  6346. */
  6347. updateSize(width: int, height: int, depth?: int): void;
  6348. /** @hidden */ rebuild(): void;
  6349. /** @hidden */ swapAndDie(target: InternalTexture): void;
  6350. /**
  6351. * Dispose the current allocated resources
  6352. */
  6353. dispose(): void;
  6354. }
  6355. }
  6356. declare module BABYLON {
  6357. /**
  6358. * This represents the main contract an easing function should follow.
  6359. * Easing functions are used throughout the animation system.
  6360. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6361. */
  6362. export interface IEasingFunction {
  6363. /**
  6364. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6365. * of the easing function.
  6366. * The link below provides some of the most common examples of easing functions.
  6367. * @see https://easings.net/
  6368. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6369. * @returns the corresponding value on the curve defined by the easing function
  6370. */
  6371. ease(gradient: number): number;
  6372. }
  6373. /**
  6374. * Base class used for every default easing function.
  6375. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6376. */
  6377. export class EasingFunction implements IEasingFunction {
  6378. /**
  6379. * Interpolation follows the mathematical formula associated with the easing function.
  6380. */
  6381. static readonly EASINGMODE_EASEIN: number;
  6382. /**
  6383. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6384. */
  6385. static readonly EASINGMODE_EASEOUT: number;
  6386. /**
  6387. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6388. */
  6389. static readonly EASINGMODE_EASEINOUT: number;
  6390. private _easingMode;
  6391. /**
  6392. * Sets the easing mode of the current function.
  6393. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6394. */
  6395. setEasingMode(easingMode: number): void;
  6396. /**
  6397. * Gets the current easing mode.
  6398. * @returns the easing mode
  6399. */
  6400. getEasingMode(): number;
  6401. /**
  6402. * @hidden
  6403. */
  6404. easeInCore(gradient: number): number;
  6405. /**
  6406. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6407. * of the easing function.
  6408. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6409. * @returns the corresponding value on the curve defined by the easing function
  6410. */
  6411. ease(gradient: number): number;
  6412. }
  6413. /**
  6414. * Easing function with a circle shape (see link below).
  6415. * @see https://easings.net/#easeInCirc
  6416. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6417. */
  6418. export class CircleEase extends EasingFunction implements IEasingFunction {
  6419. /** @hidden */
  6420. easeInCore(gradient: number): number;
  6421. }
  6422. /**
  6423. * Easing function with a ease back shape (see link below).
  6424. * @see https://easings.net/#easeInBack
  6425. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6426. */
  6427. export class BackEase extends EasingFunction implements IEasingFunction {
  6428. /** Defines the amplitude of the function */
  6429. amplitude: number;
  6430. /**
  6431. * Instantiates a back ease easing
  6432. * @see https://easings.net/#easeInBack
  6433. * @param amplitude Defines the amplitude of the function
  6434. */
  6435. constructor(
  6436. /** Defines the amplitude of the function */
  6437. amplitude?: number);
  6438. /** @hidden */
  6439. easeInCore(gradient: number): number;
  6440. }
  6441. /**
  6442. * Easing function with a bouncing shape (see link below).
  6443. * @see https://easings.net/#easeInBounce
  6444. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6445. */
  6446. export class BounceEase extends EasingFunction implements IEasingFunction {
  6447. /** Defines the number of bounces */
  6448. bounces: number;
  6449. /** Defines the amplitude of the bounce */
  6450. bounciness: number;
  6451. /**
  6452. * Instantiates a bounce easing
  6453. * @see https://easings.net/#easeInBounce
  6454. * @param bounces Defines the number of bounces
  6455. * @param bounciness Defines the amplitude of the bounce
  6456. */
  6457. constructor(
  6458. /** Defines the number of bounces */
  6459. bounces?: number,
  6460. /** Defines the amplitude of the bounce */
  6461. bounciness?: number);
  6462. /** @hidden */
  6463. easeInCore(gradient: number): number;
  6464. }
  6465. /**
  6466. * Easing function with a power of 3 shape (see link below).
  6467. * @see https://easings.net/#easeInCubic
  6468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6469. */
  6470. export class CubicEase extends EasingFunction implements IEasingFunction {
  6471. /** @hidden */
  6472. easeInCore(gradient: number): number;
  6473. }
  6474. /**
  6475. * Easing function with an elastic shape (see link below).
  6476. * @see https://easings.net/#easeInElastic
  6477. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6478. */
  6479. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6480. /** Defines the number of oscillations*/
  6481. oscillations: number;
  6482. /** Defines the amplitude of the oscillations*/
  6483. springiness: number;
  6484. /**
  6485. * Instantiates an elastic easing function
  6486. * @see https://easings.net/#easeInElastic
  6487. * @param oscillations Defines the number of oscillations
  6488. * @param springiness Defines the amplitude of the oscillations
  6489. */
  6490. constructor(
  6491. /** Defines the number of oscillations*/
  6492. oscillations?: number,
  6493. /** Defines the amplitude of the oscillations*/
  6494. springiness?: number);
  6495. /** @hidden */
  6496. easeInCore(gradient: number): number;
  6497. }
  6498. /**
  6499. * Easing function with an exponential shape (see link below).
  6500. * @see https://easings.net/#easeInExpo
  6501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6502. */
  6503. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6504. /** Defines the exponent of the function */
  6505. exponent: number;
  6506. /**
  6507. * Instantiates an exponential easing function
  6508. * @see https://easings.net/#easeInExpo
  6509. * @param exponent Defines the exponent of the function
  6510. */
  6511. constructor(
  6512. /** Defines the exponent of the function */
  6513. exponent?: number);
  6514. /** @hidden */
  6515. easeInCore(gradient: number): number;
  6516. }
  6517. /**
  6518. * Easing function with a power shape (see link below).
  6519. * @see https://easings.net/#easeInQuad
  6520. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6521. */
  6522. export class PowerEase extends EasingFunction implements IEasingFunction {
  6523. /** Defines the power of the function */
  6524. power: number;
  6525. /**
  6526. * Instantiates an power base easing function
  6527. * @see https://easings.net/#easeInQuad
  6528. * @param power Defines the power of the function
  6529. */
  6530. constructor(
  6531. /** Defines the power of the function */
  6532. power?: number);
  6533. /** @hidden */
  6534. easeInCore(gradient: number): number;
  6535. }
  6536. /**
  6537. * Easing function with a power of 2 shape (see link below).
  6538. * @see https://easings.net/#easeInQuad
  6539. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6540. */
  6541. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6542. /** @hidden */
  6543. easeInCore(gradient: number): number;
  6544. }
  6545. /**
  6546. * Easing function with a power of 4 shape (see link below).
  6547. * @see https://easings.net/#easeInQuart
  6548. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6549. */
  6550. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6551. /** @hidden */
  6552. easeInCore(gradient: number): number;
  6553. }
  6554. /**
  6555. * Easing function with a power of 5 shape (see link below).
  6556. * @see https://easings.net/#easeInQuint
  6557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6558. */
  6559. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6560. /** @hidden */
  6561. easeInCore(gradient: number): number;
  6562. }
  6563. /**
  6564. * Easing function with a sin shape (see link below).
  6565. * @see https://easings.net/#easeInSine
  6566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6567. */
  6568. export class SineEase extends EasingFunction implements IEasingFunction {
  6569. /** @hidden */
  6570. easeInCore(gradient: number): number;
  6571. }
  6572. /**
  6573. * Easing function with a bezier shape (see link below).
  6574. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6575. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6576. */
  6577. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6578. /** Defines the x component of the start tangent in the bezier curve */
  6579. x1: number;
  6580. /** Defines the y component of the start tangent in the bezier curve */
  6581. y1: number;
  6582. /** Defines the x component of the end tangent in the bezier curve */
  6583. x2: number;
  6584. /** Defines the y component of the end tangent in the bezier curve */
  6585. y2: number;
  6586. /**
  6587. * Instantiates a bezier function
  6588. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6589. * @param x1 Defines the x component of the start tangent in the bezier curve
  6590. * @param y1 Defines the y component of the start tangent in the bezier curve
  6591. * @param x2 Defines the x component of the end tangent in the bezier curve
  6592. * @param y2 Defines the y component of the end tangent in the bezier curve
  6593. */
  6594. constructor(
  6595. /** Defines the x component of the start tangent in the bezier curve */
  6596. x1?: number,
  6597. /** Defines the y component of the start tangent in the bezier curve */
  6598. y1?: number,
  6599. /** Defines the x component of the end tangent in the bezier curve */
  6600. x2?: number,
  6601. /** Defines the y component of the end tangent in the bezier curve */
  6602. y2?: number);
  6603. /** @hidden */
  6604. easeInCore(gradient: number): number;
  6605. }
  6606. }
  6607. declare module BABYLON {
  6608. /**
  6609. * Defines an interface which represents an animation key frame
  6610. */
  6611. export interface IAnimationKey {
  6612. /**
  6613. * Frame of the key frame
  6614. */
  6615. frame: number;
  6616. /**
  6617. * Value at the specifies key frame
  6618. */
  6619. value: any;
  6620. /**
  6621. * The input tangent for the cubic hermite spline
  6622. */
  6623. inTangent?: any;
  6624. /**
  6625. * The output tangent for the cubic hermite spline
  6626. */
  6627. outTangent?: any;
  6628. /**
  6629. * The animation interpolation type
  6630. */
  6631. interpolation?: AnimationKeyInterpolation;
  6632. }
  6633. /**
  6634. * Enum for the animation key frame interpolation type
  6635. */
  6636. export enum AnimationKeyInterpolation {
  6637. /**
  6638. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6639. */
  6640. STEP = 1
  6641. }
  6642. }
  6643. declare module BABYLON {
  6644. /**
  6645. * Represents the range of an animation
  6646. */
  6647. export class AnimationRange {
  6648. /**The name of the animation range**/
  6649. name: string;
  6650. /**The starting frame of the animation */
  6651. from: number;
  6652. /**The ending frame of the animation*/
  6653. to: number;
  6654. /**
  6655. * Initializes the range of an animation
  6656. * @param name The name of the animation range
  6657. * @param from The starting frame of the animation
  6658. * @param to The ending frame of the animation
  6659. */
  6660. constructor(
  6661. /**The name of the animation range**/
  6662. name: string,
  6663. /**The starting frame of the animation */
  6664. from: number,
  6665. /**The ending frame of the animation*/
  6666. to: number);
  6667. /**
  6668. * Makes a copy of the animation range
  6669. * @returns A copy of the animation range
  6670. */
  6671. clone(): AnimationRange;
  6672. }
  6673. }
  6674. declare module BABYLON {
  6675. /**
  6676. * Composed of a frame, and an action function
  6677. */
  6678. export class AnimationEvent {
  6679. /** The frame for which the event is triggered **/
  6680. frame: number;
  6681. /** The event to perform when triggered **/
  6682. action: (currentFrame: number) => void;
  6683. /** Specifies if the event should be triggered only once**/
  6684. onlyOnce?: boolean | undefined;
  6685. /**
  6686. * Specifies if the animation event is done
  6687. */
  6688. isDone: boolean;
  6689. /**
  6690. * Initializes the animation event
  6691. * @param frame The frame for which the event is triggered
  6692. * @param action The event to perform when triggered
  6693. * @param onlyOnce Specifies if the event should be triggered only once
  6694. */
  6695. constructor(
  6696. /** The frame for which the event is triggered **/
  6697. frame: number,
  6698. /** The event to perform when triggered **/
  6699. action: (currentFrame: number) => void,
  6700. /** Specifies if the event should be triggered only once**/
  6701. onlyOnce?: boolean | undefined);
  6702. /** @hidden */ clone(): AnimationEvent;
  6703. }
  6704. }
  6705. declare module BABYLON {
  6706. /**
  6707. * Interface used to define a behavior
  6708. */
  6709. export interface Behavior<T> {
  6710. /** gets or sets behavior's name */
  6711. name: string;
  6712. /**
  6713. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6714. */
  6715. init(): void;
  6716. /**
  6717. * Called when the behavior is attached to a target
  6718. * @param target defines the target where the behavior is attached to
  6719. */
  6720. attach(target: T): void;
  6721. /**
  6722. * Called when the behavior is detached from its target
  6723. */
  6724. detach(): void;
  6725. }
  6726. /**
  6727. * Interface implemented by classes supporting behaviors
  6728. */
  6729. export interface IBehaviorAware<T> {
  6730. /**
  6731. * Attach a behavior
  6732. * @param behavior defines the behavior to attach
  6733. * @returns the current host
  6734. */
  6735. addBehavior(behavior: Behavior<T>): T;
  6736. /**
  6737. * Remove a behavior from the current object
  6738. * @param behavior defines the behavior to detach
  6739. * @returns the current host
  6740. */
  6741. removeBehavior(behavior: Behavior<T>): T;
  6742. /**
  6743. * Gets a behavior using its name to search
  6744. * @param name defines the name to search
  6745. * @returns the behavior or null if not found
  6746. */
  6747. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6748. }
  6749. }
  6750. declare module BABYLON {
  6751. /**
  6752. * @hidden
  6753. */
  6754. export class IntersectionInfo {
  6755. bu: Nullable<number>;
  6756. bv: Nullable<number>;
  6757. distance: number;
  6758. faceId: number;
  6759. subMeshId: number;
  6760. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6761. }
  6762. }
  6763. declare module BABYLON {
  6764. /**
  6765. * Class used to store bounding sphere information
  6766. */
  6767. export class BoundingSphere {
  6768. /**
  6769. * Gets the center of the bounding sphere in local space
  6770. */
  6771. readonly center: Vector3;
  6772. /**
  6773. * Radius of the bounding sphere in local space
  6774. */
  6775. radius: number;
  6776. /**
  6777. * Gets the center of the bounding sphere in world space
  6778. */
  6779. readonly centerWorld: Vector3;
  6780. /**
  6781. * Radius of the bounding sphere in world space
  6782. */
  6783. radiusWorld: number;
  6784. /**
  6785. * Gets the minimum vector in local space
  6786. */
  6787. readonly minimum: Vector3;
  6788. /**
  6789. * Gets the maximum vector in local space
  6790. */
  6791. readonly maximum: Vector3;
  6792. private _worldMatrix;
  6793. private static readonly TmpVector3;
  6794. /**
  6795. * Creates a new bounding sphere
  6796. * @param min defines the minimum vector (in local space)
  6797. * @param max defines the maximum vector (in local space)
  6798. * @param worldMatrix defines the new world matrix
  6799. */
  6800. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6801. /**
  6802. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6803. * @param min defines the new minimum vector (in local space)
  6804. * @param max defines the new maximum vector (in local space)
  6805. * @param worldMatrix defines the new world matrix
  6806. */
  6807. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6808. /**
  6809. * Scale the current bounding sphere by applying a scale factor
  6810. * @param factor defines the scale factor to apply
  6811. * @returns the current bounding box
  6812. */
  6813. scale(factor: number): BoundingSphere;
  6814. /**
  6815. * Gets the world matrix of the bounding box
  6816. * @returns a matrix
  6817. */
  6818. getWorldMatrix(): DeepImmutable<Matrix>;
  6819. /** @hidden */ update(worldMatrix: DeepImmutable<Matrix>): void;
  6820. /**
  6821. * Tests if the bounding sphere is intersecting the frustum planes
  6822. * @param frustumPlanes defines the frustum planes to test
  6823. * @returns true if there is an intersection
  6824. */
  6825. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6826. /**
  6827. * Tests if the bounding sphere center is in between the frustum planes.
  6828. * Used for optimistic fast inclusion.
  6829. * @param frustumPlanes defines the frustum planes to test
  6830. * @returns true if the sphere center is in between the frustum planes
  6831. */
  6832. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6833. /**
  6834. * Tests if a point is inside the bounding sphere
  6835. * @param point defines the point to test
  6836. * @returns true if the point is inside the bounding sphere
  6837. */
  6838. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6839. /**
  6840. * Checks if two sphere intersct
  6841. * @param sphere0 sphere 0
  6842. * @param sphere1 sphere 1
  6843. * @returns true if the speres intersect
  6844. */
  6845. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6846. }
  6847. }
  6848. declare module BABYLON {
  6849. /**
  6850. * Class used to store bounding box information
  6851. */
  6852. export class BoundingBox implements ICullable {
  6853. /**
  6854. * Gets the 8 vectors representing the bounding box in local space
  6855. */
  6856. readonly vectors: Vector3[];
  6857. /**
  6858. * Gets the center of the bounding box in local space
  6859. */
  6860. readonly center: Vector3;
  6861. /**
  6862. * Gets the center of the bounding box in world space
  6863. */
  6864. readonly centerWorld: Vector3;
  6865. /**
  6866. * Gets the extend size in local space
  6867. */
  6868. readonly extendSize: Vector3;
  6869. /**
  6870. * Gets the extend size in world space
  6871. */
  6872. readonly extendSizeWorld: Vector3;
  6873. /**
  6874. * Gets the OBB (object bounding box) directions
  6875. */
  6876. readonly directions: Vector3[];
  6877. /**
  6878. * Gets the 8 vectors representing the bounding box in world space
  6879. */
  6880. readonly vectorsWorld: Vector3[];
  6881. /**
  6882. * Gets the minimum vector in world space
  6883. */
  6884. readonly minimumWorld: Vector3;
  6885. /**
  6886. * Gets the maximum vector in world space
  6887. */
  6888. readonly maximumWorld: Vector3;
  6889. /**
  6890. * Gets the minimum vector in local space
  6891. */
  6892. readonly minimum: Vector3;
  6893. /**
  6894. * Gets the maximum vector in local space
  6895. */
  6896. readonly maximum: Vector3;
  6897. private _worldMatrix;
  6898. private static readonly TmpVector3;
  6899. /**
  6900. * @hidden
  6901. */ tag: number;
  6902. /**
  6903. * Creates a new bounding box
  6904. * @param min defines the minimum vector (in local space)
  6905. * @param max defines the maximum vector (in local space)
  6906. * @param worldMatrix defines the new world matrix
  6907. */
  6908. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6909. /**
  6910. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6911. * @param min defines the new minimum vector (in local space)
  6912. * @param max defines the new maximum vector (in local space)
  6913. * @param worldMatrix defines the new world matrix
  6914. */
  6915. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6916. /**
  6917. * Scale the current bounding box by applying a scale factor
  6918. * @param factor defines the scale factor to apply
  6919. * @returns the current bounding box
  6920. */
  6921. scale(factor: number): BoundingBox;
  6922. /**
  6923. * Gets the world matrix of the bounding box
  6924. * @returns a matrix
  6925. */
  6926. getWorldMatrix(): DeepImmutable<Matrix>;
  6927. /** @hidden */ update(world: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding box is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding box is entirely inside the frustum planes
  6936. * @param frustumPlanes defines the frustum planes to test
  6937. * @returns true if there is an inclusion
  6938. */
  6939. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6940. /**
  6941. * Tests if a point is inside the bounding box
  6942. * @param point defines the point to test
  6943. * @returns true if the point is inside the bounding box
  6944. */
  6945. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6946. /**
  6947. * Tests if the bounding box intersects with a bounding sphere
  6948. * @param sphere defines the sphere to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6952. /**
  6953. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6954. * @param min defines the min vector to use
  6955. * @param max defines the max vector to use
  6956. * @returns true if there is an intersection
  6957. */
  6958. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6959. /**
  6960. * Tests if two bounding boxes are intersections
  6961. * @param box0 defines the first box to test
  6962. * @param box1 defines the second box to test
  6963. * @returns true if there is an intersection
  6964. */
  6965. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6966. /**
  6967. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6968. * @param minPoint defines the minimum vector of the bounding box
  6969. * @param maxPoint defines the maximum vector of the bounding box
  6970. * @param sphereCenter defines the sphere center
  6971. * @param sphereRadius defines the sphere radius
  6972. * @returns true if there is an intersection
  6973. */
  6974. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6975. /**
  6976. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6977. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6978. * @param frustumPlanes defines the frustum planes to test
  6979. * @return true if there is an inclusion
  6980. */
  6981. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6982. /**
  6983. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6984. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6985. * @param frustumPlanes defines the frustum planes to test
  6986. * @return true if there is an intersection
  6987. */
  6988. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6989. }
  6990. }
  6991. declare module BABYLON {
  6992. /** @hidden */
  6993. export class Collider {
  6994. /** Define if a collision was found */
  6995. collisionFound: boolean;
  6996. /**
  6997. * Define last intersection point in local space
  6998. */
  6999. intersectionPoint: Vector3;
  7000. /**
  7001. * Define last collided mesh
  7002. */
  7003. collidedMesh: Nullable<AbstractMesh>;
  7004. private _collisionPoint;
  7005. private _planeIntersectionPoint;
  7006. private _tempVector;
  7007. private _tempVector2;
  7008. private _tempVector3;
  7009. private _tempVector4;
  7010. private _edge;
  7011. private _baseToVertex;
  7012. private _destinationPoint;
  7013. private _slidePlaneNormal;
  7014. private _displacementVector;
  7015. /** @hidden */ radius: Vector3;
  7016. /** @hidden */ retry: number;
  7017. private _velocity;
  7018. private _basePoint;
  7019. private _epsilon;
  7020. /** @hidden */ velocityWorldLength: number;
  7021. /** @hidden */ basePointWorld: Vector3;
  7022. private _velocityWorld;
  7023. private _normalizedVelocity;
  7024. /** @hidden */ initialVelocity: Vector3;
  7025. /** @hidden */ initialPosition: Vector3;
  7026. private _nearestDistance;
  7027. private _collisionMask;
  7028. collisionMask: number;
  7029. /**
  7030. * Gets the plane normal used to compute the sliding response (in local space)
  7031. */
  7032. readonly slidePlaneNormal: Vector3;
  7033. /** @hidden */ initialize(source: Vector3, dir: Vector3, e: number): void;
  7034. /** @hidden */ checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7035. /** @hidden */ canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7036. /** @hidden */ testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7037. /** @hidden */ collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7038. /** @hidden */ getResponse(pos: Vector3, vel: Vector3): void;
  7039. }
  7040. }
  7041. declare module BABYLON {
  7042. /**
  7043. * Interface for cullable objects
  7044. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7045. */
  7046. export interface ICullable {
  7047. /**
  7048. * Checks if the object or part of the object is in the frustum
  7049. * @param frustumPlanes Camera near/planes
  7050. * @returns true if the object is in frustum otherwise false
  7051. */
  7052. isInFrustum(frustumPlanes: Plane[]): boolean;
  7053. /**
  7054. * Checks if a cullable object (mesh...) is in the camera frustum
  7055. * Unlike isInFrustum this cheks the full bounding box
  7056. * @param frustumPlanes Camera near/planes
  7057. * @returns true if the object is in frustum otherwise false
  7058. */
  7059. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7060. }
  7061. /**
  7062. * Info for a bounding data of a mesh
  7063. */
  7064. export class BoundingInfo implements ICullable {
  7065. /**
  7066. * Bounding box for the mesh
  7067. */
  7068. readonly boundingBox: BoundingBox;
  7069. /**
  7070. * Bounding sphere for the mesh
  7071. */
  7072. readonly boundingSphere: BoundingSphere;
  7073. private _isLocked;
  7074. private static readonly TmpVector3;
  7075. /**
  7076. * Constructs bounding info
  7077. * @param minimum min vector of the bounding box/sphere
  7078. * @param maximum max vector of the bounding box/sphere
  7079. * @param worldMatrix defines the new world matrix
  7080. */
  7081. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7082. /**
  7083. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7084. * @param min defines the new minimum vector (in local space)
  7085. * @param max defines the new maximum vector (in local space)
  7086. * @param worldMatrix defines the new world matrix
  7087. */
  7088. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7089. /**
  7090. * min vector of the bounding box/sphere
  7091. */
  7092. readonly minimum: Vector3;
  7093. /**
  7094. * max vector of the bounding box/sphere
  7095. */
  7096. readonly maximum: Vector3;
  7097. /**
  7098. * If the info is locked and won't be updated to avoid perf overhead
  7099. */
  7100. isLocked: boolean;
  7101. /**
  7102. * Updates the bounding sphere and box
  7103. * @param world world matrix to be used to update
  7104. */
  7105. update(world: DeepImmutable<Matrix>): void;
  7106. /**
  7107. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7108. * @param center New center of the bounding info
  7109. * @param extend New extend of the bounding info
  7110. * @returns the current bounding info
  7111. */
  7112. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7113. /**
  7114. * Scale the current bounding info by applying a scale factor
  7115. * @param factor defines the scale factor to apply
  7116. * @returns the current bounding info
  7117. */
  7118. scale(factor: number): BoundingInfo;
  7119. /**
  7120. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7121. * @param frustumPlanes defines the frustum to test
  7122. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7123. * @returns true if the bounding info is in the frustum planes
  7124. */
  7125. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7126. /**
  7127. * Gets the world distance between the min and max points of the bounding box
  7128. */
  7129. readonly diagonalLength: number;
  7130. /**
  7131. * Checks if a cullable object (mesh...) is in the camera frustum
  7132. * Unlike isInFrustum this cheks the full bounding box
  7133. * @param frustumPlanes Camera near/planes
  7134. * @returns true if the object is in frustum otherwise false
  7135. */
  7136. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. /** @hidden */ checkCollision(collider: Collider): boolean;
  7138. /**
  7139. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7140. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7141. * @param point the point to check intersection with
  7142. * @returns if the point intersects
  7143. */
  7144. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7145. /**
  7146. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7147. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7148. * @param boundingInfo the bounding info to check intersection with
  7149. * @param precise if the intersection should be done using OBB
  7150. * @returns if the bounding info intersects
  7151. */
  7152. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7153. }
  7154. }
  7155. declare module BABYLON {
  7156. /**
  7157. * Defines an array and its length.
  7158. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7159. */
  7160. export interface ISmartArrayLike<T> {
  7161. /**
  7162. * The data of the array.
  7163. */
  7164. data: Array<T>;
  7165. /**
  7166. * The active length of the array.
  7167. */
  7168. length: number;
  7169. }
  7170. /**
  7171. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7172. */
  7173. export class SmartArray<T> implements ISmartArrayLike<T> {
  7174. /**
  7175. * The full set of data from the array.
  7176. */
  7177. data: Array<T>;
  7178. /**
  7179. * The active length of the array.
  7180. */
  7181. length: number;
  7182. protected _id: number;
  7183. /**
  7184. * Instantiates a Smart Array.
  7185. * @param capacity defines the default capacity of the array.
  7186. */
  7187. constructor(capacity: number);
  7188. /**
  7189. * Pushes a value at the end of the active data.
  7190. * @param value defines the object to push in the array.
  7191. */
  7192. push(value: T): void;
  7193. /**
  7194. * Iterates over the active data and apply the lambda to them.
  7195. * @param func defines the action to apply on each value.
  7196. */
  7197. forEach(func: (content: T) => void): void;
  7198. /**
  7199. * Sorts the full sets of data.
  7200. * @param compareFn defines the comparison function to apply.
  7201. */
  7202. sort(compareFn: (a: T, b: T) => number): void;
  7203. /**
  7204. * Resets the active data to an empty array.
  7205. */
  7206. reset(): void;
  7207. /**
  7208. * Releases all the data from the array as well as the array.
  7209. */
  7210. dispose(): void;
  7211. /**
  7212. * Concats the active data with a given array.
  7213. * @param array defines the data to concatenate with.
  7214. */
  7215. concat(array: any): void;
  7216. /**
  7217. * Returns the position of a value in the active data.
  7218. * @param value defines the value to find the index for
  7219. * @returns the index if found in the active data otherwise -1
  7220. */
  7221. indexOf(value: T): number;
  7222. /**
  7223. * Returns whether an element is part of the active data.
  7224. * @param value defines the value to look for
  7225. * @returns true if found in the active data otherwise false
  7226. */
  7227. contains(value: T): boolean;
  7228. private static _GlobalId;
  7229. }
  7230. /**
  7231. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7232. * The data in this array can only be present once
  7233. */
  7234. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7235. private _duplicateId;
  7236. /**
  7237. * Pushes a value at the end of the active data.
  7238. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7239. * @param value defines the object to push in the array.
  7240. */
  7241. push(value: T): void;
  7242. /**
  7243. * Pushes a value at the end of the active data.
  7244. * If the data is already present, it won t be added again
  7245. * @param value defines the object to push in the array.
  7246. * @returns true if added false if it was already present
  7247. */
  7248. pushNoDuplicate(value: T): boolean;
  7249. /**
  7250. * Resets the active data to an empty array.
  7251. */
  7252. reset(): void;
  7253. /**
  7254. * Concats the active data with a given array.
  7255. * This ensures no dupplicate will be present in the result.
  7256. * @param array defines the data to concatenate with.
  7257. */
  7258. concatWithNoDuplicate(array: any): void;
  7259. }
  7260. }
  7261. declare module BABYLON {
  7262. /**
  7263. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7264. * separate meshes. This can be use to improve performances.
  7265. * @see http://doc.babylonjs.com/how_to/multi_materials
  7266. */
  7267. export class MultiMaterial extends Material {
  7268. private _subMaterials;
  7269. /**
  7270. * Gets or Sets the list of Materials used within the multi material.
  7271. * They need to be ordered according to the submeshes order in the associated mesh
  7272. */
  7273. subMaterials: Nullable<Material>[];
  7274. /**
  7275. * Function used to align with Node.getChildren()
  7276. * @returns the list of Materials used within the multi material
  7277. */
  7278. getChildren(): Nullable<Material>[];
  7279. /**
  7280. * Instantiates a new Multi Material
  7281. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7282. * separate meshes. This can be use to improve performances.
  7283. * @see http://doc.babylonjs.com/how_to/multi_materials
  7284. * @param name Define the name in the scene
  7285. * @param scene Define the scene the material belongs to
  7286. */
  7287. constructor(name: string, scene: Scene);
  7288. private _hookArray;
  7289. /**
  7290. * Get one of the submaterial by its index in the submaterials array
  7291. * @param index The index to look the sub material at
  7292. * @returns The Material if the index has been defined
  7293. */
  7294. getSubMaterial(index: number): Nullable<Material>;
  7295. /**
  7296. * Get the list of active textures for the whole sub materials list.
  7297. * @returns All the textures that will be used during the rendering
  7298. */
  7299. getActiveTextures(): BaseTexture[];
  7300. /**
  7301. * Gets the current class name of the material e.g. "MultiMaterial"
  7302. * Mainly use in serialization.
  7303. * @returns the class name
  7304. */
  7305. getClassName(): string;
  7306. /**
  7307. * Checks if the material is ready to render the requested sub mesh
  7308. * @param mesh Define the mesh the submesh belongs to
  7309. * @param subMesh Define the sub mesh to look readyness for
  7310. * @param useInstances Define whether or not the material is used with instances
  7311. * @returns true if ready, otherwise false
  7312. */
  7313. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7314. /**
  7315. * Clones the current material and its related sub materials
  7316. * @param name Define the name of the newly cloned material
  7317. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7318. * @returns the cloned material
  7319. */
  7320. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7321. /**
  7322. * Serializes the materials into a JSON representation.
  7323. * @returns the JSON representation
  7324. */
  7325. serialize(): any;
  7326. /**
  7327. * Dispose the material and release its associated resources
  7328. * @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)
  7329. * @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)
  7330. * @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)
  7331. */
  7332. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7333. /**
  7334. * Creates a MultiMaterial from parsed MultiMaterial data.
  7335. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7336. * @param scene defines the hosting scene
  7337. * @returns a new MultiMaterial
  7338. */
  7339. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7340. }
  7341. }
  7342. declare module BABYLON {
  7343. /**
  7344. * Class used to represent data loading progression
  7345. */
  7346. export class SceneLoaderFlags {
  7347. private static _ForceFullSceneLoadingForIncremental;
  7348. private static _ShowLoadingScreen;
  7349. private static _CleanBoneMatrixWeights;
  7350. private static _loggingLevel;
  7351. /**
  7352. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7353. */
  7354. static ForceFullSceneLoadingForIncremental: boolean;
  7355. /**
  7356. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7357. */
  7358. static ShowLoadingScreen: boolean;
  7359. /**
  7360. * Defines the current logging level (while loading the scene)
  7361. * @ignorenaming
  7362. */
  7363. static loggingLevel: number;
  7364. /**
  7365. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7366. */
  7367. static CleanBoneMatrixWeights: boolean;
  7368. }
  7369. }
  7370. declare module BABYLON {
  7371. /**
  7372. * 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.
  7373. * @see https://doc.babylonjs.com/how_to/transformnode
  7374. */
  7375. export class TransformNode extends Node {
  7376. /**
  7377. * Object will not rotate to face the camera
  7378. */
  7379. static BILLBOARDMODE_NONE: number;
  7380. /**
  7381. * Object will rotate to face the camera but only on the x axis
  7382. */
  7383. static BILLBOARDMODE_X: number;
  7384. /**
  7385. * Object will rotate to face the camera but only on the y axis
  7386. */
  7387. static BILLBOARDMODE_Y: number;
  7388. /**
  7389. * Object will rotate to face the camera but only on the z axis
  7390. */
  7391. static BILLBOARDMODE_Z: number;
  7392. /**
  7393. * Object will rotate to face the camera
  7394. */
  7395. static BILLBOARDMODE_ALL: number;
  7396. private _forward;
  7397. private _forwardInverted;
  7398. private _up;
  7399. private _right;
  7400. private _rightInverted;
  7401. private _position;
  7402. private _rotation;
  7403. private _rotationQuaternion;
  7404. protected _scaling: Vector3;
  7405. protected _isDirty: boolean;
  7406. private _transformToBoneReferal;
  7407. private _billboardMode;
  7408. /**
  7409. * Gets or sets the billboard mode. Default is 0.
  7410. *
  7411. * | Value | Type | Description |
  7412. * | --- | --- | --- |
  7413. * | 0 | BILLBOARDMODE_NONE | |
  7414. * | 1 | BILLBOARDMODE_X | |
  7415. * | 2 | BILLBOARDMODE_Y | |
  7416. * | 4 | BILLBOARDMODE_Z | |
  7417. * | 7 | BILLBOARDMODE_ALL | |
  7418. *
  7419. */
  7420. billboardMode: number;
  7421. private _preserveParentRotationForBillboard;
  7422. /**
  7423. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7424. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7425. */
  7426. preserveParentRotationForBillboard: boolean;
  7427. /**
  7428. * 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
  7429. */
  7430. scalingDeterminant: number;
  7431. private _infiniteDistance;
  7432. /**
  7433. * Gets or sets the distance of the object to max, often used by skybox
  7434. */
  7435. infiniteDistance: boolean;
  7436. /**
  7437. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7438. * By default the system will update normals to compensate
  7439. */
  7440. ignoreNonUniformScaling: boolean;
  7441. /**
  7442. * 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
  7443. */
  7444. reIntegrateRotationIntoRotationQuaternion: boolean;
  7445. /** @hidden */ poseMatrix: Nullable<Matrix>;
  7446. /** @hidden */ localMatrix: Matrix;
  7447. private _usePivotMatrix;
  7448. private _absolutePosition;
  7449. private _pivotMatrix;
  7450. private _pivotMatrixInverse;
  7451. protected _postMultiplyPivotMatrix: boolean;
  7452. protected _isWorldMatrixFrozen: boolean;
  7453. /** @hidden */ indexInSceneTransformNodesArray: number;
  7454. /**
  7455. * An event triggered after the world matrix is updated
  7456. */
  7457. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7458. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7459. /**
  7460. * Gets a string identifying the name of the class
  7461. * @returns "TransformNode" string
  7462. */
  7463. getClassName(): string;
  7464. /**
  7465. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7466. */
  7467. position: Vector3;
  7468. /**
  7469. * 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)).
  7470. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7471. */
  7472. rotation: Vector3;
  7473. /**
  7474. * 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)).
  7475. */
  7476. scaling: Vector3;
  7477. /**
  7478. * 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).
  7479. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7480. */
  7481. rotationQuaternion: Nullable<Quaternion>;
  7482. /**
  7483. * The forward direction of that transform in world space.
  7484. */
  7485. readonly forward: Vector3;
  7486. /**
  7487. * The up direction of that transform in world space.
  7488. */
  7489. readonly up: Vector3;
  7490. /**
  7491. * The right direction of that transform in world space.
  7492. */
  7493. readonly right: Vector3;
  7494. /**
  7495. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7496. * @param matrix the matrix to copy the pose from
  7497. * @returns this TransformNode.
  7498. */
  7499. updatePoseMatrix(matrix: Matrix): TransformNode;
  7500. /**
  7501. * Returns the mesh Pose matrix.
  7502. * @returns the pose matrix
  7503. */
  7504. getPoseMatrix(): Matrix;
  7505. /** @hidden */ isSynchronized(): boolean;
  7506. /** @hidden */ initCache(): void;
  7507. /**
  7508. * Flag the transform node as dirty (Forcing it to update everything)
  7509. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7510. * @returns this transform node
  7511. */
  7512. markAsDirty(property: string): TransformNode;
  7513. /**
  7514. * Returns the current mesh absolute position.
  7515. * Returns a Vector3.
  7516. */
  7517. readonly absolutePosition: Vector3;
  7518. /**
  7519. * Sets a new matrix to apply before all other transformation
  7520. * @param matrix defines the transform matrix
  7521. * @returns the current TransformNode
  7522. */
  7523. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7524. /**
  7525. * Sets a new pivot matrix to the current node
  7526. * @param matrix defines the new pivot matrix to use
  7527. * @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
  7528. * @returns the current TransformNode
  7529. */
  7530. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7531. /**
  7532. * Returns the mesh pivot matrix.
  7533. * Default : Identity.
  7534. * @returns the matrix
  7535. */
  7536. getPivotMatrix(): Matrix;
  7537. /**
  7538. * Prevents the World matrix to be computed any longer.
  7539. * @returns the TransformNode.
  7540. */
  7541. freezeWorldMatrix(): TransformNode;
  7542. /**
  7543. * Allows back the World matrix computation.
  7544. * @returns the TransformNode.
  7545. */
  7546. unfreezeWorldMatrix(): this;
  7547. /**
  7548. * True if the World matrix has been frozen.
  7549. */
  7550. readonly isWorldMatrixFrozen: boolean;
  7551. /**
  7552. * Retuns the mesh absolute position in the World.
  7553. * @returns a Vector3.
  7554. */
  7555. getAbsolutePosition(): Vector3;
  7556. /**
  7557. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7558. * @param absolutePosition the absolute position to set
  7559. * @returns the TransformNode.
  7560. */
  7561. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7562. /**
  7563. * Sets the mesh position in its local space.
  7564. * @param vector3 the position to set in localspace
  7565. * @returns the TransformNode.
  7566. */
  7567. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7568. /**
  7569. * Returns the mesh position in the local space from the current World matrix values.
  7570. * @returns a new Vector3.
  7571. */
  7572. getPositionExpressedInLocalSpace(): Vector3;
  7573. /**
  7574. * Translates the mesh along the passed Vector3 in its local space.
  7575. * @param vector3 the distance to translate in localspace
  7576. * @returns the TransformNode.
  7577. */
  7578. locallyTranslate(vector3: Vector3): TransformNode;
  7579. private static _lookAtVectorCache;
  7580. /**
  7581. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7582. * @param targetPoint the position (must be in same space as current mesh) to look at
  7583. * @param yawCor optional yaw (y-axis) correction in radians
  7584. * @param pitchCor optional pitch (x-axis) correction in radians
  7585. * @param rollCor optional roll (z-axis) correction in radians
  7586. * @param space the choosen space of the target
  7587. * @returns the TransformNode.
  7588. */
  7589. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7590. /**
  7591. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7592. * This Vector3 is expressed in the World space.
  7593. * @param localAxis axis to rotate
  7594. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7595. */
  7596. getDirection(localAxis: Vector3): Vector3;
  7597. /**
  7598. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7599. * localAxis is expressed in the mesh local space.
  7600. * result is computed in the Wordl space from the mesh World matrix.
  7601. * @param localAxis axis to rotate
  7602. * @param result the resulting transformnode
  7603. * @returns this TransformNode.
  7604. */
  7605. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7606. /**
  7607. * Sets this transform node rotation to the given local axis.
  7608. * @param localAxis the axis in local space
  7609. * @param yawCor optional yaw (y-axis) correction in radians
  7610. * @param pitchCor optional pitch (x-axis) correction in radians
  7611. * @param rollCor optional roll (z-axis) correction in radians
  7612. * @returns this TransformNode
  7613. */
  7614. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7615. /**
  7616. * Sets a new pivot point to the current node
  7617. * @param point defines the new pivot point to use
  7618. * @param space defines if the point is in world or local space (local by default)
  7619. * @returns the current TransformNode
  7620. */
  7621. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7622. /**
  7623. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7624. * @returns the pivot point
  7625. */
  7626. getPivotPoint(): Vector3;
  7627. /**
  7628. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7629. * @param result the vector3 to store the result
  7630. * @returns this TransformNode.
  7631. */
  7632. getPivotPointToRef(result: Vector3): TransformNode;
  7633. /**
  7634. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7635. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7636. */
  7637. getAbsolutePivotPoint(): Vector3;
  7638. /**
  7639. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7640. * @param result vector3 to store the result
  7641. * @returns this TransformNode.
  7642. */
  7643. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7644. /**
  7645. * Defines the passed node as the parent of the current node.
  7646. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7647. * @see https://doc.babylonjs.com/how_to/parenting
  7648. * @param node the node ot set as the parent
  7649. * @returns this TransformNode.
  7650. */
  7651. setParent(node: Nullable<Node>): TransformNode;
  7652. private _nonUniformScaling;
  7653. /**
  7654. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7655. */
  7656. readonly nonUniformScaling: boolean;
  7657. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  7658. /**
  7659. * Attach the current TransformNode to another TransformNode associated with a bone
  7660. * @param bone Bone affecting the TransformNode
  7661. * @param affectedTransformNode TransformNode associated with the bone
  7662. * @returns this object
  7663. */
  7664. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7665. /**
  7666. * Detach the transform node if its associated with a bone
  7667. * @returns this object
  7668. */
  7669. detachFromBone(): TransformNode;
  7670. private static _rotationAxisCache;
  7671. /**
  7672. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7673. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7674. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7675. * The passed axis is also normalized.
  7676. * @param axis the axis to rotate around
  7677. * @param amount the amount to rotate in radians
  7678. * @param space Space to rotate in (Default: local)
  7679. * @returns the TransformNode.
  7680. */
  7681. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7682. /**
  7683. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7684. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7685. * The passed axis is also normalized. .
  7686. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7687. * @param point the point to rotate around
  7688. * @param axis the axis to rotate around
  7689. * @param amount the amount to rotate in radians
  7690. * @returns the TransformNode
  7691. */
  7692. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7693. /**
  7694. * Translates the mesh along the axis vector for the passed distance in the given space.
  7695. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7696. * @param axis the axis to translate in
  7697. * @param distance the distance to translate
  7698. * @param space Space to rotate in (Default: local)
  7699. * @returns the TransformNode.
  7700. */
  7701. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7702. /**
  7703. * Adds a rotation step to the mesh current rotation.
  7704. * x, y, z are Euler angles expressed in radians.
  7705. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7706. * This means this rotation is made in the mesh local space only.
  7707. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7708. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7709. * ```javascript
  7710. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7711. * ```
  7712. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7713. * 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.
  7714. * @param x Rotation to add
  7715. * @param y Rotation to add
  7716. * @param z Rotation to add
  7717. * @returns the TransformNode.
  7718. */
  7719. addRotation(x: number, y: number, z: number): TransformNode;
  7720. /**
  7721. * @hidden
  7722. */
  7723. protected _getEffectiveParent(): Nullable<Node>;
  7724. /**
  7725. * Computes the world matrix of the node
  7726. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7727. * @returns the world matrix
  7728. */
  7729. computeWorldMatrix(force?: boolean): Matrix;
  7730. protected _afterComputeWorldMatrix(): void;
  7731. /**
  7732. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7733. * @param func callback function to add
  7734. *
  7735. * @returns the TransformNode.
  7736. */
  7737. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7738. /**
  7739. * Removes a registered callback function.
  7740. * @param func callback function to remove
  7741. * @returns the TransformNode.
  7742. */
  7743. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7744. /**
  7745. * Gets the position of the current mesh in camera space
  7746. * @param camera defines the camera to use
  7747. * @returns a position
  7748. */
  7749. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7750. /**
  7751. * Returns the distance from the mesh to the active camera
  7752. * @param camera defines the camera to use
  7753. * @returns the distance
  7754. */
  7755. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7756. /**
  7757. * Clone the current transform node
  7758. * @param name Name of the new clone
  7759. * @param newParent New parent for the clone
  7760. * @param doNotCloneChildren Do not clone children hierarchy
  7761. * @returns the new transform node
  7762. */
  7763. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7764. /**
  7765. * Serializes the objects information.
  7766. * @param currentSerializationObject defines the object to serialize in
  7767. * @returns the serialized object
  7768. */
  7769. serialize(currentSerializationObject?: any): any;
  7770. /**
  7771. * Returns a new TransformNode object parsed from the source provided.
  7772. * @param parsedTransformNode is the source.
  7773. * @param scene the scne the object belongs to
  7774. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7775. * @returns a new TransformNode object parsed from the source provided.
  7776. */
  7777. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7778. /**
  7779. * Get all child-transformNodes of this node
  7780. * @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
  7781. * @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
  7782. * @returns an array of TransformNode
  7783. */
  7784. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7785. /**
  7786. * Releases resources associated with this transform node.
  7787. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7788. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7789. */
  7790. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7791. }
  7792. }
  7793. declare module BABYLON {
  7794. /**
  7795. * Class used to override all child animations of a given target
  7796. */
  7797. export class AnimationPropertiesOverride {
  7798. /**
  7799. * Gets or sets a value indicating if animation blending must be used
  7800. */
  7801. enableBlending: boolean;
  7802. /**
  7803. * Gets or sets the blending speed to use when enableBlending is true
  7804. */
  7805. blendingSpeed: number;
  7806. /**
  7807. * Gets or sets the default loop mode to use
  7808. */
  7809. loopMode: number;
  7810. }
  7811. }
  7812. declare module BABYLON {
  7813. /**
  7814. * Class used to store bone information
  7815. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7816. */
  7817. export class Bone extends Node {
  7818. /**
  7819. * defines the bone name
  7820. */
  7821. name: string;
  7822. private static _tmpVecs;
  7823. private static _tmpQuat;
  7824. private static _tmpMats;
  7825. /**
  7826. * Gets the list of child bones
  7827. */
  7828. children: Bone[];
  7829. /** Gets the animations associated with this bone */
  7830. animations: Animation[];
  7831. /**
  7832. * Gets or sets bone length
  7833. */
  7834. length: number;
  7835. /**
  7836. * @hidden Internal only
  7837. * Set this value to map this bone to a different index in the transform matrices
  7838. * Set this value to -1 to exclude the bone from the transform matrices
  7839. */ index: Nullable<number>;
  7840. private _skeleton;
  7841. private _localMatrix;
  7842. private _restPose;
  7843. private _baseMatrix;
  7844. private _absoluteTransform;
  7845. private _invertedAbsoluteTransform;
  7846. private _parent;
  7847. private _scalingDeterminant;
  7848. private _worldTransform;
  7849. private _localScaling;
  7850. private _localRotation;
  7851. private _localPosition;
  7852. private _needToDecompose;
  7853. private _needToCompose;
  7854. /** @hidden */ linkedTransformNode: Nullable<TransformNode>;
  7855. /** @hidden */
  7856. /** @hidden */ matrix: Matrix;
  7857. /**
  7858. * Create a new bone
  7859. * @param name defines the bone name
  7860. * @param skeleton defines the parent skeleton
  7861. * @param parentBone defines the parent (can be null if the bone is the root)
  7862. * @param localMatrix defines the local matrix
  7863. * @param restPose defines the rest pose matrix
  7864. * @param baseMatrix defines the base matrix
  7865. * @param index defines index of the bone in the hiearchy
  7866. */
  7867. constructor(
  7868. /**
  7869. * defines the bone name
  7870. */
  7871. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7872. /**
  7873. * Gets the current object class name.
  7874. * @return the class name
  7875. */
  7876. getClassName(): string;
  7877. /**
  7878. * Gets the parent skeleton
  7879. * @returns a skeleton
  7880. */
  7881. getSkeleton(): Skeleton;
  7882. /**
  7883. * Gets parent bone
  7884. * @returns a bone or null if the bone is the root of the bone hierarchy
  7885. */
  7886. getParent(): Nullable<Bone>;
  7887. /**
  7888. * Returns an array containing the root bones
  7889. * @returns an array containing the root bones
  7890. */
  7891. getChildren(): Array<Bone>;
  7892. /**
  7893. * Sets the parent bone
  7894. * @param parent defines the parent (can be null if the bone is the root)
  7895. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7896. */
  7897. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7898. /**
  7899. * Gets the local matrix
  7900. * @returns a matrix
  7901. */
  7902. getLocalMatrix(): Matrix;
  7903. /**
  7904. * Gets the base matrix (initial matrix which remains unchanged)
  7905. * @returns a matrix
  7906. */
  7907. getBaseMatrix(): Matrix;
  7908. /**
  7909. * Gets the rest pose matrix
  7910. * @returns a matrix
  7911. */
  7912. getRestPose(): Matrix;
  7913. /**
  7914. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7915. */
  7916. getWorldMatrix(): Matrix;
  7917. /**
  7918. * Sets the local matrix to rest pose matrix
  7919. */
  7920. returnToRest(): void;
  7921. /**
  7922. * Gets the inverse of the absolute transform matrix.
  7923. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7924. * @returns a matrix
  7925. */
  7926. getInvertedAbsoluteTransform(): Matrix;
  7927. /**
  7928. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7929. * @returns a matrix
  7930. */
  7931. getAbsoluteTransform(): Matrix;
  7932. /**
  7933. * Links with the given transform node.
  7934. * The local matrix of this bone is copied from the transform node every frame.
  7935. * @param transformNode defines the transform node to link to
  7936. */
  7937. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7938. /** Gets or sets current position (in local space) */
  7939. position: Vector3;
  7940. /** Gets or sets current rotation (in local space) */
  7941. rotation: Vector3;
  7942. /** Gets or sets current rotation quaternion (in local space) */
  7943. rotationQuaternion: Quaternion;
  7944. /** Gets or sets current scaling (in local space) */
  7945. scaling: Vector3;
  7946. /**
  7947. * Gets the animation properties override
  7948. */
  7949. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7950. private _decompose;
  7951. private _compose;
  7952. /**
  7953. * Update the base and local matrices
  7954. * @param matrix defines the new base or local matrix
  7955. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7956. * @param updateLocalMatrix defines if the local matrix should be updated
  7957. */
  7958. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  7959. /** @hidden */ updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  7960. /**
  7961. * Flag the bone as dirty (Forcing it to update everything)
  7962. */
  7963. markAsDirty(): void;
  7964. private _markAsDirtyAndCompose;
  7965. private _markAsDirtyAndDecompose;
  7966. /**
  7967. * Translate the bone in local or world space
  7968. * @param vec The amount to translate the bone
  7969. * @param space The space that the translation is in
  7970. * @param mesh The mesh that this bone is attached to. This is only used in world space
  7971. */
  7972. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  7973. /**
  7974. * Set the postion of the bone in local or world space
  7975. * @param position The position to set the bone
  7976. * @param space The space that the position is in
  7977. * @param mesh The mesh that this bone is attached to. This is only used in world space
  7978. */
  7979. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  7980. /**
  7981. * Set the absolute position of the bone (world space)
  7982. * @param position The position to set the bone
  7983. * @param mesh The mesh that this bone is attached to
  7984. */
  7985. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  7986. /**
  7987. * Scale the bone on the x, y and z axes (in local space)
  7988. * @param x The amount to scale the bone on the x axis
  7989. * @param y The amount to scale the bone on the y axis
  7990. * @param z The amount to scale the bone on the z axis
  7991. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  7992. */
  7993. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  7994. /**
  7995. * Set the bone scaling in local space
  7996. * @param scale defines the scaling vector
  7997. */
  7998. setScale(scale: Vector3): void;
  7999. /**
  8000. * Gets the current scaling in local space
  8001. * @returns the current scaling vector
  8002. */
  8003. getScale(): Vector3;
  8004. /**
  8005. * Gets the current scaling in local space and stores it in a target vector
  8006. * @param result defines the target vector
  8007. */
  8008. getScaleToRef(result: Vector3): void;
  8009. /**
  8010. * Set the yaw, pitch, and roll of the bone in local or world space
  8011. * @param yaw The rotation of the bone on the y axis
  8012. * @param pitch The rotation of the bone on the x axis
  8013. * @param roll The rotation of the bone on the z axis
  8014. * @param space The space that the axes of rotation are in
  8015. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8016. */
  8017. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8018. /**
  8019. * Add a rotation to the bone on an axis in local or world space
  8020. * @param axis The axis to rotate the bone on
  8021. * @param amount The amount to rotate the bone
  8022. * @param space The space that the axis is in
  8023. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8024. */
  8025. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8026. /**
  8027. * Set the rotation of the bone to a particular axis angle in local or world space
  8028. * @param axis The axis to rotate the bone on
  8029. * @param angle The angle that the bone should be rotated to
  8030. * @param space The space that the axis is in
  8031. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8032. */
  8033. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8034. /**
  8035. * Set the euler rotation of the bone in local of world space
  8036. * @param rotation The euler rotation that the bone should be set to
  8037. * @param space The space that the rotation is in
  8038. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8039. */
  8040. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8041. /**
  8042. * Set the quaternion rotation of the bone in local of world space
  8043. * @param quat The quaternion rotation that the bone should be set to
  8044. * @param space The space that the rotation is in
  8045. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8046. */
  8047. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8048. /**
  8049. * Set the rotation matrix of the bone in local of world space
  8050. * @param rotMat The rotation matrix that the bone should be set to
  8051. * @param space The space that the rotation is in
  8052. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8053. */
  8054. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8055. private _rotateWithMatrix;
  8056. private _getNegativeRotationToRef;
  8057. /**
  8058. * Get the position of the bone in local or world space
  8059. * @param space The space that the returned position is in
  8060. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8061. * @returns The position of the bone
  8062. */
  8063. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8064. /**
  8065. * Copy the position of the bone to a vector3 in local or world space
  8066. * @param space The space that the returned position is in
  8067. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8068. * @param result The vector3 to copy the position to
  8069. */
  8070. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8071. /**
  8072. * Get the absolute position of the bone (world space)
  8073. * @param mesh The mesh that this bone is attached to
  8074. * @returns The absolute position of the bone
  8075. */
  8076. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8077. /**
  8078. * Copy the absolute position of the bone (world space) to the result param
  8079. * @param mesh The mesh that this bone is attached to
  8080. * @param result The vector3 to copy the absolute position to
  8081. */
  8082. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8083. /**
  8084. * Compute the absolute transforms of this bone and its children
  8085. */
  8086. computeAbsoluteTransforms(): void;
  8087. /**
  8088. * Get the world direction from an axis that is in the local space of the bone
  8089. * @param localAxis The local direction that is used to compute the world direction
  8090. * @param mesh The mesh that this bone is attached to
  8091. * @returns The world direction
  8092. */
  8093. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8094. /**
  8095. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8096. * @param localAxis The local direction that is used to compute the world direction
  8097. * @param mesh The mesh that this bone is attached to
  8098. * @param result The vector3 that the world direction will be copied to
  8099. */
  8100. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8101. /**
  8102. * Get the euler rotation of the bone in local or world space
  8103. * @param space The space that the rotation should be in
  8104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8105. * @returns The euler rotation
  8106. */
  8107. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8108. /**
  8109. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8110. * @param space The space that the rotation should be in
  8111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8112. * @param result The vector3 that the rotation should be copied to
  8113. */
  8114. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8115. /**
  8116. * Get the quaternion rotation of the bone in either local or world space
  8117. * @param space The space that the rotation should be in
  8118. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8119. * @returns The quaternion rotation
  8120. */
  8121. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8122. /**
  8123. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8124. * @param space The space that the rotation should be in
  8125. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8126. * @param result The quaternion that the rotation should be copied to
  8127. */
  8128. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8129. /**
  8130. * Get the rotation matrix of the bone in local or world space
  8131. * @param space The space that the rotation should be in
  8132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8133. * @returns The rotation matrix
  8134. */
  8135. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8136. /**
  8137. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8138. * @param space The space that the rotation should be in
  8139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8140. * @param result The quaternion that the rotation should be copied to
  8141. */
  8142. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8143. /**
  8144. * Get the world position of a point that is in the local space of the bone
  8145. * @param position The local position
  8146. * @param mesh The mesh that this bone is attached to
  8147. * @returns The world position
  8148. */
  8149. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8150. /**
  8151. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8152. * @param position The local position
  8153. * @param mesh The mesh that this bone is attached to
  8154. * @param result The vector3 that the world position should be copied to
  8155. */
  8156. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8157. /**
  8158. * Get the local position of a point that is in world space
  8159. * @param position The world position
  8160. * @param mesh The mesh that this bone is attached to
  8161. * @returns The local position
  8162. */
  8163. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8164. /**
  8165. * Get the local position of a point that is in world space and copy it to the result param
  8166. * @param position The world position
  8167. * @param mesh The mesh that this bone is attached to
  8168. * @param result The vector3 that the local position should be copied to
  8169. */
  8170. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8171. }
  8172. }
  8173. declare module BABYLON {
  8174. /**
  8175. * Enum that determines the text-wrapping mode to use.
  8176. */
  8177. export enum InspectableType {
  8178. /**
  8179. * Checkbox for booleans
  8180. */
  8181. Checkbox = 0,
  8182. /**
  8183. * Sliders for numbers
  8184. */
  8185. Slider = 1,
  8186. /**
  8187. * Vector3
  8188. */
  8189. Vector3 = 2,
  8190. /**
  8191. * Quaternions
  8192. */
  8193. Quaternion = 3,
  8194. /**
  8195. * Color3
  8196. */
  8197. Color3 = 4
  8198. }
  8199. /**
  8200. * Interface used to define custom inspectable properties.
  8201. * This interface is used by the inspector to display custom property grids
  8202. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8203. */
  8204. export interface IInspectable {
  8205. /**
  8206. * Gets the label to display
  8207. */
  8208. label: string;
  8209. /**
  8210. * Gets the name of the property to edit
  8211. */
  8212. propertyName: string;
  8213. /**
  8214. * Gets the type of the editor to use
  8215. */
  8216. type: InspectableType;
  8217. /**
  8218. * Gets the minimum value of the property when using in "slider" mode
  8219. */
  8220. min?: number;
  8221. /**
  8222. * Gets the maximum value of the property when using in "slider" mode
  8223. */
  8224. max?: number;
  8225. /**
  8226. * Gets the setp to use when using in "slider" mode
  8227. */
  8228. step?: number;
  8229. }
  8230. }
  8231. declare module BABYLON {
  8232. /**
  8233. * Class for creating a cube texture
  8234. */
  8235. export class CubeTexture extends BaseTexture {
  8236. private _delayedOnLoad;
  8237. /**
  8238. * The url of the texture
  8239. */
  8240. url: string;
  8241. /**
  8242. * Gets or sets the center of the bounding box associated with the cube texture.
  8243. * It must define where the camera used to render the texture was set
  8244. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8245. */
  8246. boundingBoxPosition: Vector3;
  8247. private _boundingBoxSize;
  8248. /**
  8249. * Gets or sets the size of the bounding box associated with the cube texture
  8250. * When defined, the cubemap will switch to local mode
  8251. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8252. * @example https://www.babylonjs-playground.com/#RNASML
  8253. */
  8254. /**
  8255. * Returns the bounding box size
  8256. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8257. */
  8258. boundingBoxSize: Vector3;
  8259. protected _rotationY: number;
  8260. /**
  8261. * Sets texture matrix rotation angle around Y axis in radians.
  8262. */
  8263. /**
  8264. * Gets texture matrix rotation angle around Y axis radians.
  8265. */
  8266. rotationY: number;
  8267. /**
  8268. * Are mip maps generated for this texture or not.
  8269. */
  8270. readonly noMipmap: boolean;
  8271. private _noMipmap;
  8272. private _files;
  8273. private _extensions;
  8274. private _textureMatrix;
  8275. private _format;
  8276. private _createPolynomials;
  8277. /** @hidden */ prefiltered: boolean;
  8278. /**
  8279. * Creates a cube texture from an array of image urls
  8280. * @param files defines an array of image urls
  8281. * @param scene defines the hosting scene
  8282. * @param noMipmap specifies if mip maps are not used
  8283. * @returns a cube texture
  8284. */
  8285. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8286. /**
  8287. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8288. * @param url defines the url of the prefiltered texture
  8289. * @param scene defines the scene the texture is attached to
  8290. * @param forcedExtension defines the extension of the file if different from the url
  8291. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8292. * @return the prefiltered texture
  8293. */
  8294. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8295. /**
  8296. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8297. * as prefiltered data.
  8298. * @param rootUrl defines the url of the texture or the root name of the six images
  8299. * @param scene defines the scene the texture is attached to
  8300. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8301. * @param noMipmap defines if mipmaps should be created or not
  8302. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8303. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8304. * @param onError defines a callback triggered in case of error during load
  8305. * @param format defines the internal format to use for the texture once loaded
  8306. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8307. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8308. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8309. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8310. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8311. * @return the cube texture
  8312. */
  8313. 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);
  8314. /**
  8315. * Get the current class name of the texture useful for serialization or dynamic coding.
  8316. * @returns "CubeTexture"
  8317. */
  8318. getClassName(): string;
  8319. /**
  8320. * Update the url (and optional buffer) of this texture if url was null during construction.
  8321. * @param url the url of the texture
  8322. * @param forcedExtension defines the extension to use
  8323. * @param onLoad callback called when the texture is loaded (defaults to null)
  8324. */
  8325. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8326. /**
  8327. * Delays loading of the cube texture
  8328. * @param forcedExtension defines the extension to use
  8329. */
  8330. delayLoad(forcedExtension?: string): void;
  8331. /**
  8332. * Returns the reflection texture matrix
  8333. * @returns the reflection texture matrix
  8334. */
  8335. getReflectionTextureMatrix(): Matrix;
  8336. /**
  8337. * Sets the reflection texture matrix
  8338. * @param value Reflection texture matrix
  8339. */
  8340. setReflectionTextureMatrix(value: Matrix): void;
  8341. /**
  8342. * Parses text to create a cube texture
  8343. * @param parsedTexture define the serialized text to read from
  8344. * @param scene defines the hosting scene
  8345. * @param rootUrl defines the root url of the cube texture
  8346. * @returns a cube texture
  8347. */
  8348. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8349. /**
  8350. * Makes a clone, or deep copy, of the cube texture
  8351. * @returns a new cube texture
  8352. */
  8353. clone(): CubeTexture;
  8354. }
  8355. }
  8356. declare module BABYLON {
  8357. /** @hidden */
  8358. export var postprocessVertexShader: {
  8359. name: string;
  8360. shader: string;
  8361. };
  8362. }
  8363. declare module BABYLON {
  8364. /**
  8365. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8366. * This is the base of the follow, arc rotate cameras and Free camera
  8367. * @see http://doc.babylonjs.com/features/cameras
  8368. */
  8369. export class TargetCamera extends Camera {
  8370. private static _RigCamTransformMatrix;
  8371. private static _TargetTransformMatrix;
  8372. private static _TargetFocalPoint;
  8373. /**
  8374. * Define the current direction the camera is moving to
  8375. */
  8376. cameraDirection: Vector3;
  8377. /**
  8378. * Define the current rotation the camera is rotating to
  8379. */
  8380. cameraRotation: Vector2;
  8381. /**
  8382. * When set, the up vector of the camera will be updated by the rotation of the camera
  8383. */
  8384. updateUpVectorFromRotation: boolean;
  8385. private _tmpQuaternion;
  8386. /**
  8387. * Define the current rotation of the camera
  8388. */
  8389. rotation: Vector3;
  8390. /**
  8391. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8392. */
  8393. rotationQuaternion: Quaternion;
  8394. /**
  8395. * Define the current speed of the camera
  8396. */
  8397. speed: number;
  8398. /**
  8399. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8400. * around all axis.
  8401. */
  8402. noRotationConstraint: boolean;
  8403. /**
  8404. * Define the current target of the camera as an object or a position.
  8405. */
  8406. lockedTarget: any;
  8407. /** @hidden */ currentTarget: Vector3;
  8408. /** @hidden */ initialFocalDistance: number;
  8409. /** @hidden */ viewMatrix: Matrix;
  8410. /** @hidden */ camMatrix: Matrix;
  8411. /** @hidden */ cameraTransformMatrix: Matrix;
  8412. /** @hidden */ cameraRotationMatrix: Matrix;
  8413. /** @hidden */ referencePoint: Vector3;
  8414. /** @hidden */ transformedReferencePoint: Vector3;
  8415. protected _globalCurrentTarget: Vector3;
  8416. protected _globalCurrentUpVector: Vector3;
  8417. /** @hidden */ reset: () => void;
  8418. private _defaultUp;
  8419. /**
  8420. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8421. * This is the base of the follow, arc rotate cameras and Free camera
  8422. * @see http://doc.babylonjs.com/features/cameras
  8423. * @param name Defines the name of the camera in the scene
  8424. * @param position Defines the start position of the camera in the scene
  8425. * @param scene Defines the scene the camera belongs to
  8426. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8427. */
  8428. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8429. /**
  8430. * Gets the position in front of the camera at a given distance.
  8431. * @param distance The distance from the camera we want the position to be
  8432. * @returns the position
  8433. */
  8434. getFrontPosition(distance: number): Vector3;
  8435. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  8436. private _storedPosition;
  8437. private _storedRotation;
  8438. private _storedRotationQuaternion;
  8439. /**
  8440. * Store current camera state of the camera (fov, position, rotation, etc..)
  8441. * @returns the camera
  8442. */
  8443. storeState(): Camera;
  8444. /**
  8445. * Restored camera state. You must call storeState() first
  8446. * @returns whether it was successful or not
  8447. * @hidden
  8448. */ restoreStateValues(): boolean;
  8449. /** @hidden */ initCache(): void;
  8450. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  8451. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  8452. /** @hidden */ computeLocalCameraSpeed(): number;
  8453. /**
  8454. * Defines the target the camera should look at.
  8455. * This will automatically adapt alpha beta and radius to fit within the new target.
  8456. * @param target Defines the new target as a Vector or a mesh
  8457. */
  8458. setTarget(target: Vector3): void;
  8459. /**
  8460. * Return the current target position of the camera. This value is expressed in local space.
  8461. * @returns the target position
  8462. */
  8463. getTarget(): Vector3;
  8464. /** @hidden */ decideIfNeedsToMove(): boolean;
  8465. /** @hidden */ updatePosition(): void;
  8466. /** @hidden */ checkInputs(): void;
  8467. protected _updateCameraRotationMatrix(): void;
  8468. /**
  8469. * 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)
  8470. * @returns the current camera
  8471. */
  8472. private _rotateUpVectorWithCameraRotationMatrix;
  8473. private _cachedRotationZ;
  8474. private _cachedQuaternionRotationZ;
  8475. /** @hidden */ getViewMatrix(): Matrix;
  8476. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8477. /**
  8478. * @hidden
  8479. */
  8480. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8481. /**
  8482. * @hidden
  8483. */ updateRigCameras(): void;
  8484. private _getRigCamPositionAndTarget;
  8485. /**
  8486. * Gets the current object class name.
  8487. * @return the class name
  8488. */
  8489. getClassName(): string;
  8490. }
  8491. }
  8492. declare module BABYLON {
  8493. /**
  8494. * @ignore
  8495. * This is a list of all the different input types that are available in the application.
  8496. * Fo instance: ArcRotateCameraGamepadInput...
  8497. */
  8498. export var CameraInputTypes: {};
  8499. /**
  8500. * This is the contract to implement in order to create a new input class.
  8501. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8502. */
  8503. export interface ICameraInput<TCamera extends Camera> {
  8504. /**
  8505. * Defines the camera the input is attached to.
  8506. */
  8507. camera: Nullable<TCamera>;
  8508. /**
  8509. * Gets the class name of the current intput.
  8510. * @returns the class name
  8511. */
  8512. getClassName(): string;
  8513. /**
  8514. * Get the friendly name associated with the input class.
  8515. * @returns the input friendly name
  8516. */
  8517. getSimpleName(): string;
  8518. /**
  8519. * Attach the input controls to a specific dom element to get the input from.
  8520. * @param element Defines the element the controls should be listened from
  8521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8522. */
  8523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8524. /**
  8525. * Detach the current controls from the specified dom element.
  8526. * @param element Defines the element to stop listening the inputs from
  8527. */
  8528. detachControl(element: Nullable<HTMLElement>): void;
  8529. /**
  8530. * Update the current camera state depending on the inputs that have been used this frame.
  8531. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8532. */
  8533. checkInputs?: () => void;
  8534. }
  8535. /**
  8536. * Represents a map of input types to input instance or input index to input instance.
  8537. */
  8538. export interface CameraInputsMap<TCamera extends Camera> {
  8539. /**
  8540. * Accessor to the input by input type.
  8541. */
  8542. [name: string]: ICameraInput<TCamera>;
  8543. /**
  8544. * Accessor to the input by input index.
  8545. */
  8546. [idx: number]: ICameraInput<TCamera>;
  8547. }
  8548. /**
  8549. * This represents the input manager used within a camera.
  8550. * It helps dealing with all the different kind of input attached to a camera.
  8551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8552. */
  8553. export class CameraInputsManager<TCamera extends Camera> {
  8554. /**
  8555. * Defines the list of inputs attahed to the camera.
  8556. */
  8557. attached: CameraInputsMap<TCamera>;
  8558. /**
  8559. * Defines the dom element the camera is collecting inputs from.
  8560. * This is null if the controls have not been attached.
  8561. */
  8562. attachedElement: Nullable<HTMLElement>;
  8563. /**
  8564. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8565. */
  8566. noPreventDefault: boolean;
  8567. /**
  8568. * Defined the camera the input manager belongs to.
  8569. */
  8570. camera: TCamera;
  8571. /**
  8572. * Update the current camera state depending on the inputs that have been used this frame.
  8573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8574. */
  8575. checkInputs: () => void;
  8576. /**
  8577. * Instantiate a new Camera Input Manager.
  8578. * @param camera Defines the camera the input manager blongs to
  8579. */
  8580. constructor(camera: TCamera);
  8581. /**
  8582. * Add an input method to a camera
  8583. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8584. * @param input camera input method
  8585. */
  8586. add(input: ICameraInput<TCamera>): void;
  8587. /**
  8588. * Remove a specific input method from a camera
  8589. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8590. * @param inputToRemove camera input method
  8591. */
  8592. remove(inputToRemove: ICameraInput<TCamera>): void;
  8593. /**
  8594. * Remove a specific input type from a camera
  8595. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8596. * @param inputType the type of the input to remove
  8597. */
  8598. removeByType(inputType: string): void;
  8599. private _addCheckInputs;
  8600. /**
  8601. * Attach the input controls to the currently attached dom element to listen the events from.
  8602. * @param input Defines the input to attach
  8603. */
  8604. attachInput(input: ICameraInput<TCamera>): void;
  8605. /**
  8606. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8607. * @param element Defines the dom element to collect the events from
  8608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8609. */
  8610. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8611. /**
  8612. * Detach the current manager inputs controls from a specific dom element.
  8613. * @param element Defines the dom element to collect the events from
  8614. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8615. */
  8616. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8617. /**
  8618. * Rebuild the dynamic inputCheck function from the current list of
  8619. * defined inputs in the manager.
  8620. */
  8621. rebuildInputCheck(): void;
  8622. /**
  8623. * Remove all attached input methods from a camera
  8624. */
  8625. clear(): void;
  8626. /**
  8627. * Serialize the current input manager attached to a camera.
  8628. * This ensures than once parsed,
  8629. * the input associated to the camera will be identical to the current ones
  8630. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8631. */
  8632. serialize(serializedCamera: any): void;
  8633. /**
  8634. * Parses an input manager serialized JSON to restore the previous list of inputs
  8635. * and states associated to a camera.
  8636. * @param parsedCamera Defines the JSON to parse
  8637. */
  8638. parse(parsedCamera: any): void;
  8639. }
  8640. }
  8641. declare module BABYLON {
  8642. /**
  8643. * Gather the list of keyboard event types as constants.
  8644. */
  8645. export class KeyboardEventTypes {
  8646. /**
  8647. * The keydown event is fired when a key becomes active (pressed).
  8648. */
  8649. static readonly KEYDOWN: number;
  8650. /**
  8651. * The keyup event is fired when a key has been released.
  8652. */
  8653. static readonly KEYUP: number;
  8654. }
  8655. /**
  8656. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8657. */
  8658. export class KeyboardInfo {
  8659. /**
  8660. * Defines the type of event (KeyboardEventTypes)
  8661. */
  8662. type: number;
  8663. /**
  8664. * Defines the related dom event
  8665. */
  8666. event: KeyboardEvent;
  8667. /**
  8668. * Instantiates a new keyboard info.
  8669. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8670. * @param type Defines the type of event (KeyboardEventTypes)
  8671. * @param event Defines the related dom event
  8672. */
  8673. constructor(
  8674. /**
  8675. * Defines the type of event (KeyboardEventTypes)
  8676. */
  8677. type: number,
  8678. /**
  8679. * Defines the related dom event
  8680. */
  8681. event: KeyboardEvent);
  8682. }
  8683. /**
  8684. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8685. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8686. */
  8687. export class KeyboardInfoPre extends KeyboardInfo {
  8688. /**
  8689. * Defines the type of event (KeyboardEventTypes)
  8690. */
  8691. type: number;
  8692. /**
  8693. * Defines the related dom event
  8694. */
  8695. event: KeyboardEvent;
  8696. /**
  8697. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8698. */
  8699. skipOnPointerObservable: boolean;
  8700. /**
  8701. * Instantiates a new keyboard pre info.
  8702. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8703. * @param type Defines the type of event (KeyboardEventTypes)
  8704. * @param event Defines the related dom event
  8705. */
  8706. constructor(
  8707. /**
  8708. * Defines the type of event (KeyboardEventTypes)
  8709. */
  8710. type: number,
  8711. /**
  8712. * Defines the related dom event
  8713. */
  8714. event: KeyboardEvent);
  8715. }
  8716. }
  8717. declare module BABYLON {
  8718. /**
  8719. * Manage the keyboard inputs to control the movement of a free camera.
  8720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8721. */
  8722. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8723. /**
  8724. * Defines the camera the input is attached to.
  8725. */
  8726. camera: FreeCamera;
  8727. /**
  8728. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8729. */
  8730. keysUp: number[];
  8731. /**
  8732. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8733. */
  8734. keysDown: number[];
  8735. /**
  8736. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8737. */
  8738. keysLeft: number[];
  8739. /**
  8740. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8741. */
  8742. keysRight: number[];
  8743. private _keys;
  8744. private _onCanvasBlurObserver;
  8745. private _onKeyboardObserver;
  8746. private _engine;
  8747. private _scene;
  8748. /**
  8749. * Attach the input controls to a specific dom element to get the input from.
  8750. * @param element Defines the element the controls should be listened from
  8751. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8752. */
  8753. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8754. /**
  8755. * Detach the current controls from the specified dom element.
  8756. * @param element Defines the element to stop listening the inputs from
  8757. */
  8758. detachControl(element: Nullable<HTMLElement>): void;
  8759. /**
  8760. * Update the current camera state depending on the inputs that have been used this frame.
  8761. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8762. */
  8763. checkInputs(): void;
  8764. /**
  8765. * Gets the class name of the current intput.
  8766. * @returns the class name
  8767. */
  8768. getClassName(): string;
  8769. /** @hidden */ onLostFocus(): void;
  8770. /**
  8771. * Get the friendly name associated with the input class.
  8772. * @returns the input friendly name
  8773. */
  8774. getSimpleName(): string;
  8775. }
  8776. }
  8777. declare module BABYLON {
  8778. /**
  8779. * Interface describing all the common properties and methods a shadow light needs to implement.
  8780. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8781. * as well as binding the different shadow properties to the effects.
  8782. */
  8783. export interface IShadowLight extends Light {
  8784. /**
  8785. * The light id in the scene (used in scene.findLighById for instance)
  8786. */
  8787. id: string;
  8788. /**
  8789. * The position the shdow will be casted from.
  8790. */
  8791. position: Vector3;
  8792. /**
  8793. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8794. */
  8795. direction: Vector3;
  8796. /**
  8797. * The transformed position. Position of the light in world space taking parenting in account.
  8798. */
  8799. transformedPosition: Vector3;
  8800. /**
  8801. * The transformed direction. Direction of the light in world space taking parenting in account.
  8802. */
  8803. transformedDirection: Vector3;
  8804. /**
  8805. * The friendly name of the light in the scene.
  8806. */
  8807. name: string;
  8808. /**
  8809. * Defines the shadow projection clipping minimum z value.
  8810. */
  8811. shadowMinZ: number;
  8812. /**
  8813. * Defines the shadow projection clipping maximum z value.
  8814. */
  8815. shadowMaxZ: number;
  8816. /**
  8817. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8818. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8819. */
  8820. computeTransformedInformation(): boolean;
  8821. /**
  8822. * Gets the scene the light belongs to.
  8823. * @returns The scene
  8824. */
  8825. getScene(): Scene;
  8826. /**
  8827. * Callback defining a custom Projection Matrix Builder.
  8828. * This can be used to override the default projection matrix computation.
  8829. */
  8830. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8831. /**
  8832. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8833. * @param matrix The materix to updated with the projection information
  8834. * @param viewMatrix The transform matrix of the light
  8835. * @param renderList The list of mesh to render in the map
  8836. * @returns The current light
  8837. */
  8838. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8839. /**
  8840. * Gets the current depth scale used in ESM.
  8841. * @returns The scale
  8842. */
  8843. getDepthScale(): number;
  8844. /**
  8845. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8846. * @returns true if a cube texture needs to be use
  8847. */
  8848. needCube(): boolean;
  8849. /**
  8850. * Detects if the projection matrix requires to be recomputed this frame.
  8851. * @returns true if it requires to be recomputed otherwise, false.
  8852. */
  8853. needProjectionMatrixCompute(): boolean;
  8854. /**
  8855. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8856. */
  8857. forceProjectionMatrixCompute(): void;
  8858. /**
  8859. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8860. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8861. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8862. */
  8863. getShadowDirection(faceIndex?: number): Vector3;
  8864. /**
  8865. * Gets the minZ used for shadow according to both the scene and the light.
  8866. * @param activeCamera The camera we are returning the min for
  8867. * @returns the depth min z
  8868. */
  8869. getDepthMinZ(activeCamera: Camera): number;
  8870. /**
  8871. * Gets the maxZ used for shadow according to both the scene and the light.
  8872. * @param activeCamera The camera we are returning the max for
  8873. * @returns the depth max z
  8874. */
  8875. getDepthMaxZ(activeCamera: Camera): number;
  8876. }
  8877. /**
  8878. * Base implementation IShadowLight
  8879. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8880. */
  8881. export abstract class ShadowLight extends Light implements IShadowLight {
  8882. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8883. protected _position: Vector3;
  8884. protected _setPosition(value: Vector3): void;
  8885. /**
  8886. * Sets the position the shadow will be casted from. Also use as the light position for both
  8887. * point and spot lights.
  8888. */
  8889. /**
  8890. * Sets the position the shadow will be casted from. Also use as the light position for both
  8891. * point and spot lights.
  8892. */
  8893. position: Vector3;
  8894. protected _direction: Vector3;
  8895. protected _setDirection(value: Vector3): void;
  8896. /**
  8897. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8898. * Also use as the light direction on spot and directional lights.
  8899. */
  8900. /**
  8901. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8902. * Also use as the light direction on spot and directional lights.
  8903. */
  8904. direction: Vector3;
  8905. private _shadowMinZ;
  8906. /**
  8907. * Gets the shadow projection clipping minimum z value.
  8908. */
  8909. /**
  8910. * Sets the shadow projection clipping minimum z value.
  8911. */
  8912. shadowMinZ: number;
  8913. private _shadowMaxZ;
  8914. /**
  8915. * Sets the shadow projection clipping maximum z value.
  8916. */
  8917. /**
  8918. * Gets the shadow projection clipping maximum z value.
  8919. */
  8920. shadowMaxZ: number;
  8921. /**
  8922. * Callback defining a custom Projection Matrix Builder.
  8923. * This can be used to override the default projection matrix computation.
  8924. */
  8925. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8926. /**
  8927. * The transformed position. Position of the light in world space taking parenting in account.
  8928. */
  8929. transformedPosition: Vector3;
  8930. /**
  8931. * The transformed direction. Direction of the light in world space taking parenting in account.
  8932. */
  8933. transformedDirection: Vector3;
  8934. private _needProjectionMatrixCompute;
  8935. /**
  8936. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8937. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8938. */
  8939. computeTransformedInformation(): boolean;
  8940. /**
  8941. * Return the depth scale used for the shadow map.
  8942. * @returns the depth scale.
  8943. */
  8944. getDepthScale(): number;
  8945. /**
  8946. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8947. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8948. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8949. */
  8950. getShadowDirection(faceIndex?: number): Vector3;
  8951. /**
  8952. * Returns the ShadowLight absolute position in the World.
  8953. * @returns the position vector in world space
  8954. */
  8955. getAbsolutePosition(): Vector3;
  8956. /**
  8957. * Sets the ShadowLight direction toward the passed target.
  8958. * @param target The point to target in local space
  8959. * @returns the updated ShadowLight direction
  8960. */
  8961. setDirectionToTarget(target: Vector3): Vector3;
  8962. /**
  8963. * Returns the light rotation in euler definition.
  8964. * @returns the x y z rotation in local space.
  8965. */
  8966. getRotation(): Vector3;
  8967. /**
  8968. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8969. * @returns true if a cube texture needs to be use
  8970. */
  8971. needCube(): boolean;
  8972. /**
  8973. * Detects if the projection matrix requires to be recomputed this frame.
  8974. * @returns true if it requires to be recomputed otherwise, false.
  8975. */
  8976. needProjectionMatrixCompute(): boolean;
  8977. /**
  8978. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8979. */
  8980. forceProjectionMatrixCompute(): void;
  8981. /** @hidden */ initCache(): void;
  8982. /** @hidden */ isSynchronized(): boolean;
  8983. /**
  8984. * Computes the world matrix of the node
  8985. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8986. * @returns the world matrix
  8987. */
  8988. computeWorldMatrix(force?: boolean): Matrix;
  8989. /**
  8990. * Gets the minZ used for shadow according to both the scene and the light.
  8991. * @param activeCamera The camera we are returning the min for
  8992. * @returns the depth min z
  8993. */
  8994. getDepthMinZ(activeCamera: Camera): number;
  8995. /**
  8996. * Gets the maxZ used for shadow according to both the scene and the light.
  8997. * @param activeCamera The camera we are returning the max for
  8998. * @returns the depth max z
  8999. */
  9000. getDepthMaxZ(activeCamera: Camera): number;
  9001. /**
  9002. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9003. * @param matrix The materix to updated with the projection information
  9004. * @param viewMatrix The transform matrix of the light
  9005. * @param renderList The list of mesh to render in the map
  9006. * @returns The current light
  9007. */
  9008. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9009. }
  9010. }
  9011. declare module BABYLON {
  9012. /**
  9013. * "Static Class" containing the most commonly used helper while dealing with material for
  9014. * rendering purpose.
  9015. *
  9016. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9017. *
  9018. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9019. */
  9020. export class MaterialHelper {
  9021. /**
  9022. * Bind the current view position to an effect.
  9023. * @param effect The effect to be bound
  9024. * @param scene The scene the eyes position is used from
  9025. */
  9026. static BindEyePosition(effect: Effect, scene: Scene): void;
  9027. /**
  9028. * Helps preparing the defines values about the UVs in used in the effect.
  9029. * UVs are shared as much as we can accross channels in the shaders.
  9030. * @param texture The texture we are preparing the UVs for
  9031. * @param defines The defines to update
  9032. * @param key The channel key "diffuse", "specular"... used in the shader
  9033. */
  9034. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9035. /**
  9036. * Binds a texture matrix value to its corrsponding uniform
  9037. * @param texture The texture to bind the matrix for
  9038. * @param uniformBuffer The uniform buffer receivin the data
  9039. * @param key The channel key "diffuse", "specular"... used in the shader
  9040. */
  9041. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9042. /**
  9043. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9044. * @param mesh defines the current mesh
  9045. * @param scene defines the current scene
  9046. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9047. * @param pointsCloud defines if point cloud rendering has to be turned on
  9048. * @param fogEnabled defines if fog has to be turned on
  9049. * @param alphaTest defines if alpha testing has to be turned on
  9050. * @param defines defines the current list of defines
  9051. */
  9052. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9053. /**
  9054. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9055. * @param scene defines the current scene
  9056. * @param engine defines the current engine
  9057. * @param defines specifies the list of active defines
  9058. * @param useInstances defines if instances have to be turned on
  9059. * @param useClipPlane defines if clip plane have to be turned on
  9060. */
  9061. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9062. /**
  9063. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9064. * @param mesh The mesh containing the geometry data we will draw
  9065. * @param defines The defines to update
  9066. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9067. * @param useBones Precise whether bones should be used or not (override mesh info)
  9068. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9069. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9070. * @returns false if defines are considered not dirty and have not been checked
  9071. */
  9072. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9073. /**
  9074. * Prepares the defines related to multiview
  9075. * @param scene The scene we are intending to draw
  9076. * @param defines The defines to update
  9077. */
  9078. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9079. /**
  9080. * Prepares the defines related to the light information passed in parameter
  9081. * @param scene The scene we are intending to draw
  9082. * @param mesh The mesh the effect is compiling for
  9083. * @param defines The defines to update
  9084. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9085. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9086. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9087. * @returns true if normals will be required for the rest of the effect
  9088. */
  9089. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9090. /**
  9091. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9092. * that won t be acctive due to defines being turned off.
  9093. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9094. * @param samplersList The samplers list
  9095. * @param defines The defines helping in the list generation
  9096. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9097. */
  9098. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9099. /**
  9100. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9101. * @param defines The defines to update while falling back
  9102. * @param fallbacks The authorized effect fallbacks
  9103. * @param maxSimultaneousLights The maximum number of lights allowed
  9104. * @param rank the current rank of the Effect
  9105. * @returns The newly affected rank
  9106. */
  9107. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9108. /**
  9109. * Prepares the list of attributes required for morph targets according to the effect defines.
  9110. * @param attribs The current list of supported attribs
  9111. * @param mesh The mesh to prepare the morph targets attributes for
  9112. * @param defines The current Defines of the effect
  9113. */
  9114. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9115. /**
  9116. * Prepares the list of attributes required for bones according to the effect defines.
  9117. * @param attribs The current list of supported attribs
  9118. * @param mesh The mesh to prepare the bones attributes for
  9119. * @param defines The current Defines of the effect
  9120. * @param fallbacks The current efffect fallback strategy
  9121. */
  9122. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9123. /**
  9124. * Prepares the list of attributes required for instances according to the effect defines.
  9125. * @param attribs The current list of supported attribs
  9126. * @param defines The current Defines of the effect
  9127. */
  9128. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9129. /**
  9130. * Binds the light shadow information to the effect for the given mesh.
  9131. * @param light The light containing the generator
  9132. * @param scene The scene the lights belongs to
  9133. * @param mesh The mesh we are binding the information to render
  9134. * @param lightIndex The light index in the effect used to render the mesh
  9135. * @param effect The effect we are binding the data to
  9136. */
  9137. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9138. /**
  9139. * Binds the light information to the effect.
  9140. * @param light The light containing the generator
  9141. * @param effect The effect we are binding the data to
  9142. * @param lightIndex The light index in the effect used to render
  9143. */
  9144. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9145. /**
  9146. * Binds the lights information from the scene to the effect for the given mesh.
  9147. * @param scene The scene the lights belongs to
  9148. * @param mesh The mesh we are binding the information to render
  9149. * @param effect The effect we are binding the data to
  9150. * @param defines The generated defines for the effect
  9151. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9152. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9153. */
  9154. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9155. private static _tempFogColor;
  9156. /**
  9157. * Binds the fog information from the scene to the effect for the given mesh.
  9158. * @param scene The scene the lights belongs to
  9159. * @param mesh The mesh we are binding the information to render
  9160. * @param effect The effect we are binding the data to
  9161. * @param linearSpace Defines if the fog effect is applied in linear space
  9162. */
  9163. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9164. /**
  9165. * Binds the bones information from the mesh to the effect.
  9166. * @param mesh The mesh we are binding the information to render
  9167. * @param effect The effect we are binding the data to
  9168. */
  9169. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9170. /**
  9171. * Binds the morph targets information from the mesh to the effect.
  9172. * @param abstractMesh The mesh we are binding the information to render
  9173. * @param effect The effect we are binding the data to
  9174. */
  9175. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9176. /**
  9177. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9178. * @param defines The generated defines used in the effect
  9179. * @param effect The effect we are binding the data to
  9180. * @param scene The scene we are willing to render with logarithmic scale for
  9181. */
  9182. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9183. /**
  9184. * Binds the clip plane information from the scene to the effect.
  9185. * @param scene The scene the clip plane information are extracted from
  9186. * @param effect The effect we are binding the data to
  9187. */
  9188. static BindClipPlane(effect: Effect, scene: Scene): void;
  9189. }
  9190. }
  9191. declare module BABYLON {
  9192. /** @hidden */
  9193. export var kernelBlurVaryingDeclaration: {
  9194. name: string;
  9195. shader: string;
  9196. };
  9197. }
  9198. declare module BABYLON {
  9199. /** @hidden */
  9200. export var kernelBlurFragment: {
  9201. name: string;
  9202. shader: string;
  9203. };
  9204. }
  9205. declare module BABYLON {
  9206. /** @hidden */
  9207. export var kernelBlurFragment2: {
  9208. name: string;
  9209. shader: string;
  9210. };
  9211. }
  9212. declare module BABYLON {
  9213. /** @hidden */
  9214. export var kernelBlurPixelShader: {
  9215. name: string;
  9216. shader: string;
  9217. };
  9218. }
  9219. declare module BABYLON {
  9220. /** @hidden */
  9221. export var kernelBlurVertex: {
  9222. name: string;
  9223. shader: string;
  9224. };
  9225. }
  9226. declare module BABYLON {
  9227. /** @hidden */
  9228. export var kernelBlurVertexShader: {
  9229. name: string;
  9230. shader: string;
  9231. };
  9232. }
  9233. declare module BABYLON {
  9234. /**
  9235. * The Blur Post Process which blurs an image based on a kernel and direction.
  9236. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9237. */
  9238. export class BlurPostProcess extends PostProcess {
  9239. /** The direction in which to blur the image. */
  9240. direction: Vector2;
  9241. private blockCompilation;
  9242. protected _kernel: number;
  9243. protected _idealKernel: number;
  9244. protected _packedFloat: boolean;
  9245. private _staticDefines;
  9246. /**
  9247. * Sets the length in pixels of the blur sample region
  9248. */
  9249. /**
  9250. * Gets the length in pixels of the blur sample region
  9251. */
  9252. kernel: number;
  9253. /**
  9254. * Sets wether or not the blur needs to unpack/repack floats
  9255. */
  9256. /**
  9257. * Gets wether or not the blur is unpacking/repacking floats
  9258. */
  9259. packedFloat: boolean;
  9260. /**
  9261. * Creates a new instance BlurPostProcess
  9262. * @param name The name of the effect.
  9263. * @param direction The direction in which to blur the image.
  9264. * @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.
  9265. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9266. * @param camera The camera to apply the render pass to.
  9267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9268. * @param engine The engine which the post process will be applied. (default: current engine)
  9269. * @param reusable If the post process can be reused on the same frame. (default: false)
  9270. * @param textureType Type of textures used when performing the post process. (default: 0)
  9271. * @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)
  9272. */
  9273. constructor(name: string,
  9274. /** The direction in which to blur the image. */
  9275. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9276. /**
  9277. * Updates the effect with the current post process compile time values and recompiles the shader.
  9278. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9279. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9280. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9281. * @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
  9282. * @param onCompiled Called when the shader has been compiled.
  9283. * @param onError Called if there is an error when compiling a shader.
  9284. */
  9285. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9286. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9287. /**
  9288. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9289. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9290. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9291. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9292. * The gaps between physical kernels are compensated for in the weighting of the samples
  9293. * @param idealKernel Ideal blur kernel.
  9294. * @return Nearest best kernel.
  9295. */
  9296. protected _nearestBestKernel(idealKernel: number): number;
  9297. /**
  9298. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9299. * @param x The point on the Gaussian distribution to sample.
  9300. * @return the value of the Gaussian function at x.
  9301. */
  9302. protected _gaussianWeight(x: number): number;
  9303. /**
  9304. * Generates a string that can be used as a floating point number in GLSL.
  9305. * @param x Value to print.
  9306. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9307. * @return GLSL float string.
  9308. */
  9309. protected _glslFloat(x: number, decimalFigures?: number): string;
  9310. }
  9311. }
  9312. declare module BABYLON {
  9313. /** @hidden */
  9314. export var shadowMapPixelShader: {
  9315. name: string;
  9316. shader: string;
  9317. };
  9318. }
  9319. declare module BABYLON {
  9320. /** @hidden */
  9321. export var bonesDeclaration: {
  9322. name: string;
  9323. shader: string;
  9324. };
  9325. }
  9326. declare module BABYLON {
  9327. /** @hidden */
  9328. export var morphTargetsVertexGlobalDeclaration: {
  9329. name: string;
  9330. shader: string;
  9331. };
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var morphTargetsVertexDeclaration: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var instancesDeclaration: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var helperFunctions: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var morphTargetsVertex: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var instancesVertex: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var bonesVertex: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var shadowMapVertexShader: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var depthBoxBlurPixelShader: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /**
  9391. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9392. */
  9393. export interface ICustomShaderOptions {
  9394. /**
  9395. * Gets or sets the custom shader name to use
  9396. */
  9397. shaderName: string;
  9398. /**
  9399. * The list of attribute names used in the shader
  9400. */
  9401. attributes?: string[];
  9402. /**
  9403. * The list of unifrom names used in the shader
  9404. */
  9405. uniforms?: string[];
  9406. /**
  9407. * The list of sampler names used in the shader
  9408. */
  9409. samplers?: string[];
  9410. /**
  9411. * The list of defines used in the shader
  9412. */
  9413. defines?: string[];
  9414. }
  9415. /**
  9416. * Interface to implement to create a shadow generator compatible with BJS.
  9417. */
  9418. export interface IShadowGenerator {
  9419. /**
  9420. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9421. * @returns The render target texture if present otherwise, null
  9422. */
  9423. getShadowMap(): Nullable<RenderTargetTexture>;
  9424. /**
  9425. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9426. * @returns The render target texture if the shadow map is present otherwise, null
  9427. */
  9428. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9429. /**
  9430. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9431. * @param subMesh The submesh we want to render in the shadow map
  9432. * @param useInstances Defines wether will draw in the map using instances
  9433. * @returns true if ready otherwise, false
  9434. */
  9435. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9436. /**
  9437. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9438. * @param defines Defines of the material we want to update
  9439. * @param lightIndex Index of the light in the enabled light list of the material
  9440. */
  9441. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9442. /**
  9443. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9444. * defined in the generator but impacting the effect).
  9445. * It implies the unifroms available on the materials are the standard BJS ones.
  9446. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9447. * @param effect The effect we are binfing the information for
  9448. */
  9449. bindShadowLight(lightIndex: string, effect: Effect): void;
  9450. /**
  9451. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9452. * (eq to shadow prjection matrix * light transform matrix)
  9453. * @returns The transform matrix used to create the shadow map
  9454. */
  9455. getTransformMatrix(): Matrix;
  9456. /**
  9457. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9458. * Cube and 2D textures for instance.
  9459. */
  9460. recreateShadowMap(): void;
  9461. /**
  9462. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9463. * @param onCompiled Callback triggered at the and of the effects compilation
  9464. * @param options Sets of optional options forcing the compilation with different modes
  9465. */
  9466. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9467. useInstances: boolean;
  9468. }>): void;
  9469. /**
  9470. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9471. * @param options Sets of optional options forcing the compilation with different modes
  9472. * @returns A promise that resolves when the compilation completes
  9473. */
  9474. forceCompilationAsync(options?: Partial<{
  9475. useInstances: boolean;
  9476. }>): Promise<void>;
  9477. /**
  9478. * Serializes the shadow generator setup to a json object.
  9479. * @returns The serialized JSON object
  9480. */
  9481. serialize(): any;
  9482. /**
  9483. * Disposes the Shadow map and related Textures and effects.
  9484. */
  9485. dispose(): void;
  9486. }
  9487. /**
  9488. * Default implementation IShadowGenerator.
  9489. * This is the main object responsible of generating shadows in the framework.
  9490. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9491. */
  9492. export class ShadowGenerator implements IShadowGenerator {
  9493. /**
  9494. * Shadow generator mode None: no filtering applied.
  9495. */
  9496. static readonly FILTER_NONE: number;
  9497. /**
  9498. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9499. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9500. */
  9501. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9502. /**
  9503. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9504. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9505. */
  9506. static readonly FILTER_POISSONSAMPLING: number;
  9507. /**
  9508. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9509. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9510. */
  9511. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9512. /**
  9513. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9514. * edge artifacts on steep falloff.
  9515. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9516. */
  9517. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9518. /**
  9519. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9520. * edge artifacts on steep falloff.
  9521. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9522. */
  9523. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9524. /**
  9525. * Shadow generator mode PCF: Percentage Closer Filtering
  9526. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9527. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9528. */
  9529. static readonly FILTER_PCF: number;
  9530. /**
  9531. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9532. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9533. * Contact Hardening
  9534. */
  9535. static readonly FILTER_PCSS: number;
  9536. /**
  9537. * Reserved for PCF and PCSS
  9538. * Highest Quality.
  9539. *
  9540. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9541. *
  9542. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9543. */
  9544. static readonly QUALITY_HIGH: number;
  9545. /**
  9546. * Reserved for PCF and PCSS
  9547. * Good tradeoff for quality/perf cross devices
  9548. *
  9549. * Execute PCF on a 3*3 kernel.
  9550. *
  9551. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9552. */
  9553. static readonly QUALITY_MEDIUM: number;
  9554. /**
  9555. * Reserved for PCF and PCSS
  9556. * The lowest quality but the fastest.
  9557. *
  9558. * Execute PCF on a 1*1 kernel.
  9559. *
  9560. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9561. */
  9562. static readonly QUALITY_LOW: number;
  9563. /** Gets or sets the custom shader name to use */
  9564. customShaderOptions: ICustomShaderOptions;
  9565. /**
  9566. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9567. */
  9568. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9569. /**
  9570. * Observable triggered before a mesh is rendered in the shadow map.
  9571. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9572. */
  9573. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9574. private _bias;
  9575. /**
  9576. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9577. */
  9578. /**
  9579. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9580. */
  9581. bias: number;
  9582. private _normalBias;
  9583. /**
  9584. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9585. */
  9586. /**
  9587. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9588. */
  9589. normalBias: number;
  9590. private _blurBoxOffset;
  9591. /**
  9592. * Gets the blur box offset: offset applied during the blur pass.
  9593. * Only useful if useKernelBlur = false
  9594. */
  9595. /**
  9596. * Sets the blur box offset: offset applied during the blur pass.
  9597. * Only useful if useKernelBlur = false
  9598. */
  9599. blurBoxOffset: number;
  9600. private _blurScale;
  9601. /**
  9602. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9603. * 2 means half of the size.
  9604. */
  9605. /**
  9606. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9607. * 2 means half of the size.
  9608. */
  9609. blurScale: number;
  9610. private _blurKernel;
  9611. /**
  9612. * Gets the blur kernel: kernel size of the blur pass.
  9613. * Only useful if useKernelBlur = true
  9614. */
  9615. /**
  9616. * Sets the blur kernel: kernel size of the blur pass.
  9617. * Only useful if useKernelBlur = true
  9618. */
  9619. blurKernel: number;
  9620. private _useKernelBlur;
  9621. /**
  9622. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9623. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9624. */
  9625. /**
  9626. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9627. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9628. */
  9629. useKernelBlur: boolean;
  9630. private _depthScale;
  9631. /**
  9632. * Gets the depth scale used in ESM mode.
  9633. */
  9634. /**
  9635. * Sets the depth scale used in ESM mode.
  9636. * This can override the scale stored on the light.
  9637. */
  9638. depthScale: number;
  9639. private _filter;
  9640. /**
  9641. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9642. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9643. */
  9644. /**
  9645. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9646. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9647. */
  9648. filter: number;
  9649. /**
  9650. * Gets if the current filter is set to Poisson Sampling.
  9651. */
  9652. /**
  9653. * Sets the current filter to Poisson Sampling.
  9654. */
  9655. usePoissonSampling: boolean;
  9656. /**
  9657. * Gets if the current filter is set to ESM.
  9658. */
  9659. /**
  9660. * Sets the current filter is to ESM.
  9661. */
  9662. useExponentialShadowMap: boolean;
  9663. /**
  9664. * Gets if the current filter is set to filtered ESM.
  9665. */
  9666. /**
  9667. * Gets if the current filter is set to filtered ESM.
  9668. */
  9669. useBlurExponentialShadowMap: boolean;
  9670. /**
  9671. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9672. * exponential to prevent steep falloff artifacts).
  9673. */
  9674. /**
  9675. * Sets the current filter to "close ESM" (using the inverse of the
  9676. * exponential to prevent steep falloff artifacts).
  9677. */
  9678. useCloseExponentialShadowMap: boolean;
  9679. /**
  9680. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9681. * exponential to prevent steep falloff artifacts).
  9682. */
  9683. /**
  9684. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9685. * exponential to prevent steep falloff artifacts).
  9686. */
  9687. useBlurCloseExponentialShadowMap: boolean;
  9688. /**
  9689. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9690. */
  9691. /**
  9692. * Sets the current filter to "PCF" (percentage closer filtering).
  9693. */
  9694. usePercentageCloserFiltering: boolean;
  9695. private _filteringQuality;
  9696. /**
  9697. * Gets the PCF or PCSS Quality.
  9698. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9699. */
  9700. /**
  9701. * Sets the PCF or PCSS Quality.
  9702. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9703. */
  9704. filteringQuality: number;
  9705. /**
  9706. * Gets if the current filter is set to "PCSS" (contact hardening).
  9707. */
  9708. /**
  9709. * Sets the current filter to "PCSS" (contact hardening).
  9710. */
  9711. useContactHardeningShadow: boolean;
  9712. private _contactHardeningLightSizeUVRatio;
  9713. /**
  9714. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9715. * Using a ratio helps keeping shape stability independently of the map size.
  9716. *
  9717. * It does not account for the light projection as it was having too much
  9718. * instability during the light setup or during light position changes.
  9719. *
  9720. * Only valid if useContactHardeningShadow is true.
  9721. */
  9722. /**
  9723. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9724. * Using a ratio helps keeping shape stability independently of the map size.
  9725. *
  9726. * It does not account for the light projection as it was having too much
  9727. * instability during the light setup or during light position changes.
  9728. *
  9729. * Only valid if useContactHardeningShadow is true.
  9730. */
  9731. contactHardeningLightSizeUVRatio: number;
  9732. private _darkness;
  9733. /**
  9734. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9735. * 0 means strongest and 1 would means no shadow.
  9736. * @returns the darkness.
  9737. */
  9738. getDarkness(): number;
  9739. /**
  9740. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9741. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9742. * @returns the shadow generator allowing fluent coding.
  9743. */
  9744. setDarkness(darkness: number): ShadowGenerator;
  9745. private _transparencyShadow;
  9746. /**
  9747. * Sets the ability to have transparent shadow (boolean).
  9748. * @param transparent True if transparent else False
  9749. * @returns the shadow generator allowing fluent coding
  9750. */
  9751. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9752. private _shadowMap;
  9753. private _shadowMap2;
  9754. /**
  9755. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9756. * @returns The render target texture if present otherwise, null
  9757. */
  9758. getShadowMap(): Nullable<RenderTargetTexture>;
  9759. /**
  9760. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9761. * @returns The render target texture if the shadow map is present otherwise, null
  9762. */
  9763. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9764. /**
  9765. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9766. * @param mesh Mesh to add
  9767. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9768. * @returns the Shadow Generator itself
  9769. */
  9770. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9771. /**
  9772. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9773. * @param mesh Mesh to remove
  9774. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9775. * @returns the Shadow Generator itself
  9776. */
  9777. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9778. /**
  9779. * Controls the extent to which the shadows fade out at the edge of the frustum
  9780. * Used only by directionals and spots
  9781. */
  9782. frustumEdgeFalloff: number;
  9783. private _light;
  9784. /**
  9785. * Returns the associated light object.
  9786. * @returns the light generating the shadow
  9787. */
  9788. getLight(): IShadowLight;
  9789. /**
  9790. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9791. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9792. * It might on the other hand introduce peter panning.
  9793. */
  9794. forceBackFacesOnly: boolean;
  9795. private _scene;
  9796. private _lightDirection;
  9797. private _effect;
  9798. private _viewMatrix;
  9799. private _projectionMatrix;
  9800. private _transformMatrix;
  9801. private _cachedPosition;
  9802. private _cachedDirection;
  9803. private _cachedDefines;
  9804. private _currentRenderID;
  9805. private _boxBlurPostprocess;
  9806. private _kernelBlurXPostprocess;
  9807. private _kernelBlurYPostprocess;
  9808. private _blurPostProcesses;
  9809. private _mapSize;
  9810. private _currentFaceIndex;
  9811. private _currentFaceIndexCache;
  9812. private _textureType;
  9813. private _defaultTextureMatrix;
  9814. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9815. /**
  9816. * Creates a ShadowGenerator object.
  9817. * A ShadowGenerator is the required tool to use the shadows.
  9818. * Each light casting shadows needs to use its own ShadowGenerator.
  9819. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9820. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9821. * @param light The light object generating the shadows.
  9822. * @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.
  9823. */
  9824. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9825. private _initializeGenerator;
  9826. private _initializeShadowMap;
  9827. private _initializeBlurRTTAndPostProcesses;
  9828. private _renderForShadowMap;
  9829. private _renderSubMeshForShadowMap;
  9830. private _applyFilterValues;
  9831. /**
  9832. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9833. * @param onCompiled Callback triggered at the and of the effects compilation
  9834. * @param options Sets of optional options forcing the compilation with different modes
  9835. */
  9836. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9837. useInstances: boolean;
  9838. }>): void;
  9839. /**
  9840. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9841. * @param options Sets of optional options forcing the compilation with different modes
  9842. * @returns A promise that resolves when the compilation completes
  9843. */
  9844. forceCompilationAsync(options?: Partial<{
  9845. useInstances: boolean;
  9846. }>): Promise<void>;
  9847. /**
  9848. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9849. * @param subMesh The submesh we want to render in the shadow map
  9850. * @param useInstances Defines wether will draw in the map using instances
  9851. * @returns true if ready otherwise, false
  9852. */
  9853. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9854. /**
  9855. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9856. * @param defines Defines of the material we want to update
  9857. * @param lightIndex Index of the light in the enabled light list of the material
  9858. */
  9859. prepareDefines(defines: any, lightIndex: number): void;
  9860. /**
  9861. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9862. * defined in the generator but impacting the effect).
  9863. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9864. * @param effect The effect we are binfing the information for
  9865. */
  9866. bindShadowLight(lightIndex: string, effect: Effect): void;
  9867. /**
  9868. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9869. * (eq to shadow prjection matrix * light transform matrix)
  9870. * @returns The transform matrix used to create the shadow map
  9871. */
  9872. getTransformMatrix(): Matrix;
  9873. /**
  9874. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9875. * Cube and 2D textures for instance.
  9876. */
  9877. recreateShadowMap(): void;
  9878. private _disposeBlurPostProcesses;
  9879. private _disposeRTTandPostProcesses;
  9880. /**
  9881. * Disposes the ShadowGenerator.
  9882. * Returns nothing.
  9883. */
  9884. dispose(): void;
  9885. /**
  9886. * Serializes the shadow generator setup to a json object.
  9887. * @returns The serialized JSON object
  9888. */
  9889. serialize(): any;
  9890. /**
  9891. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9892. * @param parsedShadowGenerator The JSON object to parse
  9893. * @param scene The scene to create the shadow map for
  9894. * @returns The parsed shadow generator
  9895. */
  9896. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9897. }
  9898. }
  9899. declare module BABYLON {
  9900. /**
  9901. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9902. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9903. * 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.
  9904. */
  9905. export abstract class Light extends Node {
  9906. /**
  9907. * Falloff Default: light is falling off following the material specification:
  9908. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9909. */
  9910. static readonly FALLOFF_DEFAULT: number;
  9911. /**
  9912. * Falloff Physical: light is falling off following the inverse squared distance law.
  9913. */
  9914. static readonly FALLOFF_PHYSICAL: number;
  9915. /**
  9916. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9917. * to enhance interoperability with other engines.
  9918. */
  9919. static readonly FALLOFF_GLTF: number;
  9920. /**
  9921. * Falloff Standard: light is falling off like in the standard material
  9922. * to enhance interoperability with other materials.
  9923. */
  9924. static readonly FALLOFF_STANDARD: number;
  9925. /**
  9926. * If every light affecting the material is in this lightmapMode,
  9927. * material.lightmapTexture adds or multiplies
  9928. * (depends on material.useLightmapAsShadowmap)
  9929. * after every other light calculations.
  9930. */
  9931. static readonly LIGHTMAP_DEFAULT: number;
  9932. /**
  9933. * material.lightmapTexture as only diffuse lighting from this light
  9934. * adds only specular lighting from this light
  9935. * adds dynamic shadows
  9936. */
  9937. static readonly LIGHTMAP_SPECULAR: number;
  9938. /**
  9939. * material.lightmapTexture as only lighting
  9940. * no light calculation from this light
  9941. * only adds dynamic shadows from this light
  9942. */
  9943. static readonly LIGHTMAP_SHADOWSONLY: number;
  9944. /**
  9945. * Each light type uses the default quantity according to its type:
  9946. * point/spot lights use luminous intensity
  9947. * directional lights use illuminance
  9948. */
  9949. static readonly INTENSITYMODE_AUTOMATIC: number;
  9950. /**
  9951. * lumen (lm)
  9952. */
  9953. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9954. /**
  9955. * candela (lm/sr)
  9956. */
  9957. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9958. /**
  9959. * lux (lm/m^2)
  9960. */
  9961. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9962. /**
  9963. * nit (cd/m^2)
  9964. */
  9965. static readonly INTENSITYMODE_LUMINANCE: number;
  9966. /**
  9967. * Light type const id of the point light.
  9968. */
  9969. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9970. /**
  9971. * Light type const id of the directional light.
  9972. */
  9973. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9974. /**
  9975. * Light type const id of the spot light.
  9976. */
  9977. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9978. /**
  9979. * Light type const id of the hemispheric light.
  9980. */
  9981. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9982. /**
  9983. * Diffuse gives the basic color to an object.
  9984. */
  9985. diffuse: Color3;
  9986. /**
  9987. * Specular produces a highlight color on an object.
  9988. * Note: This is note affecting PBR materials.
  9989. */
  9990. specular: Color3;
  9991. /**
  9992. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9993. * falling off base on range or angle.
  9994. * This can be set to any values in Light.FALLOFF_x.
  9995. *
  9996. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9997. * other types of materials.
  9998. */
  9999. falloffType: number;
  10000. /**
  10001. * Strength of the light.
  10002. * Note: By default it is define in the framework own unit.
  10003. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10004. */
  10005. intensity: number;
  10006. private _range;
  10007. protected _inverseSquaredRange: number;
  10008. /**
  10009. * Defines how far from the source the light is impacting in scene units.
  10010. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10011. */
  10012. /**
  10013. * Defines how far from the source the light is impacting in scene units.
  10014. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10015. */
  10016. range: number;
  10017. /**
  10018. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10019. * of light.
  10020. */
  10021. private _photometricScale;
  10022. private _intensityMode;
  10023. /**
  10024. * Gets the photometric scale used to interpret the intensity.
  10025. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10026. */
  10027. /**
  10028. * Sets the photometric scale used to interpret the intensity.
  10029. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10030. */
  10031. intensityMode: number;
  10032. private _radius;
  10033. /**
  10034. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10035. */
  10036. /**
  10037. * sets the light radius used by PBR Materials to simulate soft area lights.
  10038. */
  10039. radius: number;
  10040. private _renderPriority;
  10041. /**
  10042. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10043. * exceeding the number allowed of the materials.
  10044. */
  10045. renderPriority: number;
  10046. private _shadowEnabled;
  10047. /**
  10048. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10049. * the current shadow generator.
  10050. */
  10051. /**
  10052. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10053. * the current shadow generator.
  10054. */
  10055. shadowEnabled: boolean;
  10056. private _includedOnlyMeshes;
  10057. /**
  10058. * Gets the only meshes impacted by this light.
  10059. */
  10060. /**
  10061. * Sets the only meshes impacted by this light.
  10062. */
  10063. includedOnlyMeshes: AbstractMesh[];
  10064. private _excludedMeshes;
  10065. /**
  10066. * Gets the meshes not impacted by this light.
  10067. */
  10068. /**
  10069. * Sets the meshes not impacted by this light.
  10070. */
  10071. excludedMeshes: AbstractMesh[];
  10072. private _excludeWithLayerMask;
  10073. /**
  10074. * Gets the layer id use to find what meshes are not impacted by the light.
  10075. * Inactive if 0
  10076. */
  10077. /**
  10078. * Sets the layer id use to find what meshes are not impacted by the light.
  10079. * Inactive if 0
  10080. */
  10081. excludeWithLayerMask: number;
  10082. private _includeOnlyWithLayerMask;
  10083. /**
  10084. * Gets the layer id use to find what meshes are impacted by the light.
  10085. * Inactive if 0
  10086. */
  10087. /**
  10088. * Sets the layer id use to find what meshes are impacted by the light.
  10089. * Inactive if 0
  10090. */
  10091. includeOnlyWithLayerMask: number;
  10092. private _lightmapMode;
  10093. /**
  10094. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10095. */
  10096. /**
  10097. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10098. */
  10099. lightmapMode: number;
  10100. /**
  10101. * Shadow generator associted to the light.
  10102. * @hidden Internal use only.
  10103. */ shadowGenerator: Nullable<IShadowGenerator>;
  10104. /**
  10105. * @hidden Internal use only.
  10106. */ excludedMeshesIds: string[];
  10107. /**
  10108. * @hidden Internal use only.
  10109. */ includedOnlyMeshesIds: string[];
  10110. /**
  10111. * The current light unifom buffer.
  10112. * @hidden Internal use only.
  10113. */ uniformBuffer: UniformBuffer;
  10114. /**
  10115. * Creates a Light object in the scene.
  10116. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10117. * @param name The firendly name of the light
  10118. * @param scene The scene the light belongs too
  10119. */
  10120. constructor(name: string, scene: Scene);
  10121. protected abstract _buildUniformLayout(): void;
  10122. /**
  10123. * Sets the passed Effect "effect" with the Light information.
  10124. * @param effect The effect to update
  10125. * @param lightIndex The index of the light in the effect to update
  10126. * @returns The light
  10127. */
  10128. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10129. /**
  10130. * Returns the string "Light".
  10131. * @returns the class name
  10132. */
  10133. getClassName(): string;
  10134. /** @hidden */ protected readonly _isLight: boolean;
  10135. /**
  10136. * Converts the light information to a readable string for debug purpose.
  10137. * @param fullDetails Supports for multiple levels of logging within scene loading
  10138. * @returns the human readable light info
  10139. */
  10140. toString(fullDetails?: boolean): string;
  10141. /** @hidden */
  10142. protected _syncParentEnabledState(): void;
  10143. /**
  10144. * Set the enabled state of this node.
  10145. * @param value - the new enabled state
  10146. */
  10147. setEnabled(value: boolean): void;
  10148. /**
  10149. * Returns the Light associated shadow generator if any.
  10150. * @return the associated shadow generator.
  10151. */
  10152. getShadowGenerator(): Nullable<IShadowGenerator>;
  10153. /**
  10154. * Returns a Vector3, the absolute light position in the World.
  10155. * @returns the world space position of the light
  10156. */
  10157. getAbsolutePosition(): Vector3;
  10158. /**
  10159. * Specifies if the light will affect the passed mesh.
  10160. * @param mesh The mesh to test against the light
  10161. * @return true the mesh is affected otherwise, false.
  10162. */
  10163. canAffectMesh(mesh: AbstractMesh): boolean;
  10164. /**
  10165. * Sort function to order lights for rendering.
  10166. * @param a First Light object to compare to second.
  10167. * @param b Second Light object to compare first.
  10168. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10169. */
  10170. static CompareLightsPriority(a: Light, b: Light): number;
  10171. /**
  10172. * Releases resources associated with this node.
  10173. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10174. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10175. */
  10176. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10177. /**
  10178. * Returns the light type ID (integer).
  10179. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10180. */
  10181. getTypeID(): number;
  10182. /**
  10183. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10184. * @returns the scaled intensity in intensity mode unit
  10185. */
  10186. getScaledIntensity(): number;
  10187. /**
  10188. * Returns a new Light object, named "name", from the current one.
  10189. * @param name The name of the cloned light
  10190. * @returns the new created light
  10191. */
  10192. clone(name: string): Nullable<Light>;
  10193. /**
  10194. * Serializes the current light into a Serialization object.
  10195. * @returns the serialized object.
  10196. */
  10197. serialize(): any;
  10198. /**
  10199. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10200. * This new light is named "name" and added to the passed scene.
  10201. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10202. * @param name The friendly name of the light
  10203. * @param scene The scene the new light will belong to
  10204. * @returns the constructor function
  10205. */
  10206. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10207. /**
  10208. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10209. * @param parsedLight The JSON representation of the light
  10210. * @param scene The scene to create the parsed light in
  10211. * @returns the created light after parsing
  10212. */
  10213. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10214. private _hookArrayForExcluded;
  10215. private _hookArrayForIncludedOnly;
  10216. private _resyncMeshes;
  10217. /**
  10218. * Forces the meshes to update their light related information in their rendering used effects
  10219. * @hidden Internal Use Only
  10220. */ markMeshesAsLightDirty(): void;
  10221. /**
  10222. * Recomputes the cached photometric scale if needed.
  10223. */
  10224. private _computePhotometricScale;
  10225. /**
  10226. * Returns the Photometric Scale according to the light type and intensity mode.
  10227. */
  10228. private _getPhotometricScale;
  10229. /**
  10230. * Reorder the light in the scene according to their defined priority.
  10231. * @hidden Internal Use Only
  10232. */ reorderLightsInScene(): void;
  10233. /**
  10234. * Prepares the list of defines specific to the light type.
  10235. * @param defines the list of defines
  10236. * @param lightIndex defines the index of the light for the effect
  10237. */
  10238. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10239. }
  10240. }
  10241. declare module BABYLON {
  10242. /**
  10243. * Interface used to define Action
  10244. */
  10245. export interface IAction {
  10246. /**
  10247. * Trigger for the action
  10248. */
  10249. trigger: number;
  10250. /** Options of the trigger */
  10251. triggerOptions: any;
  10252. /**
  10253. * Gets the trigger parameters
  10254. * @returns the trigger parameters
  10255. */
  10256. getTriggerParameter(): any;
  10257. /**
  10258. * Internal only - executes current action event
  10259. * @hidden
  10260. */ executeCurrent(evt?: ActionEvent): void;
  10261. /**
  10262. * Serialize placeholder for child classes
  10263. * @param parent of child
  10264. * @returns the serialized object
  10265. */
  10266. serialize(parent: any): any;
  10267. /**
  10268. * Internal only
  10269. * @hidden
  10270. */ prepare(): void;
  10271. /**
  10272. * Internal only - manager for action
  10273. * @hidden
  10274. */ actionManager: AbstractActionManager;
  10275. }
  10276. /**
  10277. * The action to be carried out following a trigger
  10278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10279. */
  10280. export class Action implements IAction {
  10281. /** the trigger, with or without parameters, for the action */
  10282. triggerOptions: any;
  10283. /**
  10284. * Trigger for the action
  10285. */
  10286. trigger: number;
  10287. /**
  10288. * Internal only - manager for action
  10289. * @hidden
  10290. */ actionManager: ActionManager;
  10291. private _nextActiveAction;
  10292. private _child;
  10293. private _condition?;
  10294. private _triggerParameter;
  10295. /**
  10296. * An event triggered prior to action being executed.
  10297. */
  10298. onBeforeExecuteObservable: Observable<Action>;
  10299. /**
  10300. * Creates a new Action
  10301. * @param triggerOptions the trigger, with or without parameters, for the action
  10302. * @param condition an optional determinant of action
  10303. */
  10304. constructor(
  10305. /** the trigger, with or without parameters, for the action */
  10306. triggerOptions: any, condition?: Condition);
  10307. /**
  10308. * Internal only
  10309. * @hidden
  10310. */ prepare(): void;
  10311. /**
  10312. * Gets the trigger parameters
  10313. * @returns the trigger parameters
  10314. */
  10315. getTriggerParameter(): any;
  10316. /**
  10317. * Internal only - executes current action event
  10318. * @hidden
  10319. */ executeCurrent(evt?: ActionEvent): void;
  10320. /**
  10321. * Execute placeholder for child classes
  10322. * @param evt optional action event
  10323. */
  10324. execute(evt?: ActionEvent): void;
  10325. /**
  10326. * Skips to next active action
  10327. */
  10328. skipToNextActiveAction(): void;
  10329. /**
  10330. * Adds action to chain of actions, may be a DoNothingAction
  10331. * @param action defines the next action to execute
  10332. * @returns The action passed in
  10333. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10334. */
  10335. then(action: Action): Action;
  10336. /**
  10337. * Internal only
  10338. * @hidden
  10339. */ getProperty(propertyPath: string): string;
  10340. /**
  10341. * Internal only
  10342. * @hidden
  10343. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10344. /**
  10345. * Serialize placeholder for child classes
  10346. * @param parent of child
  10347. * @returns the serialized object
  10348. */
  10349. serialize(parent: any): any;
  10350. /**
  10351. * Internal only called by serialize
  10352. * @hidden
  10353. */
  10354. protected _serialize(serializedAction: any, parent?: any): any;
  10355. /**
  10356. * Internal only
  10357. * @hidden
  10358. */ private static _SerializeValueAsString: (value: any) => string;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10363. name: string;
  10364. targetType: string;
  10365. value: string;
  10366. };
  10367. }
  10368. }
  10369. declare module BABYLON {
  10370. /**
  10371. * A Condition applied to an Action
  10372. */
  10373. export class Condition {
  10374. /**
  10375. * Internal only - manager for action
  10376. * @hidden
  10377. */ actionManager: ActionManager;
  10378. /**
  10379. * Internal only
  10380. * @hidden
  10381. */ evaluationId: number;
  10382. /**
  10383. * Internal only
  10384. * @hidden
  10385. */ currentResult: boolean;
  10386. /**
  10387. * Creates a new Condition
  10388. * @param actionManager the manager of the action the condition is applied to
  10389. */
  10390. constructor(actionManager: ActionManager);
  10391. /**
  10392. * Check if the current condition is valid
  10393. * @returns a boolean
  10394. */
  10395. isValid(): boolean;
  10396. /**
  10397. * Internal only
  10398. * @hidden
  10399. */ getProperty(propertyPath: string): string;
  10400. /**
  10401. * Internal only
  10402. * @hidden
  10403. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10404. /**
  10405. * Serialize placeholder for child classes
  10406. * @returns the serialized object
  10407. */
  10408. serialize(): any;
  10409. /**
  10410. * Internal only
  10411. * @hidden
  10412. */
  10413. protected _serialize(serializedCondition: any): any;
  10414. }
  10415. /**
  10416. * Defines specific conditional operators as extensions of Condition
  10417. */
  10418. export class ValueCondition extends Condition {
  10419. /** path to specify the property of the target the conditional operator uses */
  10420. propertyPath: string;
  10421. /** the value compared by the conditional operator against the current value of the property */
  10422. value: any;
  10423. /** the conditional operator, default ValueCondition.IsEqual */
  10424. operator: number;
  10425. /**
  10426. * Internal only
  10427. * @hidden
  10428. */
  10429. private static _IsEqual;
  10430. /**
  10431. * Internal only
  10432. * @hidden
  10433. */
  10434. private static _IsDifferent;
  10435. /**
  10436. * Internal only
  10437. * @hidden
  10438. */
  10439. private static _IsGreater;
  10440. /**
  10441. * Internal only
  10442. * @hidden
  10443. */
  10444. private static _IsLesser;
  10445. /**
  10446. * returns the number for IsEqual
  10447. */
  10448. static readonly IsEqual: number;
  10449. /**
  10450. * Returns the number for IsDifferent
  10451. */
  10452. static readonly IsDifferent: number;
  10453. /**
  10454. * Returns the number for IsGreater
  10455. */
  10456. static readonly IsGreater: number;
  10457. /**
  10458. * Returns the number for IsLesser
  10459. */
  10460. static readonly IsLesser: number;
  10461. /**
  10462. * Internal only The action manager for the condition
  10463. * @hidden
  10464. */ actionManager: ActionManager;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. private _target;
  10470. /**
  10471. * Internal only
  10472. * @hidden
  10473. */
  10474. private _effectiveTarget;
  10475. /**
  10476. * Internal only
  10477. * @hidden
  10478. */
  10479. private _property;
  10480. /**
  10481. * Creates a new ValueCondition
  10482. * @param actionManager manager for the action the condition applies to
  10483. * @param target for the action
  10484. * @param propertyPath path to specify the property of the target the conditional operator uses
  10485. * @param value the value compared by the conditional operator against the current value of the property
  10486. * @param operator the conditional operator, default ValueCondition.IsEqual
  10487. */
  10488. constructor(actionManager: ActionManager, target: any,
  10489. /** path to specify the property of the target the conditional operator uses */
  10490. propertyPath: string,
  10491. /** the value compared by the conditional operator against the current value of the property */
  10492. value: any,
  10493. /** the conditional operator, default ValueCondition.IsEqual */
  10494. operator?: number);
  10495. /**
  10496. * Compares the given value with the property value for the specified conditional operator
  10497. * @returns the result of the comparison
  10498. */
  10499. isValid(): boolean;
  10500. /**
  10501. * Serialize the ValueCondition into a JSON compatible object
  10502. * @returns serialization object
  10503. */
  10504. serialize(): any;
  10505. /**
  10506. * Gets the name of the conditional operator for the ValueCondition
  10507. * @param operator the conditional operator
  10508. * @returns the name
  10509. */
  10510. static GetOperatorName(operator: number): string;
  10511. }
  10512. /**
  10513. * Defines a predicate condition as an extension of Condition
  10514. */
  10515. export class PredicateCondition extends Condition {
  10516. /** defines the predicate function used to validate the condition */
  10517. predicate: () => boolean;
  10518. /**
  10519. * Internal only - manager for action
  10520. * @hidden
  10521. */ actionManager: ActionManager;
  10522. /**
  10523. * Creates a new PredicateCondition
  10524. * @param actionManager manager for the action the condition applies to
  10525. * @param predicate defines the predicate function used to validate the condition
  10526. */
  10527. constructor(actionManager: ActionManager,
  10528. /** defines the predicate function used to validate the condition */
  10529. predicate: () => boolean);
  10530. /**
  10531. * @returns the validity of the predicate condition
  10532. */
  10533. isValid(): boolean;
  10534. }
  10535. /**
  10536. * Defines a state condition as an extension of Condition
  10537. */
  10538. export class StateCondition extends Condition {
  10539. /** Value to compare with target state */
  10540. value: string;
  10541. /**
  10542. * Internal only - manager for action
  10543. * @hidden
  10544. */ actionManager: ActionManager;
  10545. /**
  10546. * Internal only
  10547. * @hidden
  10548. */
  10549. private _target;
  10550. /**
  10551. * Creates a new StateCondition
  10552. * @param actionManager manager for the action the condition applies to
  10553. * @param target of the condition
  10554. * @param value to compare with target state
  10555. */
  10556. constructor(actionManager: ActionManager, target: any,
  10557. /** Value to compare with target state */
  10558. value: string);
  10559. /**
  10560. * Gets a boolean indicating if the current condition is met
  10561. * @returns the validity of the state
  10562. */
  10563. isValid(): boolean;
  10564. /**
  10565. * Serialize the StateCondition into a JSON compatible object
  10566. * @returns serialization object
  10567. */
  10568. serialize(): any;
  10569. }
  10570. }
  10571. declare module BABYLON {
  10572. /**
  10573. * This defines an action responsible to toggle a boolean once triggered.
  10574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10575. */
  10576. export class SwitchBooleanAction extends Action {
  10577. /**
  10578. * The path to the boolean property in the target object
  10579. */
  10580. propertyPath: string;
  10581. private _target;
  10582. private _effectiveTarget;
  10583. private _property;
  10584. /**
  10585. * Instantiate the action
  10586. * @param triggerOptions defines the trigger options
  10587. * @param target defines the object containing the boolean
  10588. * @param propertyPath defines the path to the boolean property in the target object
  10589. * @param condition defines the trigger related conditions
  10590. */
  10591. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10592. /** @hidden */ prepare(): void;
  10593. /**
  10594. * Execute the action toggle the boolean value.
  10595. */
  10596. execute(): void;
  10597. /**
  10598. * Serializes the actions and its related information.
  10599. * @param parent defines the object to serialize in
  10600. * @returns the serialized object
  10601. */
  10602. serialize(parent: any): any;
  10603. }
  10604. /**
  10605. * This defines an action responsible to set a the state field of the target
  10606. * to a desired value once triggered.
  10607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10608. */
  10609. export class SetStateAction extends Action {
  10610. /**
  10611. * The value to store in the state field.
  10612. */
  10613. value: string;
  10614. private _target;
  10615. /**
  10616. * Instantiate the action
  10617. * @param triggerOptions defines the trigger options
  10618. * @param target defines the object containing the state property
  10619. * @param value defines the value to store in the state field
  10620. * @param condition defines the trigger related conditions
  10621. */
  10622. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10623. /**
  10624. * Execute the action and store the value on the target state property.
  10625. */
  10626. execute(): void;
  10627. /**
  10628. * Serializes the actions and its related information.
  10629. * @param parent defines the object to serialize in
  10630. * @returns the serialized object
  10631. */
  10632. serialize(parent: any): any;
  10633. }
  10634. /**
  10635. * This defines an action responsible to set a property of the target
  10636. * to a desired value once triggered.
  10637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10638. */
  10639. export class SetValueAction extends Action {
  10640. /**
  10641. * The path of the property to set in the target.
  10642. */
  10643. propertyPath: string;
  10644. /**
  10645. * The value to set in the property
  10646. */
  10647. value: any;
  10648. private _target;
  10649. private _effectiveTarget;
  10650. private _property;
  10651. /**
  10652. * Instantiate the action
  10653. * @param triggerOptions defines the trigger options
  10654. * @param target defines the object containing the property
  10655. * @param propertyPath defines the path of the property to set in the target
  10656. * @param value defines the value to set in the property
  10657. * @param condition defines the trigger related conditions
  10658. */
  10659. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10660. /** @hidden */ prepare(): void;
  10661. /**
  10662. * Execute the action and set the targetted property to the desired value.
  10663. */
  10664. execute(): void;
  10665. /**
  10666. * Serializes the actions and its related information.
  10667. * @param parent defines the object to serialize in
  10668. * @returns the serialized object
  10669. */
  10670. serialize(parent: any): any;
  10671. }
  10672. /**
  10673. * This defines an action responsible to increment the target value
  10674. * to a desired value once triggered.
  10675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10676. */
  10677. export class IncrementValueAction extends Action {
  10678. /**
  10679. * The path of the property to increment in the target.
  10680. */
  10681. propertyPath: string;
  10682. /**
  10683. * The value we should increment the property by.
  10684. */
  10685. value: any;
  10686. private _target;
  10687. private _effectiveTarget;
  10688. private _property;
  10689. /**
  10690. * Instantiate the action
  10691. * @param triggerOptions defines the trigger options
  10692. * @param target defines the object containing the property
  10693. * @param propertyPath defines the path of the property to increment in the target
  10694. * @param value defines the value value we should increment the property by
  10695. * @param condition defines the trigger related conditions
  10696. */
  10697. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10698. /** @hidden */ prepare(): void;
  10699. /**
  10700. * Execute the action and increment the target of the value amount.
  10701. */
  10702. execute(): void;
  10703. /**
  10704. * Serializes the actions and its related information.
  10705. * @param parent defines the object to serialize in
  10706. * @returns the serialized object
  10707. */
  10708. serialize(parent: any): any;
  10709. }
  10710. /**
  10711. * This defines an action responsible to start an animation once triggered.
  10712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10713. */
  10714. export class PlayAnimationAction extends Action {
  10715. /**
  10716. * Where the animation should start (animation frame)
  10717. */
  10718. from: number;
  10719. /**
  10720. * Where the animation should stop (animation frame)
  10721. */
  10722. to: number;
  10723. /**
  10724. * Define if the animation should loop or stop after the first play.
  10725. */
  10726. loop?: boolean;
  10727. private _target;
  10728. /**
  10729. * Instantiate the action
  10730. * @param triggerOptions defines the trigger options
  10731. * @param target defines the target animation or animation name
  10732. * @param from defines from where the animation should start (animation frame)
  10733. * @param end defines where the animation should stop (animation frame)
  10734. * @param loop defines if the animation should loop or stop after the first play
  10735. * @param condition defines the trigger related conditions
  10736. */
  10737. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10738. /** @hidden */ prepare(): void;
  10739. /**
  10740. * Execute the action and play the animation.
  10741. */
  10742. execute(): void;
  10743. /**
  10744. * Serializes the actions and its related information.
  10745. * @param parent defines the object to serialize in
  10746. * @returns the serialized object
  10747. */
  10748. serialize(parent: any): any;
  10749. }
  10750. /**
  10751. * This defines an action responsible to stop an animation once triggered.
  10752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10753. */
  10754. export class StopAnimationAction extends Action {
  10755. private _target;
  10756. /**
  10757. * Instantiate the action
  10758. * @param triggerOptions defines the trigger options
  10759. * @param target defines the target animation or animation name
  10760. * @param condition defines the trigger related conditions
  10761. */
  10762. constructor(triggerOptions: any, target: any, condition?: Condition);
  10763. /** @hidden */ prepare(): void;
  10764. /**
  10765. * Execute the action and stop the animation.
  10766. */
  10767. execute(): void;
  10768. /**
  10769. * Serializes the actions and its related information.
  10770. * @param parent defines the object to serialize in
  10771. * @returns the serialized object
  10772. */
  10773. serialize(parent: any): any;
  10774. }
  10775. /**
  10776. * This defines an action responsible that does nothing once triggered.
  10777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10778. */
  10779. export class DoNothingAction extends Action {
  10780. /**
  10781. * Instantiate the action
  10782. * @param triggerOptions defines the trigger options
  10783. * @param condition defines the trigger related conditions
  10784. */
  10785. constructor(triggerOptions?: any, condition?: Condition);
  10786. /**
  10787. * Execute the action and do nothing.
  10788. */
  10789. execute(): void;
  10790. /**
  10791. * Serializes the actions and its related information.
  10792. * @param parent defines the object to serialize in
  10793. * @returns the serialized object
  10794. */
  10795. serialize(parent: any): any;
  10796. }
  10797. /**
  10798. * This defines an action responsible to trigger several actions once triggered.
  10799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10800. */
  10801. export class CombineAction extends Action {
  10802. /**
  10803. * The list of aggregated animations to run.
  10804. */
  10805. children: Action[];
  10806. /**
  10807. * Instantiate the action
  10808. * @param triggerOptions defines the trigger options
  10809. * @param children defines the list of aggregated animations to run
  10810. * @param condition defines the trigger related conditions
  10811. */
  10812. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10813. /** @hidden */ prepare(): void;
  10814. /**
  10815. * Execute the action and executes all the aggregated actions.
  10816. */
  10817. execute(evt: ActionEvent): void;
  10818. /**
  10819. * Serializes the actions and its related information.
  10820. * @param parent defines the object to serialize in
  10821. * @returns the serialized object
  10822. */
  10823. serialize(parent: any): any;
  10824. }
  10825. /**
  10826. * This defines an action responsible to run code (external event) once triggered.
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10828. */
  10829. export class ExecuteCodeAction extends Action {
  10830. /**
  10831. * The callback function to run.
  10832. */
  10833. func: (evt: ActionEvent) => void;
  10834. /**
  10835. * Instantiate the action
  10836. * @param triggerOptions defines the trigger options
  10837. * @param func defines the callback function to run
  10838. * @param condition defines the trigger related conditions
  10839. */
  10840. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10841. /**
  10842. * Execute the action and run the attached code.
  10843. */
  10844. execute(evt: ActionEvent): void;
  10845. }
  10846. /**
  10847. * This defines an action responsible to set the parent property of the target once triggered.
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10849. */
  10850. export class SetParentAction extends Action {
  10851. private _parent;
  10852. private _target;
  10853. /**
  10854. * Instantiate the action
  10855. * @param triggerOptions defines the trigger options
  10856. * @param target defines the target containing the parent property
  10857. * @param parent defines from where the animation should start (animation frame)
  10858. * @param condition defines the trigger related conditions
  10859. */
  10860. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10861. /** @hidden */ prepare(): void;
  10862. /**
  10863. * Execute the action and set the parent property.
  10864. */
  10865. execute(): void;
  10866. /**
  10867. * Serializes the actions and its related information.
  10868. * @param parent defines the object to serialize in
  10869. * @returns the serialized object
  10870. */
  10871. serialize(parent: any): any;
  10872. }
  10873. }
  10874. declare module BABYLON {
  10875. /**
  10876. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10877. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10879. */
  10880. export class ActionManager extends AbstractActionManager {
  10881. /**
  10882. * Nothing
  10883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10884. */
  10885. static readonly NothingTrigger: number;
  10886. /**
  10887. * On pick
  10888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10889. */
  10890. static readonly OnPickTrigger: number;
  10891. /**
  10892. * On left pick
  10893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10894. */
  10895. static readonly OnLeftPickTrigger: number;
  10896. /**
  10897. * On right pick
  10898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10899. */
  10900. static readonly OnRightPickTrigger: number;
  10901. /**
  10902. * On center pick
  10903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10904. */
  10905. static readonly OnCenterPickTrigger: number;
  10906. /**
  10907. * On pick down
  10908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10909. */
  10910. static readonly OnPickDownTrigger: number;
  10911. /**
  10912. * On double pick
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10914. */
  10915. static readonly OnDoublePickTrigger: number;
  10916. /**
  10917. * On pick up
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10919. */
  10920. static readonly OnPickUpTrigger: number;
  10921. /**
  10922. * On pick out.
  10923. * This trigger will only be raised if you also declared a OnPickDown
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10925. */
  10926. static readonly OnPickOutTrigger: number;
  10927. /**
  10928. * On long press
  10929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10930. */
  10931. static readonly OnLongPressTrigger: number;
  10932. /**
  10933. * On pointer over
  10934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10935. */
  10936. static readonly OnPointerOverTrigger: number;
  10937. /**
  10938. * On pointer out
  10939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10940. */
  10941. static readonly OnPointerOutTrigger: number;
  10942. /**
  10943. * On every frame
  10944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10945. */
  10946. static readonly OnEveryFrameTrigger: number;
  10947. /**
  10948. * On intersection enter
  10949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10950. */
  10951. static readonly OnIntersectionEnterTrigger: number;
  10952. /**
  10953. * On intersection exit
  10954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10955. */
  10956. static readonly OnIntersectionExitTrigger: number;
  10957. /**
  10958. * On key down
  10959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10960. */
  10961. static readonly OnKeyDownTrigger: number;
  10962. /**
  10963. * On key up
  10964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10965. */
  10966. static readonly OnKeyUpTrigger: number;
  10967. private _scene;
  10968. /**
  10969. * Creates a new action manager
  10970. * @param scene defines the hosting scene
  10971. */
  10972. constructor(scene: Scene);
  10973. /**
  10974. * Releases all associated resources
  10975. */
  10976. dispose(): void;
  10977. /**
  10978. * Gets hosting scene
  10979. * @returns the hosting scene
  10980. */
  10981. getScene(): Scene;
  10982. /**
  10983. * Does this action manager handles actions of any of the given triggers
  10984. * @param triggers defines the triggers to be tested
  10985. * @return a boolean indicating whether one (or more) of the triggers is handled
  10986. */
  10987. hasSpecificTriggers(triggers: number[]): boolean;
  10988. /**
  10989. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10990. * speed.
  10991. * @param triggerA defines the trigger to be tested
  10992. * @param triggerB defines the trigger to be tested
  10993. * @return a boolean indicating whether one (or more) of the triggers is handled
  10994. */
  10995. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10996. /**
  10997. * Does this action manager handles actions of a given trigger
  10998. * @param trigger defines the trigger to be tested
  10999. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11000. * @return whether the trigger is handled
  11001. */
  11002. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11003. /**
  11004. * Does this action manager has pointer triggers
  11005. */
  11006. readonly hasPointerTriggers: boolean;
  11007. /**
  11008. * Does this action manager has pick triggers
  11009. */
  11010. readonly hasPickTriggers: boolean;
  11011. /**
  11012. * Registers an action to this action manager
  11013. * @param action defines the action to be registered
  11014. * @return the action amended (prepared) after registration
  11015. */
  11016. registerAction(action: IAction): Nullable<IAction>;
  11017. /**
  11018. * Unregisters an action to this action manager
  11019. * @param action defines the action to be unregistered
  11020. * @return a boolean indicating whether the action has been unregistered
  11021. */
  11022. unregisterAction(action: IAction): Boolean;
  11023. /**
  11024. * Process a specific trigger
  11025. * @param trigger defines the trigger to process
  11026. * @param evt defines the event details to be processed
  11027. */
  11028. processTrigger(trigger: number, evt?: IActionEvent): void;
  11029. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  11030. /** @hidden */ getProperty(propertyPath: string): string;
  11031. /**
  11032. * Serialize this manager to a JSON object
  11033. * @param name defines the property name to store this manager
  11034. * @returns a JSON representation of this manager
  11035. */
  11036. serialize(name: string): any;
  11037. /**
  11038. * Creates a new ActionManager from a JSON data
  11039. * @param parsedActions defines the JSON data to read from
  11040. * @param object defines the hosting mesh
  11041. * @param scene defines the hosting scene
  11042. */
  11043. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11044. /**
  11045. * Get a trigger name by index
  11046. * @param trigger defines the trigger index
  11047. * @returns a trigger name
  11048. */
  11049. static GetTriggerName(trigger: number): string;
  11050. }
  11051. }
  11052. declare module BABYLON {
  11053. /**
  11054. * Class representing a ray with position and direction
  11055. */
  11056. export class Ray {
  11057. /** origin point */
  11058. origin: Vector3;
  11059. /** direction */
  11060. direction: Vector3;
  11061. /** length of the ray */
  11062. length: number;
  11063. private static readonly TmpVector3;
  11064. private _tmpRay;
  11065. /**
  11066. * Creates a new ray
  11067. * @param origin origin point
  11068. * @param direction direction
  11069. * @param length length of the ray
  11070. */
  11071. constructor(
  11072. /** origin point */
  11073. origin: Vector3,
  11074. /** direction */
  11075. direction: Vector3,
  11076. /** length of the ray */
  11077. length?: number);
  11078. /**
  11079. * Checks if the ray intersects a box
  11080. * @param minimum bound of the box
  11081. * @param maximum bound of the box
  11082. * @param intersectionTreshold extra extend to be added to the box in all direction
  11083. * @returns if the box was hit
  11084. */
  11085. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11086. /**
  11087. * Checks if the ray intersects a box
  11088. * @param box the bounding box to check
  11089. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11090. * @returns if the box was hit
  11091. */
  11092. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11093. /**
  11094. * If the ray hits a sphere
  11095. * @param sphere the bounding sphere to check
  11096. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11097. * @returns true if it hits the sphere
  11098. */
  11099. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11100. /**
  11101. * If the ray hits a triange
  11102. * @param vertex0 triangle vertex
  11103. * @param vertex1 triangle vertex
  11104. * @param vertex2 triangle vertex
  11105. * @returns intersection information if hit
  11106. */
  11107. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11108. /**
  11109. * Checks if ray intersects a plane
  11110. * @param plane the plane to check
  11111. * @returns the distance away it was hit
  11112. */
  11113. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11114. /**
  11115. * Checks if ray intersects a mesh
  11116. * @param mesh the mesh to check
  11117. * @param fastCheck if only the bounding box should checked
  11118. * @returns picking info of the intersecton
  11119. */
  11120. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11121. /**
  11122. * Checks if ray intersects a mesh
  11123. * @param meshes the meshes to check
  11124. * @param fastCheck if only the bounding box should checked
  11125. * @param results array to store result in
  11126. * @returns Array of picking infos
  11127. */
  11128. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11129. private _comparePickingInfo;
  11130. private static smallnum;
  11131. private static rayl;
  11132. /**
  11133. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11134. * @param sega the first point of the segment to test the intersection against
  11135. * @param segb the second point of the segment to test the intersection against
  11136. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11137. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11138. */
  11139. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11140. /**
  11141. * Update the ray from viewport position
  11142. * @param x position
  11143. * @param y y position
  11144. * @param viewportWidth viewport width
  11145. * @param viewportHeight viewport height
  11146. * @param world world matrix
  11147. * @param view view matrix
  11148. * @param projection projection matrix
  11149. * @returns this ray updated
  11150. */
  11151. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11152. /**
  11153. * Creates a ray with origin and direction of 0,0,0
  11154. * @returns the new ray
  11155. */
  11156. static Zero(): Ray;
  11157. /**
  11158. * Creates a new ray from screen space and viewport
  11159. * @param x position
  11160. * @param y y position
  11161. * @param viewportWidth viewport width
  11162. * @param viewportHeight viewport height
  11163. * @param world world matrix
  11164. * @param view view matrix
  11165. * @param projection projection matrix
  11166. * @returns new ray
  11167. */
  11168. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11169. /**
  11170. * 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
  11171. * transformed to the given world matrix.
  11172. * @param origin The origin point
  11173. * @param end The end point
  11174. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11175. * @returns the new ray
  11176. */
  11177. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11178. /**
  11179. * Transforms a ray by a matrix
  11180. * @param ray ray to transform
  11181. * @param matrix matrix to apply
  11182. * @returns the resulting new ray
  11183. */
  11184. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11185. /**
  11186. * Transforms a ray by a matrix
  11187. * @param ray ray to transform
  11188. * @param matrix matrix to apply
  11189. * @param result ray to store result in
  11190. */
  11191. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11192. /**
  11193. * Unproject a ray from screen space to object space
  11194. * @param sourceX defines the screen space x coordinate to use
  11195. * @param sourceY defines the screen space y coordinate to use
  11196. * @param viewportWidth defines the current width of the viewport
  11197. * @param viewportHeight defines the current height of the viewport
  11198. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11199. * @param view defines the view matrix to use
  11200. * @param projection defines the projection matrix to use
  11201. */
  11202. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11203. }
  11204. /**
  11205. * Type used to define predicate used to select faces when a mesh intersection is detected
  11206. */
  11207. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11208. interface Scene {
  11209. /** @hidden */ tempPickingRay: Nullable<Ray>;
  11210. /** @hidden */ cachedRayForTransform: Ray;
  11211. /** @hidden */ pickWithRayInverseMatrix: Matrix;
  11212. /** @hidden */ internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11213. /** @hidden */ internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11214. }
  11215. }
  11216. declare module BABYLON {
  11217. /**
  11218. * Groups all the scene component constants in one place to ease maintenance.
  11219. * @hidden
  11220. */
  11221. export class SceneComponentConstants {
  11222. static readonly NAME_EFFECTLAYER: string;
  11223. static readonly NAME_LAYER: string;
  11224. static readonly NAME_LENSFLARESYSTEM: string;
  11225. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11226. static readonly NAME_PARTICLESYSTEM: string;
  11227. static readonly NAME_GAMEPAD: string;
  11228. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11229. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11230. static readonly NAME_DEPTHRENDERER: string;
  11231. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11232. static readonly NAME_SPRITE: string;
  11233. static readonly NAME_OUTLINERENDERER: string;
  11234. static readonly NAME_PROCEDURALTEXTURE: string;
  11235. static readonly NAME_SHADOWGENERATOR: string;
  11236. static readonly NAME_OCTREE: string;
  11237. static readonly NAME_PHYSICSENGINE: string;
  11238. static readonly NAME_AUDIO: string;
  11239. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11240. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11241. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11242. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11243. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11244. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11245. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11246. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11247. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11248. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11249. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11250. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11251. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11252. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11253. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11254. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11255. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11256. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11257. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11258. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11259. static readonly STEP_AFTERRENDER_AUDIO: number;
  11260. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11261. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11262. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11263. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11264. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11265. static readonly STEP_POINTERMOVE_SPRITE: number;
  11266. static readonly STEP_POINTERDOWN_SPRITE: number;
  11267. static readonly STEP_POINTERUP_SPRITE: number;
  11268. }
  11269. /**
  11270. * This represents a scene component.
  11271. *
  11272. * This is used to decouple the dependency the scene is having on the different workloads like
  11273. * layers, post processes...
  11274. */
  11275. export interface ISceneComponent {
  11276. /**
  11277. * The name of the component. Each component must have a unique name.
  11278. */
  11279. name: string;
  11280. /**
  11281. * The scene the component belongs to.
  11282. */
  11283. scene: Scene;
  11284. /**
  11285. * Register the component to one instance of a scene.
  11286. */
  11287. register(): void;
  11288. /**
  11289. * Rebuilds the elements related to this component in case of
  11290. * context lost for instance.
  11291. */
  11292. rebuild(): void;
  11293. /**
  11294. * Disposes the component and the associated ressources.
  11295. */
  11296. dispose(): void;
  11297. }
  11298. /**
  11299. * This represents a SERIALIZABLE scene component.
  11300. *
  11301. * This extends Scene Component to add Serialization methods on top.
  11302. */
  11303. export interface ISceneSerializableComponent extends ISceneComponent {
  11304. /**
  11305. * Adds all the element from the container to the scene
  11306. * @param container the container holding the elements
  11307. */
  11308. addFromContainer(container: AbstractScene): void;
  11309. /**
  11310. * Removes all the elements in the container from the scene
  11311. * @param container contains the elements to remove
  11312. * @param dispose if the removed element should be disposed (default: false)
  11313. */
  11314. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11315. /**
  11316. * Serializes the component data to the specified json object
  11317. * @param serializationObject The object to serialize to
  11318. */
  11319. serialize(serializationObject: any): void;
  11320. }
  11321. /**
  11322. * Strong typing of a Mesh related stage step action
  11323. */
  11324. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11325. /**
  11326. * Strong typing of a Evaluate Sub Mesh related stage step action
  11327. */
  11328. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11329. /**
  11330. * Strong typing of a Active Mesh related stage step action
  11331. */
  11332. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11333. /**
  11334. * Strong typing of a Camera related stage step action
  11335. */
  11336. export type CameraStageAction = (camera: Camera) => void;
  11337. /**
  11338. * Strong typing of a Camera Frame buffer related stage step action
  11339. */
  11340. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11341. /**
  11342. * Strong typing of a Render Target related stage step action
  11343. */
  11344. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11345. /**
  11346. * Strong typing of a RenderingGroup related stage step action
  11347. */
  11348. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11349. /**
  11350. * Strong typing of a Mesh Render related stage step action
  11351. */
  11352. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11353. /**
  11354. * Strong typing of a simple stage step action
  11355. */
  11356. export type SimpleStageAction = () => void;
  11357. /**
  11358. * Strong typing of a render target action.
  11359. */
  11360. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11361. /**
  11362. * Strong typing of a pointer move action.
  11363. */
  11364. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11365. /**
  11366. * Strong typing of a pointer up/down action.
  11367. */
  11368. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11369. /**
  11370. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11371. * @hidden
  11372. */
  11373. export class Stage<T extends Function> extends Array<{
  11374. index: number;
  11375. component: ISceneComponent;
  11376. action: T;
  11377. }> {
  11378. /**
  11379. * Hide ctor from the rest of the world.
  11380. * @param items The items to add.
  11381. */
  11382. private constructor();
  11383. /**
  11384. * Creates a new Stage.
  11385. * @returns A new instance of a Stage
  11386. */
  11387. static Create<T extends Function>(): Stage<T>;
  11388. /**
  11389. * Registers a step in an ordered way in the targeted stage.
  11390. * @param index Defines the position to register the step in
  11391. * @param component Defines the component attached to the step
  11392. * @param action Defines the action to launch during the step
  11393. */
  11394. registerStep(index: number, component: ISceneComponent, action: T): void;
  11395. /**
  11396. * Clears all the steps from the stage.
  11397. */
  11398. clear(): void;
  11399. }
  11400. }
  11401. declare module BABYLON {
  11402. interface Scene {
  11403. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  11404. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  11405. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  11406. /**
  11407. * All of the sprite managers added to this scene
  11408. * @see http://doc.babylonjs.com/babylon101/sprites
  11409. */
  11410. spriteManagers: Array<ISpriteManager>;
  11411. /**
  11412. * An event triggered when sprites rendering is about to start
  11413. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11414. */
  11415. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11416. /**
  11417. * An event triggered when sprites rendering is done
  11418. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11419. */
  11420. onAfterSpritesRenderingObservable: Observable<Scene>;
  11421. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11422. /** Launch a ray to try to pick a sprite in the scene
  11423. * @param x position on screen
  11424. * @param y position on screen
  11425. * @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
  11426. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11427. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11428. * @returns a PickingInfo
  11429. */
  11430. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11431. /** Use the given ray to pick a sprite in the scene
  11432. * @param ray The ray (in world space) to use to pick meshes
  11433. * @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
  11434. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11435. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11436. * @returns a PickingInfo
  11437. */
  11438. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11439. /**
  11440. * Force the sprite under the pointer
  11441. * @param sprite defines the sprite to use
  11442. */
  11443. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11444. /**
  11445. * Gets the sprite under the pointer
  11446. * @returns a Sprite or null if no sprite is under the pointer
  11447. */
  11448. getPointerOverSprite(): Nullable<Sprite>;
  11449. }
  11450. /**
  11451. * Defines the sprite scene component responsible to manage sprites
  11452. * in a given scene.
  11453. */
  11454. export class SpriteSceneComponent implements ISceneComponent {
  11455. /**
  11456. * The component name helpfull to identify the component in the list of scene components.
  11457. */
  11458. readonly name: string;
  11459. /**
  11460. * The scene the component belongs to.
  11461. */
  11462. scene: Scene;
  11463. /** @hidden */
  11464. private _spritePredicate;
  11465. /**
  11466. * Creates a new instance of the component for the given scene
  11467. * @param scene Defines the scene to register the component in
  11468. */
  11469. constructor(scene: Scene);
  11470. /**
  11471. * Registers the component in a given scene
  11472. */
  11473. register(): void;
  11474. /**
  11475. * Rebuilds the elements related to this component in case of
  11476. * context lost for instance.
  11477. */
  11478. rebuild(): void;
  11479. /**
  11480. * Disposes the component and the associated ressources.
  11481. */
  11482. dispose(): void;
  11483. private _pickSpriteButKeepRay;
  11484. private _pointerMove;
  11485. private _pointerDown;
  11486. private _pointerUp;
  11487. }
  11488. }
  11489. declare module BABYLON {
  11490. /** @hidden */
  11491. export var fogFragmentDeclaration: {
  11492. name: string;
  11493. shader: string;
  11494. };
  11495. }
  11496. declare module BABYLON {
  11497. /** @hidden */
  11498. export var fogFragment: {
  11499. name: string;
  11500. shader: string;
  11501. };
  11502. }
  11503. declare module BABYLON {
  11504. /** @hidden */
  11505. export var spritesPixelShader: {
  11506. name: string;
  11507. shader: string;
  11508. };
  11509. }
  11510. declare module BABYLON {
  11511. /** @hidden */
  11512. export var fogVertexDeclaration: {
  11513. name: string;
  11514. shader: string;
  11515. };
  11516. }
  11517. declare module BABYLON {
  11518. /** @hidden */
  11519. export var spritesVertexShader: {
  11520. name: string;
  11521. shader: string;
  11522. };
  11523. }
  11524. declare module BABYLON {
  11525. /**
  11526. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11527. */
  11528. export interface ISpriteManager extends IDisposable {
  11529. /**
  11530. * Restricts the camera to viewing objects with the same layerMask.
  11531. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11532. */
  11533. layerMask: number;
  11534. /**
  11535. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11536. */
  11537. isPickable: boolean;
  11538. /**
  11539. * Specifies the rendering group id for this mesh (0 by default)
  11540. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11541. */
  11542. renderingGroupId: number;
  11543. /**
  11544. * Defines the list of sprites managed by the manager.
  11545. */
  11546. sprites: Array<Sprite>;
  11547. /**
  11548. * Tests the intersection of a sprite with a specific ray.
  11549. * @param ray The ray we are sending to test the collision
  11550. * @param camera The camera space we are sending rays in
  11551. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11552. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11553. * @returns picking info or null.
  11554. */
  11555. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11556. /**
  11557. * Renders the list of sprites on screen.
  11558. */
  11559. render(): void;
  11560. }
  11561. /**
  11562. * Class used to manage multiple sprites on the same spritesheet
  11563. * @see http://doc.babylonjs.com/babylon101/sprites
  11564. */
  11565. export class SpriteManager implements ISpriteManager {
  11566. /** defines the manager's name */
  11567. name: string;
  11568. /** Gets the list of sprites */
  11569. sprites: Sprite[];
  11570. /** Gets or sets the rendering group id (0 by default) */
  11571. renderingGroupId: number;
  11572. /** Gets or sets camera layer mask */
  11573. layerMask: number;
  11574. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11575. fogEnabled: boolean;
  11576. /** Gets or sets a boolean indicating if the sprites are pickable */
  11577. isPickable: boolean;
  11578. /** Defines the default width of a cell in the spritesheet */
  11579. cellWidth: number;
  11580. /** Defines the default height of a cell in the spritesheet */
  11581. cellHeight: number;
  11582. /**
  11583. * An event triggered when the manager is disposed.
  11584. */
  11585. onDisposeObservable: Observable<SpriteManager>;
  11586. private _onDisposeObserver;
  11587. /**
  11588. * Callback called when the manager is disposed
  11589. */
  11590. onDispose: () => void;
  11591. private _capacity;
  11592. private _spriteTexture;
  11593. private _epsilon;
  11594. private _scene;
  11595. private _vertexData;
  11596. private _buffer;
  11597. private _vertexBuffers;
  11598. private _indexBuffer;
  11599. private _effectBase;
  11600. private _effectFog;
  11601. /**
  11602. * Gets or sets the spritesheet texture
  11603. */
  11604. texture: Texture;
  11605. /**
  11606. * Creates a new sprite manager
  11607. * @param name defines the manager's name
  11608. * @param imgUrl defines the sprite sheet url
  11609. * @param capacity defines the maximum allowed number of sprites
  11610. * @param cellSize defines the size of a sprite cell
  11611. * @param scene defines the hosting scene
  11612. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11613. * @param samplingMode defines the smapling mode to use with spritesheet
  11614. */
  11615. constructor(
  11616. /** defines the manager's name */
  11617. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11618. private _appendSpriteVertex;
  11619. /**
  11620. * Intersects the sprites with a ray
  11621. * @param ray defines the ray to intersect with
  11622. * @param camera defines the current active camera
  11623. * @param predicate defines a predicate used to select candidate sprites
  11624. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11625. * @returns null if no hit or a PickingInfo
  11626. */
  11627. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11628. /**
  11629. * Render all child sprites
  11630. */
  11631. render(): void;
  11632. /**
  11633. * Release associated resources
  11634. */
  11635. dispose(): void;
  11636. }
  11637. }
  11638. declare module BABYLON {
  11639. /**
  11640. * Class used to represent a sprite
  11641. * @see http://doc.babylonjs.com/babylon101/sprites
  11642. */
  11643. export class Sprite {
  11644. /** defines the name */
  11645. name: string;
  11646. /** Gets or sets the current world position */
  11647. position: Vector3;
  11648. /** Gets or sets the main color */
  11649. color: Color4;
  11650. /** Gets or sets the width */
  11651. width: number;
  11652. /** Gets or sets the height */
  11653. height: number;
  11654. /** Gets or sets rotation angle */
  11655. angle: number;
  11656. /** Gets or sets the cell index in the sprite sheet */
  11657. cellIndex: number;
  11658. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11659. invertU: number;
  11660. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11661. invertV: number;
  11662. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11663. disposeWhenFinishedAnimating: boolean;
  11664. /** Gets the list of attached animations */
  11665. animations: Animation[];
  11666. /** Gets or sets a boolean indicating if the sprite can be picked */
  11667. isPickable: boolean;
  11668. /**
  11669. * Gets or sets the associated action manager
  11670. */
  11671. actionManager: Nullable<ActionManager>;
  11672. private _animationStarted;
  11673. private _loopAnimation;
  11674. private _fromIndex;
  11675. private _toIndex;
  11676. private _delay;
  11677. private _direction;
  11678. private _manager;
  11679. private _time;
  11680. private _onAnimationEnd;
  11681. /**
  11682. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11683. */
  11684. isVisible: boolean;
  11685. /**
  11686. * Gets or sets the sprite size
  11687. */
  11688. size: number;
  11689. /**
  11690. * Creates a new Sprite
  11691. * @param name defines the name
  11692. * @param manager defines the manager
  11693. */
  11694. constructor(
  11695. /** defines the name */
  11696. name: string, manager: ISpriteManager);
  11697. /**
  11698. * Starts an animation
  11699. * @param from defines the initial key
  11700. * @param to defines the end key
  11701. * @param loop defines if the animation must loop
  11702. * @param delay defines the start delay (in ms)
  11703. * @param onAnimationEnd defines a callback to call when animation ends
  11704. */
  11705. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11706. /** Stops current animation (if any) */
  11707. stopAnimation(): void;
  11708. /** @hidden */ animate(deltaTime: number): void;
  11709. /** Release associated resources */
  11710. dispose(): void;
  11711. }
  11712. }
  11713. declare module BABYLON {
  11714. /**
  11715. * Information about the result of picking within a scene
  11716. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11717. */
  11718. export class PickingInfo {
  11719. /** @hidden */ pickingUnavailable: boolean;
  11720. /**
  11721. * If the pick collided with an object
  11722. */
  11723. hit: boolean;
  11724. /**
  11725. * Distance away where the pick collided
  11726. */
  11727. distance: number;
  11728. /**
  11729. * The location of pick collision
  11730. */
  11731. pickedPoint: Nullable<Vector3>;
  11732. /**
  11733. * The mesh corresponding the the pick collision
  11734. */
  11735. pickedMesh: Nullable<AbstractMesh>;
  11736. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11737. bu: number;
  11738. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11739. bv: number;
  11740. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11741. faceId: number;
  11742. /** Id of the the submesh that was picked */
  11743. subMeshId: number;
  11744. /** If a sprite was picked, this will be the sprite the pick collided with */
  11745. pickedSprite: Nullable<Sprite>;
  11746. /**
  11747. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11748. */
  11749. originMesh: Nullable<AbstractMesh>;
  11750. /**
  11751. * The ray that was used to perform the picking.
  11752. */
  11753. ray: Nullable<Ray>;
  11754. /**
  11755. * Gets the normal correspodning to the face the pick collided with
  11756. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11757. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11758. * @returns The normal correspodning to the face the pick collided with
  11759. */
  11760. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11761. /**
  11762. * Gets the texture coordinates of where the pick occured
  11763. * @returns the vector containing the coordnates of the texture
  11764. */
  11765. getTextureCoordinates(): Nullable<Vector2>;
  11766. }
  11767. }
  11768. declare module BABYLON {
  11769. /**
  11770. * Gather the list of pointer event types as constants.
  11771. */
  11772. export class PointerEventTypes {
  11773. /**
  11774. * 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.
  11775. */
  11776. static readonly POINTERDOWN: number;
  11777. /**
  11778. * The pointerup event is fired when a pointer is no longer active.
  11779. */
  11780. static readonly POINTERUP: number;
  11781. /**
  11782. * The pointermove event is fired when a pointer changes coordinates.
  11783. */
  11784. static readonly POINTERMOVE: number;
  11785. /**
  11786. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11787. */
  11788. static readonly POINTERWHEEL: number;
  11789. /**
  11790. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11791. */
  11792. static readonly POINTERPICK: number;
  11793. /**
  11794. * The pointertap event is fired when a the object has been touched and released without drag.
  11795. */
  11796. static readonly POINTERTAP: number;
  11797. /**
  11798. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11799. */
  11800. static readonly POINTERDOUBLETAP: number;
  11801. }
  11802. /**
  11803. * Base class of pointer info types.
  11804. */
  11805. export class PointerInfoBase {
  11806. /**
  11807. * Defines the type of event (PointerEventTypes)
  11808. */
  11809. type: number;
  11810. /**
  11811. * Defines the related dom event
  11812. */
  11813. event: PointerEvent | MouseWheelEvent;
  11814. /**
  11815. * Instantiates the base class of pointers info.
  11816. * @param type Defines the type of event (PointerEventTypes)
  11817. * @param event Defines the related dom event
  11818. */
  11819. constructor(
  11820. /**
  11821. * Defines the type of event (PointerEventTypes)
  11822. */
  11823. type: number,
  11824. /**
  11825. * Defines the related dom event
  11826. */
  11827. event: PointerEvent | MouseWheelEvent);
  11828. }
  11829. /**
  11830. * This class is used to store pointer related info for the onPrePointerObservable event.
  11831. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11832. */
  11833. export class PointerInfoPre extends PointerInfoBase {
  11834. /**
  11835. * Ray from a pointer if availible (eg. 6dof controller)
  11836. */
  11837. ray: Nullable<Ray>;
  11838. /**
  11839. * Defines the local position of the pointer on the canvas.
  11840. */
  11841. localPosition: Vector2;
  11842. /**
  11843. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11844. */
  11845. skipOnPointerObservable: boolean;
  11846. /**
  11847. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11848. * @param type Defines the type of event (PointerEventTypes)
  11849. * @param event Defines the related dom event
  11850. * @param localX Defines the local x coordinates of the pointer when the event occured
  11851. * @param localY Defines the local y coordinates of the pointer when the event occured
  11852. */
  11853. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11854. }
  11855. /**
  11856. * This type contains all the data related to a pointer event in Babylon.js.
  11857. * 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.
  11858. */
  11859. export class PointerInfo extends PointerInfoBase {
  11860. /**
  11861. * Defines the picking info associated to the info (if any)\
  11862. */
  11863. pickInfo: Nullable<PickingInfo>;
  11864. /**
  11865. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11866. * @param type Defines the type of event (PointerEventTypes)
  11867. * @param event Defines the related dom event
  11868. * @param pickInfo Defines the picking info associated to the info (if any)\
  11869. */
  11870. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11871. /**
  11872. * Defines the picking info associated to the info (if any)\
  11873. */
  11874. pickInfo: Nullable<PickingInfo>);
  11875. }
  11876. /**
  11877. * Data relating to a touch event on the screen.
  11878. */
  11879. export interface PointerTouch {
  11880. /**
  11881. * X coordinate of touch.
  11882. */
  11883. x: number;
  11884. /**
  11885. * Y coordinate of touch.
  11886. */
  11887. y: number;
  11888. /**
  11889. * Id of touch. Unique for each finger.
  11890. */
  11891. pointerId: number;
  11892. /**
  11893. * Event type passed from DOM.
  11894. */
  11895. type: any;
  11896. }
  11897. }
  11898. declare module BABYLON {
  11899. /**
  11900. * Manage the mouse inputs to control the movement of a free camera.
  11901. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11902. */
  11903. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11904. /**
  11905. * Define if touch is enabled in the mouse input
  11906. */
  11907. touchEnabled: boolean;
  11908. /**
  11909. * Defines the camera the input is attached to.
  11910. */
  11911. camera: FreeCamera;
  11912. /**
  11913. * Defines the buttons associated with the input to handle camera move.
  11914. */
  11915. buttons: number[];
  11916. /**
  11917. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11918. */
  11919. angularSensibility: number;
  11920. private _pointerInput;
  11921. private _onMouseMove;
  11922. private _observer;
  11923. private previousPosition;
  11924. /**
  11925. * Observable for when a pointer move event occurs containing the move offset
  11926. */
  11927. onPointerMovedObservable: Observable<{
  11928. offsetX: number;
  11929. offsetY: number;
  11930. }>;
  11931. /**
  11932. * @hidden
  11933. * If the camera should be rotated automatically based on pointer movement
  11934. */ allowCameraRotation: boolean;
  11935. /**
  11936. * Manage the mouse inputs to control the movement of a free camera.
  11937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11938. * @param touchEnabled Defines if touch is enabled or not
  11939. */
  11940. constructor(
  11941. /**
  11942. * Define if touch is enabled in the mouse input
  11943. */
  11944. touchEnabled?: boolean);
  11945. /**
  11946. * Attach the input controls to a specific dom element to get the input from.
  11947. * @param element Defines the element the controls should be listened from
  11948. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11949. */
  11950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11951. /**
  11952. * Called on JS contextmenu event.
  11953. * Override this method to provide functionality.
  11954. */
  11955. protected onContextMenu(evt: PointerEvent): void;
  11956. /**
  11957. * Detach the current controls from the specified dom element.
  11958. * @param element Defines the element to stop listening the inputs from
  11959. */
  11960. detachControl(element: Nullable<HTMLElement>): void;
  11961. /**
  11962. * Gets the class name of the current intput.
  11963. * @returns the class name
  11964. */
  11965. getClassName(): string;
  11966. /**
  11967. * Get the friendly name associated with the input class.
  11968. * @returns the input friendly name
  11969. */
  11970. getSimpleName(): string;
  11971. }
  11972. }
  11973. declare module BABYLON {
  11974. /**
  11975. * Manage the touch inputs to control the movement of a free camera.
  11976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11977. */
  11978. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11979. /**
  11980. * Defines the camera the input is attached to.
  11981. */
  11982. camera: FreeCamera;
  11983. /**
  11984. * Defines the touch sensibility for rotation.
  11985. * The higher the faster.
  11986. */
  11987. touchAngularSensibility: number;
  11988. /**
  11989. * Defines the touch sensibility for move.
  11990. * The higher the faster.
  11991. */
  11992. touchMoveSensibility: number;
  11993. private _offsetX;
  11994. private _offsetY;
  11995. private _pointerPressed;
  11996. private _pointerInput;
  11997. private _observer;
  11998. private _onLostFocus;
  11999. /**
  12000. * Attach the input controls to a specific dom element to get the input from.
  12001. * @param element Defines the element the controls should be listened from
  12002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12003. */
  12004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12005. /**
  12006. * Detach the current controls from the specified dom element.
  12007. * @param element Defines the element to stop listening the inputs from
  12008. */
  12009. detachControl(element: Nullable<HTMLElement>): void;
  12010. /**
  12011. * Update the current camera state depending on the inputs that have been used this frame.
  12012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12013. */
  12014. checkInputs(): void;
  12015. /**
  12016. * Gets the class name of the current intput.
  12017. * @returns the class name
  12018. */
  12019. getClassName(): string;
  12020. /**
  12021. * Get the friendly name associated with the input class.
  12022. * @returns the input friendly name
  12023. */
  12024. getSimpleName(): string;
  12025. }
  12026. }
  12027. declare module BABYLON {
  12028. /**
  12029. * Default Inputs manager for the FreeCamera.
  12030. * It groups all the default supported inputs for ease of use.
  12031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12032. */
  12033. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12034. /**
  12035. * @hidden
  12036. */ keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12037. /**
  12038. * @hidden
  12039. */ mouseInput: Nullable<FreeCameraMouseInput>;
  12040. /**
  12041. * Instantiates a new FreeCameraInputsManager.
  12042. * @param camera Defines the camera the inputs belong to
  12043. */
  12044. constructor(camera: FreeCamera);
  12045. /**
  12046. * Add keyboard input support to the input manager.
  12047. * @returns the current input manager
  12048. */
  12049. addKeyboard(): FreeCameraInputsManager;
  12050. /**
  12051. * Add mouse input support to the input manager.
  12052. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12053. * @returns the current input manager
  12054. */
  12055. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12056. /**
  12057. * Removes the mouse input support from the manager
  12058. * @returns the current input manager
  12059. */
  12060. removeMouse(): FreeCameraInputsManager;
  12061. /**
  12062. * Add touch input support to the input manager.
  12063. * @returns the current input manager
  12064. */
  12065. addTouch(): FreeCameraInputsManager;
  12066. }
  12067. }
  12068. declare module BABYLON {
  12069. /**
  12070. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12071. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12072. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12073. */
  12074. export class FreeCamera extends TargetCamera {
  12075. /**
  12076. * Define the collision ellipsoid of the camera.
  12077. * This is helpful to simulate a camera body like the player body around the camera
  12078. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12079. */
  12080. ellipsoid: Vector3;
  12081. /**
  12082. * Define an offset for the position of the ellipsoid around the camera.
  12083. * This can be helpful to determine the center of the body near the gravity center of the body
  12084. * instead of its head.
  12085. */
  12086. ellipsoidOffset: Vector3;
  12087. /**
  12088. * Enable or disable collisions of the camera with the rest of the scene objects.
  12089. */
  12090. checkCollisions: boolean;
  12091. /**
  12092. * Enable or disable gravity on the camera.
  12093. */
  12094. applyGravity: boolean;
  12095. /**
  12096. * Define the input manager associated to the camera.
  12097. */
  12098. inputs: FreeCameraInputsManager;
  12099. /**
  12100. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12101. * Higher values reduce sensitivity.
  12102. */
  12103. /**
  12104. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12105. * Higher values reduce sensitivity.
  12106. */
  12107. angularSensibility: number;
  12108. /**
  12109. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12110. */
  12111. keysUp: number[];
  12112. /**
  12113. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12114. */
  12115. keysDown: number[];
  12116. /**
  12117. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12118. */
  12119. keysLeft: number[];
  12120. /**
  12121. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12122. */
  12123. keysRight: number[];
  12124. /**
  12125. * Event raised when the camera collide with a mesh in the scene.
  12126. */
  12127. onCollide: (collidedMesh: AbstractMesh) => void;
  12128. private _collider;
  12129. private _needMoveForGravity;
  12130. private _oldPosition;
  12131. private _diffPosition;
  12132. private _newPosition;
  12133. /** @hidden */ localDirection: Vector3;
  12134. /** @hidden */ transformedDirection: Vector3;
  12135. /**
  12136. * Instantiates a Free Camera.
  12137. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12138. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12139. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12140. * @param name Define the name of the camera in the scene
  12141. * @param position Define the start position of the camera in the scene
  12142. * @param scene Define the scene the camera belongs to
  12143. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12144. */
  12145. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12146. /**
  12147. * Attached controls to the current camera.
  12148. * @param element Defines the element the controls should be listened from
  12149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12150. */
  12151. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12152. /**
  12153. * Detach the current controls from the camera.
  12154. * The camera will stop reacting to inputs.
  12155. * @param element Defines the element to stop listening the inputs from
  12156. */
  12157. detachControl(element: HTMLElement): void;
  12158. private _collisionMask;
  12159. /**
  12160. * Define a collision mask to limit the list of object the camera can collide with
  12161. */
  12162. collisionMask: number;
  12163. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  12164. private _onCollisionPositionChange;
  12165. /** @hidden */ checkInputs(): void;
  12166. /** @hidden */ decideIfNeedsToMove(): boolean;
  12167. /** @hidden */ updatePosition(): void;
  12168. /**
  12169. * Destroy the camera and release the current resources hold by it.
  12170. */
  12171. dispose(): void;
  12172. /**
  12173. * Gets the current object class name.
  12174. * @return the class name
  12175. */
  12176. getClassName(): string;
  12177. }
  12178. }
  12179. declare module BABYLON {
  12180. /**
  12181. * Represents a gamepad control stick position
  12182. */
  12183. export class StickValues {
  12184. /**
  12185. * The x component of the control stick
  12186. */
  12187. x: number;
  12188. /**
  12189. * The y component of the control stick
  12190. */
  12191. y: number;
  12192. /**
  12193. * Initializes the gamepad x and y control stick values
  12194. * @param x The x component of the gamepad control stick value
  12195. * @param y The y component of the gamepad control stick value
  12196. */
  12197. constructor(
  12198. /**
  12199. * The x component of the control stick
  12200. */
  12201. x: number,
  12202. /**
  12203. * The y component of the control stick
  12204. */
  12205. y: number);
  12206. }
  12207. /**
  12208. * An interface which manages callbacks for gamepad button changes
  12209. */
  12210. export interface GamepadButtonChanges {
  12211. /**
  12212. * Called when a gamepad has been changed
  12213. */
  12214. changed: boolean;
  12215. /**
  12216. * Called when a gamepad press event has been triggered
  12217. */
  12218. pressChanged: boolean;
  12219. /**
  12220. * Called when a touch event has been triggered
  12221. */
  12222. touchChanged: boolean;
  12223. /**
  12224. * Called when a value has changed
  12225. */
  12226. valueChanged: boolean;
  12227. }
  12228. /**
  12229. * Represents a gamepad
  12230. */
  12231. export class Gamepad {
  12232. /**
  12233. * The id of the gamepad
  12234. */
  12235. id: string;
  12236. /**
  12237. * The index of the gamepad
  12238. */
  12239. index: number;
  12240. /**
  12241. * The browser gamepad
  12242. */
  12243. browserGamepad: any;
  12244. /**
  12245. * Specifies what type of gamepad this represents
  12246. */
  12247. type: number;
  12248. private _leftStick;
  12249. private _rightStick;
  12250. /** @hidden */ isConnected: boolean;
  12251. private _leftStickAxisX;
  12252. private _leftStickAxisY;
  12253. private _rightStickAxisX;
  12254. private _rightStickAxisY;
  12255. /**
  12256. * Triggered when the left control stick has been changed
  12257. */
  12258. private _onleftstickchanged;
  12259. /**
  12260. * Triggered when the right control stick has been changed
  12261. */
  12262. private _onrightstickchanged;
  12263. /**
  12264. * Represents a gamepad controller
  12265. */
  12266. static GAMEPAD: number;
  12267. /**
  12268. * Represents a generic controller
  12269. */
  12270. static GENERIC: number;
  12271. /**
  12272. * Represents an XBox controller
  12273. */
  12274. static XBOX: number;
  12275. /**
  12276. * Represents a pose-enabled controller
  12277. */
  12278. static POSE_ENABLED: number;
  12279. /**
  12280. * Specifies whether the left control stick should be Y-inverted
  12281. */
  12282. protected _invertLeftStickY: boolean;
  12283. /**
  12284. * Specifies if the gamepad has been connected
  12285. */
  12286. readonly isConnected: boolean;
  12287. /**
  12288. * Initializes the gamepad
  12289. * @param id The id of the gamepad
  12290. * @param index The index of the gamepad
  12291. * @param browserGamepad The browser gamepad
  12292. * @param leftStickX The x component of the left joystick
  12293. * @param leftStickY The y component of the left joystick
  12294. * @param rightStickX The x component of the right joystick
  12295. * @param rightStickY The y component of the right joystick
  12296. */
  12297. constructor(
  12298. /**
  12299. * The id of the gamepad
  12300. */
  12301. id: string,
  12302. /**
  12303. * The index of the gamepad
  12304. */
  12305. index: number,
  12306. /**
  12307. * The browser gamepad
  12308. */
  12309. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12310. /**
  12311. * Callback triggered when the left joystick has changed
  12312. * @param callback
  12313. */
  12314. onleftstickchanged(callback: (values: StickValues) => void): void;
  12315. /**
  12316. * Callback triggered when the right joystick has changed
  12317. * @param callback
  12318. */
  12319. onrightstickchanged(callback: (values: StickValues) => void): void;
  12320. /**
  12321. * Gets the left joystick
  12322. */
  12323. /**
  12324. * Sets the left joystick values
  12325. */
  12326. leftStick: StickValues;
  12327. /**
  12328. * Gets the right joystick
  12329. */
  12330. /**
  12331. * Sets the right joystick value
  12332. */
  12333. rightStick: StickValues;
  12334. /**
  12335. * Updates the gamepad joystick positions
  12336. */
  12337. update(): void;
  12338. /**
  12339. * Disposes the gamepad
  12340. */
  12341. dispose(): void;
  12342. }
  12343. /**
  12344. * Represents a generic gamepad
  12345. */
  12346. export class GenericPad extends Gamepad {
  12347. private _buttons;
  12348. private _onbuttondown;
  12349. private _onbuttonup;
  12350. /**
  12351. * Observable triggered when a button has been pressed
  12352. */
  12353. onButtonDownObservable: Observable<number>;
  12354. /**
  12355. * Observable triggered when a button has been released
  12356. */
  12357. onButtonUpObservable: Observable<number>;
  12358. /**
  12359. * Callback triggered when a button has been pressed
  12360. * @param callback Called when a button has been pressed
  12361. */
  12362. onbuttondown(callback: (buttonPressed: number) => void): void;
  12363. /**
  12364. * Callback triggered when a button has been released
  12365. * @param callback Called when a button has been released
  12366. */
  12367. onbuttonup(callback: (buttonReleased: number) => void): void;
  12368. /**
  12369. * Initializes the generic gamepad
  12370. * @param id The id of the generic gamepad
  12371. * @param index The index of the generic gamepad
  12372. * @param browserGamepad The browser gamepad
  12373. */
  12374. constructor(id: string, index: number, browserGamepad: any);
  12375. private _setButtonValue;
  12376. /**
  12377. * Updates the generic gamepad
  12378. */
  12379. update(): void;
  12380. /**
  12381. * Disposes the generic gamepad
  12382. */
  12383. dispose(): void;
  12384. }
  12385. }
  12386. declare module BABYLON {
  12387. /**
  12388. * Defines the types of pose enabled controllers that are supported
  12389. */
  12390. export enum PoseEnabledControllerType {
  12391. /**
  12392. * HTC Vive
  12393. */
  12394. VIVE = 0,
  12395. /**
  12396. * Oculus Rift
  12397. */
  12398. OCULUS = 1,
  12399. /**
  12400. * Windows mixed reality
  12401. */
  12402. WINDOWS = 2,
  12403. /**
  12404. * Samsung gear VR
  12405. */
  12406. GEAR_VR = 3,
  12407. /**
  12408. * Google Daydream
  12409. */
  12410. DAYDREAM = 4,
  12411. /**
  12412. * Generic
  12413. */
  12414. GENERIC = 5
  12415. }
  12416. /**
  12417. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12418. */
  12419. export interface MutableGamepadButton {
  12420. /**
  12421. * Value of the button/trigger
  12422. */
  12423. value: number;
  12424. /**
  12425. * If the button/trigger is currently touched
  12426. */
  12427. touched: boolean;
  12428. /**
  12429. * If the button/trigger is currently pressed
  12430. */
  12431. pressed: boolean;
  12432. }
  12433. /**
  12434. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12435. * @hidden
  12436. */
  12437. export interface ExtendedGamepadButton extends GamepadButton {
  12438. /**
  12439. * If the button/trigger is currently pressed
  12440. */
  12441. readonly pressed: boolean;
  12442. /**
  12443. * If the button/trigger is currently touched
  12444. */
  12445. readonly touched: boolean;
  12446. /**
  12447. * Value of the button/trigger
  12448. */
  12449. readonly value: number;
  12450. }
  12451. /** @hidden */
  12452. export interface _GamePadFactory {
  12453. /**
  12454. * Returns wether or not the current gamepad can be created for this type of controller.
  12455. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12456. * @returns true if it can be created, otherwise false
  12457. */
  12458. canCreate(gamepadInfo: any): boolean;
  12459. /**
  12460. * Creates a new instance of the Gamepad.
  12461. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12462. * @returns the new gamepad instance
  12463. */
  12464. create(gamepadInfo: any): Gamepad;
  12465. }
  12466. /**
  12467. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12468. */
  12469. export class PoseEnabledControllerHelper {
  12470. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12471. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12472. /**
  12473. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12474. * @param vrGamepad the gamepad to initialized
  12475. * @returns a vr controller of the type the gamepad identified as
  12476. */
  12477. static InitiateController(vrGamepad: any): Gamepad;
  12478. }
  12479. /**
  12480. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12481. */
  12482. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12483. private _deviceRoomPosition;
  12484. private _deviceRoomRotationQuaternion;
  12485. /**
  12486. * The device position in babylon space
  12487. */
  12488. devicePosition: Vector3;
  12489. /**
  12490. * The device rotation in babylon space
  12491. */
  12492. deviceRotationQuaternion: Quaternion;
  12493. /**
  12494. * The scale factor of the device in babylon space
  12495. */
  12496. deviceScaleFactor: number;
  12497. /**
  12498. * (Likely devicePosition should be used instead) The device position in its room space
  12499. */
  12500. position: Vector3;
  12501. /**
  12502. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12503. */
  12504. rotationQuaternion: Quaternion;
  12505. /**
  12506. * The type of controller (Eg. Windows mixed reality)
  12507. */
  12508. controllerType: PoseEnabledControllerType;
  12509. protected _calculatedPosition: Vector3;
  12510. private _calculatedRotation;
  12511. /**
  12512. * The raw pose from the device
  12513. */
  12514. rawPose: DevicePose;
  12515. private _trackPosition;
  12516. private _maxRotationDistFromHeadset;
  12517. private _draggedRoomRotation;
  12518. /**
  12519. * @hidden
  12520. */ disableTrackPosition(fixedPosition: Vector3): void;
  12521. /**
  12522. * Internal, the mesh attached to the controller
  12523. * @hidden
  12524. */ mesh: Nullable<AbstractMesh>;
  12525. private _poseControlledCamera;
  12526. private _leftHandSystemQuaternion;
  12527. /**
  12528. * Internal, matrix used to convert room space to babylon space
  12529. * @hidden
  12530. */ deviceToWorld: Matrix;
  12531. /**
  12532. * Node to be used when casting a ray from the controller
  12533. * @hidden
  12534. */ pointingPoseNode: Nullable<TransformNode>;
  12535. /**
  12536. * Name of the child mesh that can be used to cast a ray from the controller
  12537. */
  12538. static readonly POINTING_POSE: string;
  12539. /**
  12540. * Creates a new PoseEnabledController from a gamepad
  12541. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12542. */
  12543. constructor(browserGamepad: any);
  12544. private _workingMatrix;
  12545. /**
  12546. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12547. */
  12548. update(): void;
  12549. /**
  12550. * Updates only the pose device and mesh without doing any button event checking
  12551. */
  12552. protected _updatePoseAndMesh(): void;
  12553. /**
  12554. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12555. * @param poseData raw pose fromthe device
  12556. */
  12557. updateFromDevice(poseData: DevicePose): void;
  12558. /**
  12559. * @hidden
  12560. */ meshAttachedObservable: Observable<AbstractMesh>;
  12561. /**
  12562. * Attaches a mesh to the controller
  12563. * @param mesh the mesh to be attached
  12564. */
  12565. attachToMesh(mesh: AbstractMesh): void;
  12566. /**
  12567. * Attaches the controllers mesh to a camera
  12568. * @param camera the camera the mesh should be attached to
  12569. */
  12570. attachToPoseControlledCamera(camera: TargetCamera): void;
  12571. /**
  12572. * Disposes of the controller
  12573. */
  12574. dispose(): void;
  12575. /**
  12576. * The mesh that is attached to the controller
  12577. */
  12578. readonly mesh: Nullable<AbstractMesh>;
  12579. /**
  12580. * Gets the ray of the controller in the direction the controller is pointing
  12581. * @param length the length the resulting ray should be
  12582. * @returns a ray in the direction the controller is pointing
  12583. */
  12584. getForwardRay(length?: number): Ray;
  12585. }
  12586. }
  12587. declare module BABYLON {
  12588. /**
  12589. * Defines the WebVRController object that represents controllers tracked in 3D space
  12590. */
  12591. export abstract class WebVRController extends PoseEnabledController {
  12592. /**
  12593. * Internal, the default controller model for the controller
  12594. */
  12595. protected _defaultModel: AbstractMesh;
  12596. /**
  12597. * Fired when the trigger state has changed
  12598. */
  12599. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12600. /**
  12601. * Fired when the main button state has changed
  12602. */
  12603. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12604. /**
  12605. * Fired when the secondary button state has changed
  12606. */
  12607. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12608. /**
  12609. * Fired when the pad state has changed
  12610. */
  12611. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12612. /**
  12613. * Fired when controllers stick values have changed
  12614. */
  12615. onPadValuesChangedObservable: Observable<StickValues>;
  12616. /**
  12617. * Array of button availible on the controller
  12618. */
  12619. protected _buttons: Array<MutableGamepadButton>;
  12620. private _onButtonStateChange;
  12621. /**
  12622. * Fired when a controller button's state has changed
  12623. * @param callback the callback containing the button that was modified
  12624. */
  12625. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12626. /**
  12627. * X and Y axis corrisponding to the controllers joystick
  12628. */
  12629. pad: StickValues;
  12630. /**
  12631. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12632. */
  12633. hand: string;
  12634. /**
  12635. * The default controller model for the controller
  12636. */
  12637. readonly defaultModel: AbstractMesh;
  12638. /**
  12639. * Creates a new WebVRController from a gamepad
  12640. * @param vrGamepad the gamepad that the WebVRController should be created from
  12641. */
  12642. constructor(vrGamepad: any);
  12643. /**
  12644. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12645. */
  12646. update(): void;
  12647. /**
  12648. * Function to be called when a button is modified
  12649. */
  12650. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12651. /**
  12652. * Loads a mesh and attaches it to the controller
  12653. * @param scene the scene the mesh should be added to
  12654. * @param meshLoaded callback for when the mesh has been loaded
  12655. */
  12656. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12657. private _setButtonValue;
  12658. private _changes;
  12659. private _checkChanges;
  12660. /**
  12661. * Disposes of th webVRCOntroller
  12662. */
  12663. dispose(): void;
  12664. }
  12665. }
  12666. declare module BABYLON {
  12667. /**
  12668. * The HemisphericLight simulates the ambient environment light,
  12669. * so the passed direction is the light reflection direction, not the incoming direction.
  12670. */
  12671. export class HemisphericLight extends Light {
  12672. /**
  12673. * The groundColor is the light in the opposite direction to the one specified during creation.
  12674. * 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.
  12675. */
  12676. groundColor: Color3;
  12677. /**
  12678. * The light reflection direction, not the incoming direction.
  12679. */
  12680. direction: Vector3;
  12681. /**
  12682. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12683. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12684. * The HemisphericLight can't cast shadows.
  12685. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12686. * @param name The friendly name of the light
  12687. * @param direction The direction of the light reflection
  12688. * @param scene The scene the light belongs to
  12689. */
  12690. constructor(name: string, direction: Vector3, scene: Scene);
  12691. protected _buildUniformLayout(): void;
  12692. /**
  12693. * Returns the string "HemisphericLight".
  12694. * @return The class name
  12695. */
  12696. getClassName(): string;
  12697. /**
  12698. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12699. * Returns the updated direction.
  12700. * @param target The target the direction should point to
  12701. * @return The computed direction
  12702. */
  12703. setDirectionToTarget(target: Vector3): Vector3;
  12704. /**
  12705. * Returns the shadow generator associated to the light.
  12706. * @returns Always null for hemispheric lights because it does not support shadows.
  12707. */
  12708. getShadowGenerator(): Nullable<IShadowGenerator>;
  12709. /**
  12710. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12711. * @param effect The effect to update
  12712. * @param lightIndex The index of the light in the effect to update
  12713. * @returns The hemispheric light
  12714. */
  12715. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12716. /**
  12717. * Computes the world matrix of the node
  12718. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12719. * @param useWasUpdatedFlag defines a reserved property
  12720. * @returns the world matrix
  12721. */
  12722. computeWorldMatrix(): Matrix;
  12723. /**
  12724. * Returns the integer 3.
  12725. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12726. */
  12727. getTypeID(): number;
  12728. /**
  12729. * Prepares the list of defines specific to the light type.
  12730. * @param defines the list of defines
  12731. * @param lightIndex defines the index of the light for the effect
  12732. */
  12733. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12734. }
  12735. }
  12736. declare module BABYLON {
  12737. /** @hidden */
  12738. export var vrMultiviewToSingleviewPixelShader: {
  12739. name: string;
  12740. shader: string;
  12741. };
  12742. }
  12743. declare module BABYLON {
  12744. /**
  12745. * Renders to multiple views with a single draw call
  12746. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12747. */
  12748. export class MultiviewRenderTarget extends RenderTargetTexture {
  12749. /**
  12750. * Creates a multiview render target
  12751. * @param scene scene used with the render target
  12752. * @param size the size of the render target (used for each view)
  12753. */
  12754. constructor(scene: Scene, size?: number | {
  12755. width: number;
  12756. height: number;
  12757. } | {
  12758. ratio: number;
  12759. });
  12760. /**
  12761. * @hidden
  12762. * @param faceIndex the face index, if its a cube texture
  12763. */ bindFrameBuffer(faceIndex?: number): void;
  12764. /**
  12765. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12766. * @returns the view count
  12767. */
  12768. getViewCount(): number;
  12769. }
  12770. }
  12771. declare module BABYLON {
  12772. interface Engine {
  12773. /**
  12774. * Creates a new multiview render target
  12775. * @param width defines the width of the texture
  12776. * @param height defines the height of the texture
  12777. * @returns the created multiview texture
  12778. */
  12779. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12780. /**
  12781. * Binds a multiview framebuffer to be drawn to
  12782. * @param multiviewTexture texture to bind
  12783. */
  12784. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12785. }
  12786. interface Camera {
  12787. /**
  12788. * @hidden
  12789. * 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)
  12790. */ useMultiviewToSingleView: boolean;
  12791. /**
  12792. * @hidden
  12793. * 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)
  12794. */ multiviewTexture: Nullable<RenderTargetTexture>;
  12795. /**
  12796. * @hidden
  12797. * ensures the multiview texture of the camera exists and has the specified width/height
  12798. * @param width height to set on the multiview texture
  12799. * @param height width to set on the multiview texture
  12800. */ resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12801. }
  12802. interface Scene {
  12803. /** @hidden */ transformMatrixR: Matrix;
  12804. /** @hidden */ multiviewSceneUbo: Nullable<UniformBuffer>;
  12805. /** @hidden */ createMultiviewUbo(): void;
  12806. /** @hidden */ updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12807. /** @hidden */ renderMultiviewToSingleView(camera: Camera): void;
  12808. }
  12809. }
  12810. declare module BABYLON {
  12811. /**
  12812. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  12813. * This will not be used for webXR as it supports displaying texture arrays directly
  12814. */
  12815. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  12816. /**
  12817. * Initializes a VRMultiviewToSingleview
  12818. * @param name name of the post process
  12819. * @param camera camera to be applied to
  12820. * @param scaleFactor scaling factor to the size of the output texture
  12821. */
  12822. constructor(name: string, camera: Camera, scaleFactor: number);
  12823. }
  12824. }
  12825. declare module BABYLON {
  12826. /**
  12827. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12828. * IMPORTANT!! The data is right-hand data.
  12829. * @export
  12830. * @interface DevicePose
  12831. */
  12832. export interface DevicePose {
  12833. /**
  12834. * The position of the device, values in array are [x,y,z].
  12835. */
  12836. readonly position: Nullable<Float32Array>;
  12837. /**
  12838. * The linearVelocity of the device, values in array are [x,y,z].
  12839. */
  12840. readonly linearVelocity: Nullable<Float32Array>;
  12841. /**
  12842. * The linearAcceleration of the device, values in array are [x,y,z].
  12843. */
  12844. readonly linearAcceleration: Nullable<Float32Array>;
  12845. /**
  12846. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12847. */
  12848. readonly orientation: Nullable<Float32Array>;
  12849. /**
  12850. * The angularVelocity of the device, values in array are [x,y,z].
  12851. */
  12852. readonly angularVelocity: Nullable<Float32Array>;
  12853. /**
  12854. * The angularAcceleration of the device, values in array are [x,y,z].
  12855. */
  12856. readonly angularAcceleration: Nullable<Float32Array>;
  12857. }
  12858. /**
  12859. * Interface representing a pose controlled object in Babylon.
  12860. * A pose controlled object has both regular pose values as well as pose values
  12861. * from an external device such as a VR head mounted display
  12862. */
  12863. export interface PoseControlled {
  12864. /**
  12865. * The position of the object in babylon space.
  12866. */
  12867. position: Vector3;
  12868. /**
  12869. * The rotation quaternion of the object in babylon space.
  12870. */
  12871. rotationQuaternion: Quaternion;
  12872. /**
  12873. * The position of the device in babylon space.
  12874. */
  12875. devicePosition?: Vector3;
  12876. /**
  12877. * The rotation quaternion of the device in babylon space.
  12878. */
  12879. deviceRotationQuaternion: Quaternion;
  12880. /**
  12881. * The raw pose coming from the device.
  12882. */
  12883. rawPose: Nullable<DevicePose>;
  12884. /**
  12885. * The scale of the device to be used when translating from device space to babylon space.
  12886. */
  12887. deviceScaleFactor: number;
  12888. /**
  12889. * Updates the poseControlled values based on the input device pose.
  12890. * @param poseData the pose data to update the object with
  12891. */
  12892. updateFromDevice(poseData: DevicePose): void;
  12893. }
  12894. /**
  12895. * Set of options to customize the webVRCamera
  12896. */
  12897. export interface WebVROptions {
  12898. /**
  12899. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  12900. */
  12901. trackPosition?: boolean;
  12902. /**
  12903. * Sets the scale of the vrDevice in babylon space. (default: 1)
  12904. */
  12905. positionScale?: number;
  12906. /**
  12907. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  12908. */
  12909. displayName?: string;
  12910. /**
  12911. * Should the native controller meshes be initialized. (default: true)
  12912. */
  12913. controllerMeshes?: boolean;
  12914. /**
  12915. * Creating a default HemiLight only on controllers. (default: true)
  12916. */
  12917. defaultLightingOnControllers?: boolean;
  12918. /**
  12919. * If you don't want to use the default VR button of the helper. (default: false)
  12920. */
  12921. useCustomVRButton?: boolean;
  12922. /**
  12923. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  12924. */
  12925. customVRButton?: HTMLButtonElement;
  12926. /**
  12927. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  12928. */
  12929. rayLength?: number;
  12930. /**
  12931. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  12932. */
  12933. defaultHeight?: number;
  12934. /**
  12935. * If multiview should be used if availible (default: false)
  12936. */
  12937. useMultiview?: boolean;
  12938. }
  12939. /**
  12940. * This represents a WebVR camera.
  12941. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  12942. * @example http://doc.babylonjs.com/how_to/webvr_camera
  12943. */
  12944. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  12945. private webVROptions;
  12946. /**
  12947. * @hidden
  12948. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  12949. */ vrDevice: any;
  12950. /**
  12951. * The rawPose of the vrDevice.
  12952. */
  12953. rawPose: Nullable<DevicePose>;
  12954. private _onVREnabled;
  12955. private _specsVersion;
  12956. private _attached;
  12957. private _frameData;
  12958. protected _descendants: Array<Node>;
  12959. private _deviceRoomPosition;
  12960. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  12961. private _standingMatrix;
  12962. /**
  12963. * Represents device position in babylon space.
  12964. */
  12965. devicePosition: Vector3;
  12966. /**
  12967. * Represents device rotation in babylon space.
  12968. */
  12969. deviceRotationQuaternion: Quaternion;
  12970. /**
  12971. * The scale of the device to be used when translating from device space to babylon space.
  12972. */
  12973. deviceScaleFactor: number;
  12974. private _deviceToWorld;
  12975. private _worldToDevice;
  12976. /**
  12977. * References to the webVR controllers for the vrDevice.
  12978. */
  12979. controllers: Array<WebVRController>;
  12980. /**
  12981. * Emits an event when a controller is attached.
  12982. */
  12983. onControllersAttachedObservable: Observable<WebVRController[]>;
  12984. /**
  12985. * Emits an event when a controller's mesh has been loaded;
  12986. */
  12987. onControllerMeshLoadedObservable: Observable<WebVRController>;
  12988. /**
  12989. * Emits an event when the HMD's pose has been updated.
  12990. */
  12991. onPoseUpdatedFromDeviceObservable: Observable<any>;
  12992. private _poseSet;
  12993. /**
  12994. * If the rig cameras be used as parent instead of this camera.
  12995. */
  12996. rigParenting: boolean;
  12997. private _lightOnControllers;
  12998. private _defaultHeight?;
  12999. /**
  13000. * Instantiates a WebVRFreeCamera.
  13001. * @param name The name of the WebVRFreeCamera
  13002. * @param position The starting anchor position for the camera
  13003. * @param scene The scene the camera belongs to
  13004. * @param webVROptions a set of customizable options for the webVRCamera
  13005. */
  13006. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13007. /**
  13008. * Gets the device distance from the ground in meters.
  13009. * @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.
  13010. */
  13011. deviceDistanceToRoomGround(): number;
  13012. /**
  13013. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13014. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13015. */
  13016. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13017. /**
  13018. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13019. * @returns A promise with a boolean set to if the standing matrix is supported.
  13020. */
  13021. useStandingMatrixAsync(): Promise<boolean>;
  13022. /**
  13023. * Disposes the camera
  13024. */
  13025. dispose(): void;
  13026. /**
  13027. * Gets a vrController by name.
  13028. * @param name The name of the controller to retreive
  13029. * @returns the controller matching the name specified or null if not found
  13030. */
  13031. getControllerByName(name: string): Nullable<WebVRController>;
  13032. private _leftController;
  13033. /**
  13034. * The controller corrisponding to the users left hand.
  13035. */
  13036. readonly leftController: Nullable<WebVRController>;
  13037. private _rightController;
  13038. /**
  13039. * The controller corrisponding to the users right hand.
  13040. */
  13041. readonly rightController: Nullable<WebVRController>;
  13042. /**
  13043. * Casts a ray forward from the vrCamera's gaze.
  13044. * @param length Length of the ray (default: 100)
  13045. * @returns the ray corrisponding to the gaze
  13046. */
  13047. getForwardRay(length?: number): Ray;
  13048. /**
  13049. * @hidden
  13050. * Updates the camera based on device's frame data
  13051. */ checkInputs(): void;
  13052. /**
  13053. * Updates the poseControlled values based on the input device pose.
  13054. * @param poseData Pose coming from the device
  13055. */
  13056. updateFromDevice(poseData: DevicePose): void;
  13057. private _htmlElementAttached;
  13058. private _detachIfAttached;
  13059. /**
  13060. * WebVR's attach control will start broadcasting frames to the device.
  13061. * Note that in certain browsers (chrome for example) this function must be called
  13062. * within a user-interaction callback. Example:
  13063. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13064. *
  13065. * @param element html element to attach the vrDevice to
  13066. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13067. */
  13068. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13069. /**
  13070. * Detaches the camera from the html element and disables VR
  13071. *
  13072. * @param element html element to detach from
  13073. */
  13074. detachControl(element: HTMLElement): void;
  13075. /**
  13076. * @returns the name of this class
  13077. */
  13078. getClassName(): string;
  13079. /**
  13080. * Calls resetPose on the vrDisplay
  13081. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13082. */
  13083. resetToCurrentRotation(): void;
  13084. /**
  13085. * @hidden
  13086. * Updates the rig cameras (left and right eye)
  13087. */ updateRigCameras(): void;
  13088. private _workingVector;
  13089. private _oneVector;
  13090. private _workingMatrix;
  13091. private updateCacheCalled;
  13092. private _correctPositionIfNotTrackPosition;
  13093. /**
  13094. * @hidden
  13095. * Updates the cached values of the camera
  13096. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13097. */ updateCache(ignoreParentClass?: boolean): void;
  13098. /**
  13099. * @hidden
  13100. * Get current device position in babylon world
  13101. */ computeDevicePosition(): void;
  13102. /**
  13103. * Updates the current device position and rotation in the babylon world
  13104. */
  13105. update(): void;
  13106. /**
  13107. * @hidden
  13108. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13109. * @returns an identity matrix
  13110. */ getViewMatrix(): Matrix;
  13111. private _tmpMatrix;
  13112. /**
  13113. * This function is called by the two RIG cameras.
  13114. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13115. * @hidden
  13116. */ getWebVRViewMatrix(): Matrix;
  13117. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  13118. private _onGamepadConnectedObserver;
  13119. private _onGamepadDisconnectedObserver;
  13120. private _updateCacheWhenTrackingDisabledObserver;
  13121. /**
  13122. * Initializes the controllers and their meshes
  13123. */
  13124. initControllers(): void;
  13125. }
  13126. }
  13127. declare module BABYLON {
  13128. /**
  13129. * Size options for a post process
  13130. */
  13131. export type PostProcessOptions = {
  13132. width: number;
  13133. height: number;
  13134. };
  13135. /**
  13136. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13137. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13138. */
  13139. export class PostProcess {
  13140. /** Name of the PostProcess. */
  13141. name: string;
  13142. /**
  13143. * Gets or sets the unique id of the post process
  13144. */
  13145. uniqueId: number;
  13146. /**
  13147. * Width of the texture to apply the post process on
  13148. */
  13149. width: number;
  13150. /**
  13151. * Height of the texture to apply the post process on
  13152. */
  13153. height: number;
  13154. /**
  13155. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13156. * @hidden
  13157. */ outputTexture: Nullable<InternalTexture>;
  13158. /**
  13159. * Sampling mode used by the shader
  13160. * See https://doc.babylonjs.com/classes/3.1/texture
  13161. */
  13162. renderTargetSamplingMode: number;
  13163. /**
  13164. * Clear color to use when screen clearing
  13165. */
  13166. clearColor: Color4;
  13167. /**
  13168. * If the buffer needs to be cleared before applying the post process. (default: true)
  13169. * Should be set to false if shader will overwrite all previous pixels.
  13170. */
  13171. autoClear: boolean;
  13172. /**
  13173. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13174. */
  13175. alphaMode: number;
  13176. /**
  13177. * Sets the setAlphaBlendConstants of the babylon engine
  13178. */
  13179. alphaConstants: Color4;
  13180. /**
  13181. * Animations to be used for the post processing
  13182. */
  13183. animations: Animation[];
  13184. /**
  13185. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13186. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13187. */
  13188. enablePixelPerfectMode: boolean;
  13189. /**
  13190. * Force the postprocess to be applied without taking in account viewport
  13191. */
  13192. forceFullscreenViewport: boolean;
  13193. /**
  13194. * List of inspectable custom properties (used by the Inspector)
  13195. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13196. */
  13197. inspectableCustomProperties: IInspectable[];
  13198. /**
  13199. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13200. *
  13201. * | Value | Type | Description |
  13202. * | ----- | ----------------------------------- | ----------- |
  13203. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13204. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13205. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13206. *
  13207. */
  13208. scaleMode: number;
  13209. /**
  13210. * Force textures to be a power of two (default: false)
  13211. */
  13212. alwaysForcePOT: boolean;
  13213. private _samples;
  13214. /**
  13215. * Number of sample textures (default: 1)
  13216. */
  13217. samples: number;
  13218. /**
  13219. * Modify the scale of the post process to be the same as the viewport (default: false)
  13220. */
  13221. adaptScaleToCurrentViewport: boolean;
  13222. private _camera;
  13223. private _scene;
  13224. private _engine;
  13225. private _options;
  13226. private _reusable;
  13227. private _textureType;
  13228. /**
  13229. * Smart array of input and output textures for the post process.
  13230. * @hidden
  13231. */ textures: SmartArray<InternalTexture>;
  13232. /**
  13233. * The index in _textures that corresponds to the output texture.
  13234. * @hidden
  13235. */ currentRenderTextureInd: number;
  13236. private _effect;
  13237. private _samplers;
  13238. private _fragmentUrl;
  13239. private _vertexUrl;
  13240. private _parameters;
  13241. private _scaleRatio;
  13242. protected _indexParameters: any;
  13243. private _shareOutputWithPostProcess;
  13244. private _texelSize;
  13245. private _forcedOutputTexture;
  13246. /**
  13247. * Returns the fragment url or shader name used in the post process.
  13248. * @returns the fragment url or name in the shader store.
  13249. */
  13250. getEffectName(): string;
  13251. /**
  13252. * An event triggered when the postprocess is activated.
  13253. */
  13254. onActivateObservable: Observable<Camera>;
  13255. private _onActivateObserver;
  13256. /**
  13257. * A function that is added to the onActivateObservable
  13258. */
  13259. onActivate: Nullable<(camera: Camera) => void>;
  13260. /**
  13261. * An event triggered when the postprocess changes its size.
  13262. */
  13263. onSizeChangedObservable: Observable<PostProcess>;
  13264. private _onSizeChangedObserver;
  13265. /**
  13266. * A function that is added to the onSizeChangedObservable
  13267. */
  13268. onSizeChanged: (postProcess: PostProcess) => void;
  13269. /**
  13270. * An event triggered when the postprocess applies its effect.
  13271. */
  13272. onApplyObservable: Observable<Effect>;
  13273. private _onApplyObserver;
  13274. /**
  13275. * A function that is added to the onApplyObservable
  13276. */
  13277. onApply: (effect: Effect) => void;
  13278. /**
  13279. * An event triggered before rendering the postprocess
  13280. */
  13281. onBeforeRenderObservable: Observable<Effect>;
  13282. private _onBeforeRenderObserver;
  13283. /**
  13284. * A function that is added to the onBeforeRenderObservable
  13285. */
  13286. onBeforeRender: (effect: Effect) => void;
  13287. /**
  13288. * An event triggered after rendering the postprocess
  13289. */
  13290. onAfterRenderObservable: Observable<Effect>;
  13291. private _onAfterRenderObserver;
  13292. /**
  13293. * A function that is added to the onAfterRenderObservable
  13294. */
  13295. onAfterRender: (efect: Effect) => void;
  13296. /**
  13297. * 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
  13298. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13299. */
  13300. inputTexture: InternalTexture;
  13301. /**
  13302. * Gets the camera which post process is applied to.
  13303. * @returns The camera the post process is applied to.
  13304. */
  13305. getCamera(): Camera;
  13306. /**
  13307. * Gets the texel size of the postprocess.
  13308. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13309. */
  13310. readonly texelSize: Vector2;
  13311. /**
  13312. * Creates a new instance PostProcess
  13313. * @param name The name of the PostProcess.
  13314. * @param fragmentUrl The url of the fragment shader to be used.
  13315. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13316. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13317. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13318. * @param camera The camera to apply the render pass to.
  13319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13320. * @param engine The engine which the post process will be applied. (default: current engine)
  13321. * @param reusable If the post process can be reused on the same frame. (default: false)
  13322. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13323. * @param textureType Type of textures used when performing the post process. (default: 0)
  13324. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13325. * @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
  13326. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13327. */
  13328. constructor(
  13329. /** Name of the PostProcess. */
  13330. 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);
  13331. /**
  13332. * Gets a string idenfifying the name of the class
  13333. * @returns "PostProcess" string
  13334. */
  13335. getClassName(): string;
  13336. /**
  13337. * Gets the engine which this post process belongs to.
  13338. * @returns The engine the post process was enabled with.
  13339. */
  13340. getEngine(): Engine;
  13341. /**
  13342. * The effect that is created when initializing the post process.
  13343. * @returns The created effect corrisponding the the postprocess.
  13344. */
  13345. getEffect(): Effect;
  13346. /**
  13347. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13348. * @param postProcess The post process to share the output with.
  13349. * @returns This post process.
  13350. */
  13351. shareOutputWith(postProcess: PostProcess): PostProcess;
  13352. /**
  13353. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13354. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13355. */
  13356. useOwnOutput(): void;
  13357. /**
  13358. * Updates the effect with the current post process compile time values and recompiles the shader.
  13359. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13360. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13361. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13362. * @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
  13363. * @param onCompiled Called when the shader has been compiled.
  13364. * @param onError Called if there is an error when compiling a shader.
  13365. */
  13366. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13367. /**
  13368. * The post process is reusable if it can be used multiple times within one frame.
  13369. * @returns If the post process is reusable
  13370. */
  13371. isReusable(): boolean;
  13372. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13373. markTextureDirty(): void;
  13374. /**
  13375. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13376. * 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.
  13377. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13378. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13379. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13380. * @returns The target texture that was bound to be written to.
  13381. */
  13382. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13383. /**
  13384. * If the post process is supported.
  13385. */
  13386. readonly isSupported: boolean;
  13387. /**
  13388. * The aspect ratio of the output texture.
  13389. */
  13390. readonly aspectRatio: number;
  13391. /**
  13392. * Get a value indicating if the post-process is ready to be used
  13393. * @returns true if the post-process is ready (shader is compiled)
  13394. */
  13395. isReady(): boolean;
  13396. /**
  13397. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13398. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13399. */
  13400. apply(): Nullable<Effect>;
  13401. private _disposeTextures;
  13402. /**
  13403. * Disposes the post process.
  13404. * @param camera The camera to dispose the post process on.
  13405. */
  13406. dispose(camera?: Camera): void;
  13407. }
  13408. }
  13409. declare module BABYLON {
  13410. /**
  13411. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13412. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13413. */
  13414. export class PostProcessManager {
  13415. private _scene;
  13416. private _indexBuffer;
  13417. private _vertexBuffers;
  13418. /**
  13419. * Creates a new instance PostProcess
  13420. * @param scene The scene that the post process is associated with.
  13421. */
  13422. constructor(scene: Scene);
  13423. private _prepareBuffers;
  13424. private _buildIndexBuffer;
  13425. /**
  13426. * Rebuilds the vertex buffers of the manager.
  13427. * @hidden
  13428. */ rebuild(): void;
  13429. /**
  13430. * Prepares a frame to be run through a post process.
  13431. * @param sourceTexture The input texture to the post procesess. (default: null)
  13432. * @param postProcesses An array of post processes to be run. (default: null)
  13433. * @returns True if the post processes were able to be run.
  13434. * @hidden
  13435. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13436. /**
  13437. * Manually render a set of post processes to a texture.
  13438. * @param postProcesses An array of post processes to be run.
  13439. * @param targetTexture The target texture to render to.
  13440. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13441. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13442. * @param lodLevel defines which lod of the texture to render to
  13443. */
  13444. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13445. /**
  13446. * Finalize the result of the output of the postprocesses.
  13447. * @param doNotPresent If true the result will not be displayed to the screen.
  13448. * @param targetTexture The target texture to render to.
  13449. * @param faceIndex The index of the face to bind the target texture to.
  13450. * @param postProcesses The array of post processes to render.
  13451. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13452. * @hidden
  13453. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13454. /**
  13455. * Disposes of the post process manager.
  13456. */
  13457. dispose(): void;
  13458. }
  13459. }
  13460. declare module BABYLON {
  13461. interface AbstractScene {
  13462. /**
  13463. * The list of layers (background and foreground) of the scene
  13464. */
  13465. layers: Array<Layer>;
  13466. }
  13467. /**
  13468. * Defines the layer scene component responsible to manage any layers
  13469. * in a given scene.
  13470. */
  13471. export class LayerSceneComponent implements ISceneComponent {
  13472. /**
  13473. * The component name helpfull to identify the component in the list of scene components.
  13474. */
  13475. readonly name: string;
  13476. /**
  13477. * The scene the component belongs to.
  13478. */
  13479. scene: Scene;
  13480. private _engine;
  13481. /**
  13482. * Creates a new instance of the component for the given scene
  13483. * @param scene Defines the scene to register the component in
  13484. */
  13485. constructor(scene: Scene);
  13486. /**
  13487. * Registers the component in a given scene
  13488. */
  13489. register(): void;
  13490. /**
  13491. * Rebuilds the elements related to this component in case of
  13492. * context lost for instance.
  13493. */
  13494. rebuild(): void;
  13495. /**
  13496. * Disposes the component and the associated ressources.
  13497. */
  13498. dispose(): void;
  13499. private _draw;
  13500. private _drawCameraPredicate;
  13501. private _drawCameraBackground;
  13502. private _drawCameraForeground;
  13503. private _drawRenderTargetPredicate;
  13504. private _drawRenderTargetBackground;
  13505. private _drawRenderTargetForeground;
  13506. }
  13507. }
  13508. declare module BABYLON {
  13509. /** @hidden */
  13510. export var layerPixelShader: {
  13511. name: string;
  13512. shader: string;
  13513. };
  13514. }
  13515. declare module BABYLON {
  13516. /** @hidden */
  13517. export var layerVertexShader: {
  13518. name: string;
  13519. shader: string;
  13520. };
  13521. }
  13522. declare module BABYLON {
  13523. /**
  13524. * This represents a full screen 2d layer.
  13525. * This can be useful to display a picture in the background of your scene for instance.
  13526. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13527. */
  13528. export class Layer {
  13529. /**
  13530. * Define the name of the layer.
  13531. */
  13532. name: string;
  13533. /**
  13534. * Define the texture the layer should display.
  13535. */
  13536. texture: Nullable<Texture>;
  13537. /**
  13538. * Is the layer in background or foreground.
  13539. */
  13540. isBackground: boolean;
  13541. /**
  13542. * Define the color of the layer (instead of texture).
  13543. */
  13544. color: Color4;
  13545. /**
  13546. * Define the scale of the layer in order to zoom in out of the texture.
  13547. */
  13548. scale: Vector2;
  13549. /**
  13550. * Define an offset for the layer in order to shift the texture.
  13551. */
  13552. offset: Vector2;
  13553. /**
  13554. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13555. */
  13556. alphaBlendingMode: number;
  13557. /**
  13558. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13559. * Alpha test will not mix with the background color in case of transparency.
  13560. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13561. */
  13562. alphaTest: boolean;
  13563. /**
  13564. * Define a mask to restrict the layer to only some of the scene cameras.
  13565. */
  13566. layerMask: number;
  13567. /**
  13568. * Define the list of render target the layer is visible into.
  13569. */
  13570. renderTargetTextures: RenderTargetTexture[];
  13571. /**
  13572. * Define if the layer is only used in renderTarget or if it also
  13573. * renders in the main frame buffer of the canvas.
  13574. */
  13575. renderOnlyInRenderTargetTextures: boolean;
  13576. private _scene;
  13577. private _vertexBuffers;
  13578. private _indexBuffer;
  13579. private _effect;
  13580. private _alphaTestEffect;
  13581. /**
  13582. * An event triggered when the layer is disposed.
  13583. */
  13584. onDisposeObservable: Observable<Layer>;
  13585. private _onDisposeObserver;
  13586. /**
  13587. * Back compatibility with callback before the onDisposeObservable existed.
  13588. * The set callback will be triggered when the layer has been disposed.
  13589. */
  13590. onDispose: () => void;
  13591. /**
  13592. * An event triggered before rendering the scene
  13593. */
  13594. onBeforeRenderObservable: Observable<Layer>;
  13595. private _onBeforeRenderObserver;
  13596. /**
  13597. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13598. * The set callback will be triggered just before rendering the layer.
  13599. */
  13600. onBeforeRender: () => void;
  13601. /**
  13602. * An event triggered after rendering the scene
  13603. */
  13604. onAfterRenderObservable: Observable<Layer>;
  13605. private _onAfterRenderObserver;
  13606. /**
  13607. * Back compatibility with callback before the onAfterRenderObservable existed.
  13608. * The set callback will be triggered just after rendering the layer.
  13609. */
  13610. onAfterRender: () => void;
  13611. /**
  13612. * Instantiates a new layer.
  13613. * This represents a full screen 2d layer.
  13614. * This can be useful to display a picture in the background of your scene for instance.
  13615. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13616. * @param name Define the name of the layer in the scene
  13617. * @param imgUrl Define the url of the texture to display in the layer
  13618. * @param scene Define the scene the layer belongs to
  13619. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13620. * @param color Defines a color for the layer
  13621. */
  13622. constructor(
  13623. /**
  13624. * Define the name of the layer.
  13625. */
  13626. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13627. private _createIndexBuffer;
  13628. /** @hidden */ rebuild(): void;
  13629. /**
  13630. * Renders the layer in the scene.
  13631. */
  13632. render(): void;
  13633. /**
  13634. * Disposes and releases the associated ressources.
  13635. */
  13636. dispose(): void;
  13637. }
  13638. }
  13639. declare module BABYLON {
  13640. interface AbstractScene {
  13641. /**
  13642. * The list of procedural textures added to the scene
  13643. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13644. */
  13645. proceduralTextures: Array<ProceduralTexture>;
  13646. }
  13647. /**
  13648. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13649. * in a given scene.
  13650. */
  13651. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13652. /**
  13653. * The component name helpfull to identify the component in the list of scene components.
  13654. */
  13655. readonly name: string;
  13656. /**
  13657. * The scene the component belongs to.
  13658. */
  13659. scene: Scene;
  13660. /**
  13661. * Creates a new instance of the component for the given scene
  13662. * @param scene Defines the scene to register the component in
  13663. */
  13664. constructor(scene: Scene);
  13665. /**
  13666. * Registers the component in a given scene
  13667. */
  13668. register(): void;
  13669. /**
  13670. * Rebuilds the elements related to this component in case of
  13671. * context lost for instance.
  13672. */
  13673. rebuild(): void;
  13674. /**
  13675. * Disposes the component and the associated ressources.
  13676. */
  13677. dispose(): void;
  13678. private _beforeClear;
  13679. }
  13680. }
  13681. declare module BABYLON {
  13682. /** @hidden */
  13683. export var proceduralVertexShader: {
  13684. name: string;
  13685. shader: string;
  13686. };
  13687. }
  13688. declare module BABYLON {
  13689. /**
  13690. * 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.
  13691. * This is the base class of any Procedural texture and contains most of the shareable code.
  13692. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13693. */
  13694. export class ProceduralTexture extends Texture {
  13695. isCube: boolean;
  13696. /**
  13697. * Define if the texture is enabled or not (disabled texture will not render)
  13698. */
  13699. isEnabled: boolean;
  13700. /**
  13701. * Define if the texture must be cleared before rendering (default is true)
  13702. */
  13703. autoClear: boolean;
  13704. /**
  13705. * Callback called when the texture is generated
  13706. */
  13707. onGenerated: () => void;
  13708. /**
  13709. * Event raised when the texture is generated
  13710. */
  13711. onGeneratedObservable: Observable<ProceduralTexture>;
  13712. /** @hidden */ generateMipMaps: boolean;
  13713. /** @hidden **/ effect: Effect;
  13714. /** @hidden */ textures: {
  13715. [key: string]: Texture;
  13716. };
  13717. private _size;
  13718. private _currentRefreshId;
  13719. private _refreshRate;
  13720. private _vertexBuffers;
  13721. private _indexBuffer;
  13722. private _uniforms;
  13723. private _samplers;
  13724. private _fragment;
  13725. private _floats;
  13726. private _ints;
  13727. private _floatsArrays;
  13728. private _colors3;
  13729. private _colors4;
  13730. private _vectors2;
  13731. private _vectors3;
  13732. private _matrices;
  13733. private _fallbackTexture;
  13734. private _fallbackTextureUsed;
  13735. private _engine;
  13736. private _cachedDefines;
  13737. private _contentUpdateId;
  13738. private _contentData;
  13739. /**
  13740. * Instantiates a new procedural texture.
  13741. * 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.
  13742. * This is the base class of any Procedural texture and contains most of the shareable code.
  13743. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13744. * @param name Define the name of the texture
  13745. * @param size Define the size of the texture to create
  13746. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13747. * @param scene Define the scene the texture belongs to
  13748. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13749. * @param generateMipMaps Define if the texture should creates mip maps or not
  13750. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13751. */
  13752. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13753. /**
  13754. * The effect that is created when initializing the post process.
  13755. * @returns The created effect corrisponding the the postprocess.
  13756. */
  13757. getEffect(): Effect;
  13758. /**
  13759. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13760. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13761. */
  13762. getContent(): Nullable<ArrayBufferView>;
  13763. private _createIndexBuffer;
  13764. /** @hidden */ rebuild(): void;
  13765. /**
  13766. * Resets the texture in order to recreate its associated resources.
  13767. * This can be called in case of context loss
  13768. */
  13769. reset(): void;
  13770. protected _getDefines(): string;
  13771. /**
  13772. * Is the texture ready to be used ? (rendered at least once)
  13773. * @returns true if ready, otherwise, false.
  13774. */
  13775. isReady(): boolean;
  13776. /**
  13777. * Resets the refresh counter of the texture and start bak from scratch.
  13778. * Could be useful to regenerate the texture if it is setup to render only once.
  13779. */
  13780. resetRefreshCounter(): void;
  13781. /**
  13782. * Set the fragment shader to use in order to render the texture.
  13783. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13784. */
  13785. setFragment(fragment: any): void;
  13786. /**
  13787. * Define the refresh rate of the texture or the rendering frequency.
  13788. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13789. */
  13790. refreshRate: number;
  13791. /** @hidden */ shouldRender(): boolean;
  13792. /**
  13793. * Get the size the texture is rendering at.
  13794. * @returns the size (texture is always squared)
  13795. */
  13796. getRenderSize(): number;
  13797. /**
  13798. * Resize the texture to new value.
  13799. * @param size Define the new size the texture should have
  13800. * @param generateMipMaps Define whether the new texture should create mip maps
  13801. */
  13802. resize(size: number, generateMipMaps: boolean): void;
  13803. private _checkUniform;
  13804. /**
  13805. * Set a texture in the shader program used to render.
  13806. * @param name Define the name of the uniform samplers as defined in the shader
  13807. * @param texture Define the texture to bind to this sampler
  13808. * @return the texture itself allowing "fluent" like uniform updates
  13809. */
  13810. setTexture(name: string, texture: Texture): ProceduralTexture;
  13811. /**
  13812. * Set a float in the shader.
  13813. * @param name Define the name of the uniform as defined in the shader
  13814. * @param value Define the value to give to the uniform
  13815. * @return the texture itself allowing "fluent" like uniform updates
  13816. */
  13817. setFloat(name: string, value: number): ProceduralTexture;
  13818. /**
  13819. * Set a int in the shader.
  13820. * @param name Define the name of the uniform as defined in the shader
  13821. * @param value Define the value to give to the uniform
  13822. * @return the texture itself allowing "fluent" like uniform updates
  13823. */
  13824. setInt(name: string, value: number): ProceduralTexture;
  13825. /**
  13826. * Set an array of floats in the shader.
  13827. * @param name Define the name of the uniform as defined in the shader
  13828. * @param value Define the value to give to the uniform
  13829. * @return the texture itself allowing "fluent" like uniform updates
  13830. */
  13831. setFloats(name: string, value: number[]): ProceduralTexture;
  13832. /**
  13833. * Set a vec3 in the shader from a Color3.
  13834. * @param name Define the name of the uniform as defined in the shader
  13835. * @param value Define the value to give to the uniform
  13836. * @return the texture itself allowing "fluent" like uniform updates
  13837. */
  13838. setColor3(name: string, value: Color3): ProceduralTexture;
  13839. /**
  13840. * Set a vec4 in the shader from a Color4.
  13841. * @param name Define the name of the uniform as defined in the shader
  13842. * @param value Define the value to give to the uniform
  13843. * @return the texture itself allowing "fluent" like uniform updates
  13844. */
  13845. setColor4(name: string, value: Color4): ProceduralTexture;
  13846. /**
  13847. * Set a vec2 in the shader from a Vector2.
  13848. * @param name Define the name of the uniform as defined in the shader
  13849. * @param value Define the value to give to the uniform
  13850. * @return the texture itself allowing "fluent" like uniform updates
  13851. */
  13852. setVector2(name: string, value: Vector2): ProceduralTexture;
  13853. /**
  13854. * Set a vec3 in the shader from a Vector3.
  13855. * @param name Define the name of the uniform as defined in the shader
  13856. * @param value Define the value to give to the uniform
  13857. * @return the texture itself allowing "fluent" like uniform updates
  13858. */
  13859. setVector3(name: string, value: Vector3): ProceduralTexture;
  13860. /**
  13861. * Set a mat4 in the shader from a MAtrix.
  13862. * @param name Define the name of the uniform as defined in the shader
  13863. * @param value Define the value to give to the uniform
  13864. * @return the texture itself allowing "fluent" like uniform updates
  13865. */
  13866. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13867. /**
  13868. * Render the texture to its associated render target.
  13869. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13870. */
  13871. render(useCameraPostProcess?: boolean): void;
  13872. /**
  13873. * Clone the texture.
  13874. * @returns the cloned texture
  13875. */
  13876. clone(): ProceduralTexture;
  13877. /**
  13878. * Dispose the texture and release its asoociated resources.
  13879. */
  13880. dispose(): void;
  13881. }
  13882. }
  13883. declare module BABYLON {
  13884. /**
  13885. * This represents the base class for particle system in Babylon.
  13886. * 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.
  13887. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13888. * @example https://doc.babylonjs.com/babylon101/particles
  13889. */
  13890. export class BaseParticleSystem {
  13891. /**
  13892. * Source color is added to the destination color without alpha affecting the result
  13893. */
  13894. static BLENDMODE_ONEONE: number;
  13895. /**
  13896. * Blend current color and particle color using particle’s alpha
  13897. */
  13898. static BLENDMODE_STANDARD: number;
  13899. /**
  13900. * Add current color and particle color multiplied by particle’s alpha
  13901. */
  13902. static BLENDMODE_ADD: number;
  13903. /**
  13904. * Multiply current color with particle color
  13905. */
  13906. static BLENDMODE_MULTIPLY: number;
  13907. /**
  13908. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13909. */
  13910. static BLENDMODE_MULTIPLYADD: number;
  13911. /**
  13912. * List of animations used by the particle system.
  13913. */
  13914. animations: Animation[];
  13915. /**
  13916. * The id of the Particle system.
  13917. */
  13918. id: string;
  13919. /**
  13920. * The friendly name of the Particle system.
  13921. */
  13922. name: string;
  13923. /**
  13924. * The rendering group used by the Particle system to chose when to render.
  13925. */
  13926. renderingGroupId: number;
  13927. /**
  13928. * The emitter represents the Mesh or position we are attaching the particle system to.
  13929. */
  13930. emitter: Nullable<AbstractMesh | Vector3>;
  13931. /**
  13932. * The maximum number of particles to emit per frame
  13933. */
  13934. emitRate: number;
  13935. /**
  13936. * If you want to launch only a few particles at once, that can be done, as well.
  13937. */
  13938. manualEmitCount: number;
  13939. /**
  13940. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13941. */
  13942. updateSpeed: number;
  13943. /**
  13944. * The amount of time the particle system is running (depends of the overall update speed).
  13945. */
  13946. targetStopDuration: number;
  13947. /**
  13948. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13949. */
  13950. disposeOnStop: boolean;
  13951. /**
  13952. * Minimum power of emitting particles.
  13953. */
  13954. minEmitPower: number;
  13955. /**
  13956. * Maximum power of emitting particles.
  13957. */
  13958. maxEmitPower: number;
  13959. /**
  13960. * Minimum life time of emitting particles.
  13961. */
  13962. minLifeTime: number;
  13963. /**
  13964. * Maximum life time of emitting particles.
  13965. */
  13966. maxLifeTime: number;
  13967. /**
  13968. * Minimum Size of emitting particles.
  13969. */
  13970. minSize: number;
  13971. /**
  13972. * Maximum Size of emitting particles.
  13973. */
  13974. maxSize: number;
  13975. /**
  13976. * Minimum scale of emitting particles on X axis.
  13977. */
  13978. minScaleX: number;
  13979. /**
  13980. * Maximum scale of emitting particles on X axis.
  13981. */
  13982. maxScaleX: number;
  13983. /**
  13984. * Minimum scale of emitting particles on Y axis.
  13985. */
  13986. minScaleY: number;
  13987. /**
  13988. * Maximum scale of emitting particles on Y axis.
  13989. */
  13990. maxScaleY: number;
  13991. /**
  13992. * Gets or sets the minimal initial rotation in radians.
  13993. */
  13994. minInitialRotation: number;
  13995. /**
  13996. * Gets or sets the maximal initial rotation in radians.
  13997. */
  13998. maxInitialRotation: number;
  13999. /**
  14000. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14001. */
  14002. minAngularSpeed: number;
  14003. /**
  14004. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14005. */
  14006. maxAngularSpeed: number;
  14007. /**
  14008. * The texture used to render each particle. (this can be a spritesheet)
  14009. */
  14010. particleTexture: Nullable<Texture>;
  14011. /**
  14012. * The layer mask we are rendering the particles through.
  14013. */
  14014. layerMask: number;
  14015. /**
  14016. * This can help using your own shader to render the particle system.
  14017. * The according effect will be created
  14018. */
  14019. customShader: any;
  14020. /**
  14021. * By default particle system starts as soon as they are created. This prevents the
  14022. * automatic start to happen and let you decide when to start emitting particles.
  14023. */
  14024. preventAutoStart: boolean;
  14025. private _noiseTexture;
  14026. /**
  14027. * Gets or sets a texture used to add random noise to particle positions
  14028. */
  14029. noiseTexture: Nullable<ProceduralTexture>;
  14030. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14031. noiseStrength: Vector3;
  14032. /**
  14033. * Callback triggered when the particle animation is ending.
  14034. */
  14035. onAnimationEnd: Nullable<() => void>;
  14036. /**
  14037. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14038. */
  14039. blendMode: number;
  14040. /**
  14041. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14042. * to override the particles.
  14043. */
  14044. forceDepthWrite: boolean;
  14045. /** 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 */
  14046. preWarmCycles: number;
  14047. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14048. preWarmStepOffset: number;
  14049. /**
  14050. * 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)
  14051. */
  14052. spriteCellChangeSpeed: number;
  14053. /**
  14054. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14055. */
  14056. startSpriteCellID: number;
  14057. /**
  14058. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14059. */
  14060. endSpriteCellID: number;
  14061. /**
  14062. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14063. */
  14064. spriteCellWidth: number;
  14065. /**
  14066. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14067. */
  14068. spriteCellHeight: number;
  14069. /**
  14070. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14071. */
  14072. spriteRandomStartCell: boolean;
  14073. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14074. translationPivot: Vector2;
  14075. /** @hidden */
  14076. protected _isAnimationSheetEnabled: boolean;
  14077. /**
  14078. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14079. */
  14080. beginAnimationOnStart: boolean;
  14081. /**
  14082. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14083. */
  14084. beginAnimationFrom: number;
  14085. /**
  14086. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14087. */
  14088. beginAnimationTo: number;
  14089. /**
  14090. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14091. */
  14092. beginAnimationLoop: boolean;
  14093. /**
  14094. * Gets or sets a world offset applied to all particles
  14095. */
  14096. worldOffset: Vector3;
  14097. /**
  14098. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14099. */
  14100. isAnimationSheetEnabled: boolean;
  14101. /**
  14102. * Get hosting scene
  14103. * @returns the scene
  14104. */
  14105. getScene(): Scene;
  14106. /**
  14107. * You can use gravity if you want to give an orientation to your particles.
  14108. */
  14109. gravity: Vector3;
  14110. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14111. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14112. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14113. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14114. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14115. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14116. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14117. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14118. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14119. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14120. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14121. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14122. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14123. /**
  14124. * Defines the delay in milliseconds before starting the system (0 by default)
  14125. */
  14126. startDelay: number;
  14127. /**
  14128. * Gets the current list of drag gradients.
  14129. * You must use addDragGradient and removeDragGradient to udpate this list
  14130. * @returns the list of drag gradients
  14131. */
  14132. getDragGradients(): Nullable<Array<FactorGradient>>;
  14133. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14134. limitVelocityDamping: number;
  14135. /**
  14136. * Gets the current list of limit velocity gradients.
  14137. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14138. * @returns the list of limit velocity gradients
  14139. */
  14140. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14141. /**
  14142. * Gets the current list of color gradients.
  14143. * You must use addColorGradient and removeColorGradient to udpate this list
  14144. * @returns the list of color gradients
  14145. */
  14146. getColorGradients(): Nullable<Array<ColorGradient>>;
  14147. /**
  14148. * Gets the current list of size gradients.
  14149. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14150. * @returns the list of size gradients
  14151. */
  14152. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14153. /**
  14154. * Gets the current list of color remap gradients.
  14155. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14156. * @returns the list of color remap gradients
  14157. */
  14158. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14159. /**
  14160. * Gets the current list of alpha remap gradients.
  14161. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14162. * @returns the list of alpha remap gradients
  14163. */
  14164. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14165. /**
  14166. * Gets the current list of life time gradients.
  14167. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14168. * @returns the list of life time gradients
  14169. */
  14170. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14171. /**
  14172. * Gets the current list of angular speed gradients.
  14173. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14174. * @returns the list of angular speed gradients
  14175. */
  14176. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14177. /**
  14178. * Gets the current list of velocity gradients.
  14179. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14180. * @returns the list of velocity gradients
  14181. */
  14182. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14183. /**
  14184. * Gets the current list of start size gradients.
  14185. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14186. * @returns the list of start size gradients
  14187. */
  14188. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14189. /**
  14190. * Gets the current list of emit rate gradients.
  14191. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14192. * @returns the list of emit rate gradients
  14193. */
  14194. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14195. /**
  14196. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14197. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14198. */
  14199. direction1: Vector3;
  14200. /**
  14201. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14202. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14203. */
  14204. direction2: Vector3;
  14205. /**
  14206. * 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.
  14207. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14208. */
  14209. minEmitBox: Vector3;
  14210. /**
  14211. * 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.
  14212. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14213. */
  14214. maxEmitBox: Vector3;
  14215. /**
  14216. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14217. */
  14218. color1: Color4;
  14219. /**
  14220. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14221. */
  14222. color2: Color4;
  14223. /**
  14224. * Color the particle will have at the end of its lifetime
  14225. */
  14226. colorDead: Color4;
  14227. /**
  14228. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14229. */
  14230. textureMask: Color4;
  14231. /**
  14232. * The particle emitter type defines the emitter used by the particle system.
  14233. * It can be for example box, sphere, or cone...
  14234. */
  14235. particleEmitterType: IParticleEmitterType;
  14236. /** @hidden */ isSubEmitter: boolean;
  14237. /**
  14238. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14239. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14240. */
  14241. billboardMode: number;
  14242. protected _isBillboardBased: boolean;
  14243. /**
  14244. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14245. */
  14246. isBillboardBased: boolean;
  14247. /**
  14248. * The scene the particle system belongs to.
  14249. */
  14250. protected _scene: Scene;
  14251. /**
  14252. * Local cache of defines for image processing.
  14253. */
  14254. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14255. /**
  14256. * Default configuration related to image processing available in the standard Material.
  14257. */
  14258. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14259. /**
  14260. * Gets the image processing configuration used either in this material.
  14261. */
  14262. /**
  14263. * Sets the Default image processing configuration used either in the this material.
  14264. *
  14265. * If sets to null, the scene one is in use.
  14266. */
  14267. imageProcessingConfiguration: ImageProcessingConfiguration;
  14268. /**
  14269. * Attaches a new image processing configuration to the Standard Material.
  14270. * @param configuration
  14271. */
  14272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14273. /** @hidden */
  14274. protected _reset(): void;
  14275. /** @hidden */
  14276. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14277. /**
  14278. * Instantiates a particle system.
  14279. * 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.
  14280. * @param name The name of the particle system
  14281. */
  14282. constructor(name: string);
  14283. /**
  14284. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14285. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14286. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14287. * @returns the emitter
  14288. */
  14289. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14290. /**
  14291. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14292. * @param radius The radius of the hemisphere to emit from
  14293. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14294. * @returns the emitter
  14295. */
  14296. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14297. /**
  14298. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14299. * @param radius The radius of the sphere to emit from
  14300. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14301. * @returns the emitter
  14302. */
  14303. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14304. /**
  14305. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14306. * @param radius The radius of the sphere to emit from
  14307. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14308. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14309. * @returns the emitter
  14310. */
  14311. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14312. /**
  14313. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14314. * @param radius The radius of the emission cylinder
  14315. * @param height The height of the emission cylinder
  14316. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14317. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14318. * @returns the emitter
  14319. */
  14320. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14321. /**
  14322. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14323. * @param radius The radius of the cylinder to emit from
  14324. * @param height The height of the emission cylinder
  14325. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14326. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14327. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14328. * @returns the emitter
  14329. */
  14330. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14331. /**
  14332. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14333. * @param radius The radius of the cone to emit from
  14334. * @param angle The base angle of the cone
  14335. * @returns the emitter
  14336. */
  14337. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14338. /**
  14339. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14342. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14343. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14344. * @returns the emitter
  14345. */
  14346. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14347. }
  14348. }
  14349. declare module BABYLON {
  14350. /**
  14351. * Type of sub emitter
  14352. */
  14353. export enum SubEmitterType {
  14354. /**
  14355. * Attached to the particle over it's lifetime
  14356. */
  14357. ATTACHED = 0,
  14358. /**
  14359. * Created when the particle dies
  14360. */
  14361. END = 1
  14362. }
  14363. /**
  14364. * Sub emitter class used to emit particles from an existing particle
  14365. */
  14366. export class SubEmitter {
  14367. /**
  14368. * the particle system to be used by the sub emitter
  14369. */
  14370. particleSystem: ParticleSystem;
  14371. /**
  14372. * Type of the submitter (Default: END)
  14373. */
  14374. type: SubEmitterType;
  14375. /**
  14376. * 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)
  14377. * Note: This only is supported when using an emitter of type Mesh
  14378. */
  14379. inheritDirection: boolean;
  14380. /**
  14381. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14382. */
  14383. inheritedVelocityAmount: number;
  14384. /**
  14385. * Creates a sub emitter
  14386. * @param particleSystem the particle system to be used by the sub emitter
  14387. */
  14388. constructor(
  14389. /**
  14390. * the particle system to be used by the sub emitter
  14391. */
  14392. particleSystem: ParticleSystem);
  14393. /**
  14394. * Clones the sub emitter
  14395. * @returns the cloned sub emitter
  14396. */
  14397. clone(): SubEmitter;
  14398. /**
  14399. * Serialize current object to a JSON object
  14400. * @returns the serialized object
  14401. */
  14402. serialize(): any;
  14403. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14404. /**
  14405. * Creates a new SubEmitter from a serialized JSON version
  14406. * @param serializationObject defines the JSON object to read from
  14407. * @param scene defines the hosting scene
  14408. * @param rootUrl defines the rootUrl for data loading
  14409. * @returns a new SubEmitter
  14410. */
  14411. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14412. /** Release associated resources */
  14413. dispose(): void;
  14414. }
  14415. }
  14416. declare module BABYLON {
  14417. /** @hidden */
  14418. export var clipPlaneFragmentDeclaration: {
  14419. name: string;
  14420. shader: string;
  14421. };
  14422. }
  14423. declare module BABYLON {
  14424. /** @hidden */
  14425. export var imageProcessingDeclaration: {
  14426. name: string;
  14427. shader: string;
  14428. };
  14429. }
  14430. declare module BABYLON {
  14431. /** @hidden */
  14432. export var imageProcessingFunctions: {
  14433. name: string;
  14434. shader: string;
  14435. };
  14436. }
  14437. declare module BABYLON {
  14438. /** @hidden */
  14439. export var clipPlaneFragment: {
  14440. name: string;
  14441. shader: string;
  14442. };
  14443. }
  14444. declare module BABYLON {
  14445. /** @hidden */
  14446. export var particlesPixelShader: {
  14447. name: string;
  14448. shader: string;
  14449. };
  14450. }
  14451. declare module BABYLON {
  14452. /** @hidden */
  14453. export var clipPlaneVertexDeclaration: {
  14454. name: string;
  14455. shader: string;
  14456. };
  14457. }
  14458. declare module BABYLON {
  14459. /** @hidden */
  14460. export var clipPlaneVertex: {
  14461. name: string;
  14462. shader: string;
  14463. };
  14464. }
  14465. declare module BABYLON {
  14466. /** @hidden */
  14467. export var particlesVertexShader: {
  14468. name: string;
  14469. shader: string;
  14470. };
  14471. }
  14472. declare module BABYLON {
  14473. /**
  14474. * This represents a particle system in Babylon.
  14475. * 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.
  14476. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14477. * @example https://doc.babylonjs.com/babylon101/particles
  14478. */
  14479. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14480. /**
  14481. * Billboard mode will only apply to Y axis
  14482. */
  14483. static readonly BILLBOARDMODE_Y: number;
  14484. /**
  14485. * Billboard mode will apply to all axes
  14486. */
  14487. static readonly BILLBOARDMODE_ALL: number;
  14488. /**
  14489. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14490. */
  14491. static readonly BILLBOARDMODE_STRETCHED: number;
  14492. /**
  14493. * This function can be defined to provide custom update for active particles.
  14494. * This function will be called instead of regular update (age, position, color, etc.).
  14495. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14496. */
  14497. updateFunction: (particles: Particle[]) => void;
  14498. private _emitterWorldMatrix;
  14499. /**
  14500. * This function can be defined to specify initial direction for every new particle.
  14501. * It by default use the emitterType defined function
  14502. */
  14503. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14504. /**
  14505. * This function can be defined to specify initial position for every new particle.
  14506. * It by default use the emitterType defined function
  14507. */
  14508. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14509. /**
  14510. * @hidden
  14511. */ inheritedVelocityOffset: Vector3;
  14512. /**
  14513. * An event triggered when the system is disposed
  14514. */
  14515. onDisposeObservable: Observable<ParticleSystem>;
  14516. private _onDisposeObserver;
  14517. /**
  14518. * Sets a callback that will be triggered when the system is disposed
  14519. */
  14520. onDispose: () => void;
  14521. private _particles;
  14522. private _epsilon;
  14523. private _capacity;
  14524. private _stockParticles;
  14525. private _newPartsExcess;
  14526. private _vertexData;
  14527. private _vertexBuffer;
  14528. private _vertexBuffers;
  14529. private _spriteBuffer;
  14530. private _indexBuffer;
  14531. private _effect;
  14532. private _customEffect;
  14533. private _cachedDefines;
  14534. private _scaledColorStep;
  14535. private _colorDiff;
  14536. private _scaledDirection;
  14537. private _scaledGravity;
  14538. private _currentRenderId;
  14539. private _alive;
  14540. private _useInstancing;
  14541. private _started;
  14542. private _stopped;
  14543. private _actualFrame;
  14544. private _scaledUpdateSpeed;
  14545. private _vertexBufferSize;
  14546. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14547. /** @hidden */ currentEmitRate1: number;
  14548. /** @hidden */ currentEmitRate2: number;
  14549. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14550. /** @hidden */ currentStartSize1: number;
  14551. /** @hidden */ currentStartSize2: number;
  14552. private readonly _rawTextureWidth;
  14553. private _rampGradientsTexture;
  14554. private _useRampGradients;
  14555. /** Gets or sets a boolean indicating that ramp gradients must be used
  14556. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14557. */
  14558. useRampGradients: boolean;
  14559. /**
  14560. * 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.
  14561. * 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: [])
  14562. */
  14563. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14564. private _subEmitters;
  14565. /**
  14566. * @hidden
  14567. * If the particle systems emitter should be disposed when the particle system is disposed
  14568. */ disposeEmitterOnDispose: boolean;
  14569. /**
  14570. * The current active Sub-systems, this property is used by the root particle system only.
  14571. */
  14572. activeSubSystems: Array<ParticleSystem>;
  14573. private _rootParticleSystem;
  14574. /**
  14575. * Gets the current list of active particles
  14576. */
  14577. readonly particles: Particle[];
  14578. /**
  14579. * Returns the string "ParticleSystem"
  14580. * @returns a string containing the class name
  14581. */
  14582. getClassName(): string;
  14583. /**
  14584. * Instantiates a particle system.
  14585. * 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.
  14586. * @param name The name of the particle system
  14587. * @param capacity The max number of particles alive at the same time
  14588. * @param scene The scene the particle system belongs to
  14589. * @param customEffect a custom effect used to change the way particles are rendered by default
  14590. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14591. * @param epsilon Offset used to render the particles
  14592. */
  14593. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14594. private _addFactorGradient;
  14595. private _removeFactorGradient;
  14596. /**
  14597. * Adds a new life time gradient
  14598. * @param gradient defines the gradient to use (between 0 and 1)
  14599. * @param factor defines the life time factor to affect to the specified gradient
  14600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14601. * @returns the current particle system
  14602. */
  14603. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14604. /**
  14605. * Remove a specific life time gradient
  14606. * @param gradient defines the gradient to remove
  14607. * @returns the current particle system
  14608. */
  14609. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14610. /**
  14611. * Adds a new size gradient
  14612. * @param gradient defines the gradient to use (between 0 and 1)
  14613. * @param factor defines the size factor to affect to the specified gradient
  14614. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14615. * @returns the current particle system
  14616. */
  14617. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14618. /**
  14619. * Remove a specific size gradient
  14620. * @param gradient defines the gradient to remove
  14621. * @returns the current particle system
  14622. */
  14623. removeSizeGradient(gradient: number): IParticleSystem;
  14624. /**
  14625. * Adds a new color remap gradient
  14626. * @param gradient defines the gradient to use (between 0 and 1)
  14627. * @param min defines the color remap minimal range
  14628. * @param max defines the color remap maximal range
  14629. * @returns the current particle system
  14630. */
  14631. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14632. /**
  14633. * Remove a specific color remap gradient
  14634. * @param gradient defines the gradient to remove
  14635. * @returns the current particle system
  14636. */
  14637. removeColorRemapGradient(gradient: number): IParticleSystem;
  14638. /**
  14639. * Adds a new alpha remap gradient
  14640. * @param gradient defines the gradient to use (between 0 and 1)
  14641. * @param min defines the alpha remap minimal range
  14642. * @param max defines the alpha remap maximal range
  14643. * @returns the current particle system
  14644. */
  14645. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14646. /**
  14647. * Remove a specific alpha remap gradient
  14648. * @param gradient defines the gradient to remove
  14649. * @returns the current particle system
  14650. */
  14651. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14652. /**
  14653. * Adds a new angular speed gradient
  14654. * @param gradient defines the gradient to use (between 0 and 1)
  14655. * @param factor defines the angular speed to affect to the specified gradient
  14656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14657. * @returns the current particle system
  14658. */
  14659. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14660. /**
  14661. * Remove a specific angular speed gradient
  14662. * @param gradient defines the gradient to remove
  14663. * @returns the current particle system
  14664. */
  14665. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14666. /**
  14667. * Adds a new velocity gradient
  14668. * @param gradient defines the gradient to use (between 0 and 1)
  14669. * @param factor defines the velocity to affect to the specified gradient
  14670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14671. * @returns the current particle system
  14672. */
  14673. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14674. /**
  14675. * Remove a specific velocity gradient
  14676. * @param gradient defines the gradient to remove
  14677. * @returns the current particle system
  14678. */
  14679. removeVelocityGradient(gradient: number): IParticleSystem;
  14680. /**
  14681. * Adds a new limit velocity gradient
  14682. * @param gradient defines the gradient to use (between 0 and 1)
  14683. * @param factor defines the limit velocity value to affect to the specified gradient
  14684. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14685. * @returns the current particle system
  14686. */
  14687. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14688. /**
  14689. * Remove a specific limit velocity gradient
  14690. * @param gradient defines the gradient to remove
  14691. * @returns the current particle system
  14692. */
  14693. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14694. /**
  14695. * Adds a new drag gradient
  14696. * @param gradient defines the gradient to use (between 0 and 1)
  14697. * @param factor defines the drag value to affect to the specified gradient
  14698. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14699. * @returns the current particle system
  14700. */
  14701. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14702. /**
  14703. * Remove a specific drag gradient
  14704. * @param gradient defines the gradient to remove
  14705. * @returns the current particle system
  14706. */
  14707. removeDragGradient(gradient: number): IParticleSystem;
  14708. /**
  14709. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14710. * @param gradient defines the gradient to use (between 0 and 1)
  14711. * @param factor defines the emit rate value to affect to the specified gradient
  14712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14713. * @returns the current particle system
  14714. */
  14715. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14716. /**
  14717. * Remove a specific emit rate gradient
  14718. * @param gradient defines the gradient to remove
  14719. * @returns the current particle system
  14720. */
  14721. removeEmitRateGradient(gradient: number): IParticleSystem;
  14722. /**
  14723. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14724. * @param gradient defines the gradient to use (between 0 and 1)
  14725. * @param factor defines the start size value to affect to the specified gradient
  14726. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14727. * @returns the current particle system
  14728. */
  14729. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14730. /**
  14731. * Remove a specific start size gradient
  14732. * @param gradient defines the gradient to remove
  14733. * @returns the current particle system
  14734. */
  14735. removeStartSizeGradient(gradient: number): IParticleSystem;
  14736. private _createRampGradientTexture;
  14737. /**
  14738. * Gets the current list of ramp gradients.
  14739. * You must use addRampGradient and removeRampGradient to udpate this list
  14740. * @returns the list of ramp gradients
  14741. */
  14742. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14743. /**
  14744. * Adds a new ramp gradient used to remap particle colors
  14745. * @param gradient defines the gradient to use (between 0 and 1)
  14746. * @param color defines the color to affect to the specified gradient
  14747. * @returns the current particle system
  14748. */
  14749. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14750. /**
  14751. * Remove a specific ramp gradient
  14752. * @param gradient defines the gradient to remove
  14753. * @returns the current particle system
  14754. */
  14755. removeRampGradient(gradient: number): ParticleSystem;
  14756. /**
  14757. * Adds a new color gradient
  14758. * @param gradient defines the gradient to use (between 0 and 1)
  14759. * @param color1 defines the color to affect to the specified gradient
  14760. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14761. * @returns this particle system
  14762. */
  14763. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14764. /**
  14765. * Remove a specific color gradient
  14766. * @param gradient defines the gradient to remove
  14767. * @returns this particle system
  14768. */
  14769. removeColorGradient(gradient: number): IParticleSystem;
  14770. private _fetchR;
  14771. protected _reset(): void;
  14772. private _resetEffect;
  14773. private _createVertexBuffers;
  14774. private _createIndexBuffer;
  14775. /**
  14776. * Gets the maximum number of particles active at the same time.
  14777. * @returns The max number of active particles.
  14778. */
  14779. getCapacity(): number;
  14780. /**
  14781. * Gets whether there are still active particles in the system.
  14782. * @returns True if it is alive, otherwise false.
  14783. */
  14784. isAlive(): boolean;
  14785. /**
  14786. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14787. * @returns True if it has been started, otherwise false.
  14788. */
  14789. isStarted(): boolean;
  14790. private _prepareSubEmitterInternalArray;
  14791. /**
  14792. * Starts the particle system and begins to emit
  14793. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14794. */
  14795. start(delay?: number): void;
  14796. /**
  14797. * Stops the particle system.
  14798. * @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.
  14799. */
  14800. stop(stopSubEmitters?: boolean): void;
  14801. /**
  14802. * Remove all active particles
  14803. */
  14804. reset(): void;
  14805. /**
  14806. * @hidden (for internal use only)
  14807. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14808. /**
  14809. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14810. * Its lifetime will start back at 0.
  14811. */
  14812. recycleParticle: (particle: Particle) => void;
  14813. private _stopSubEmitters;
  14814. private _createParticle;
  14815. private _removeFromRoot;
  14816. private _emitFromParticle;
  14817. private _update;
  14818. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14819. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14820. /** @hidden */
  14821. private _getEffect;
  14822. /**
  14823. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14824. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14825. */
  14826. animate(preWarmOnly?: boolean): void;
  14827. private _appendParticleVertices;
  14828. /**
  14829. * Rebuilds the particle system.
  14830. */
  14831. rebuild(): void;
  14832. /**
  14833. * Is this system ready to be used/rendered
  14834. * @return true if the system is ready
  14835. */
  14836. isReady(): boolean;
  14837. private _render;
  14838. /**
  14839. * Renders the particle system in its current state.
  14840. * @returns the current number of particles
  14841. */
  14842. render(): number;
  14843. /**
  14844. * Disposes the particle system and free the associated resources
  14845. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14846. */
  14847. dispose(disposeTexture?: boolean): void;
  14848. /**
  14849. * Clones the particle system.
  14850. * @param name The name of the cloned object
  14851. * @param newEmitter The new emitter to use
  14852. * @returns the cloned particle system
  14853. */
  14854. clone(name: string, newEmitter: any): ParticleSystem;
  14855. /**
  14856. * Serializes the particle system to a JSON object.
  14857. * @returns the JSON object
  14858. */
  14859. serialize(): any;
  14860. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14861. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14862. /**
  14863. * Parses a JSON object to create a particle system.
  14864. * @param parsedParticleSystem The JSON object to parse
  14865. * @param scene The scene to create the particle system in
  14866. * @param rootUrl The root url to use to load external dependencies like texture
  14867. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14868. * @returns the Parsed particle system
  14869. */
  14870. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14871. }
  14872. }
  14873. declare module BABYLON {
  14874. /**
  14875. * A particle represents one of the element emitted by a particle system.
  14876. * This is mainly define by its coordinates, direction, velocity and age.
  14877. */
  14878. export class Particle {
  14879. /**
  14880. * The particle system the particle belongs to.
  14881. */
  14882. particleSystem: ParticleSystem;
  14883. private static _Count;
  14884. /**
  14885. * Unique ID of the particle
  14886. */
  14887. id: number;
  14888. /**
  14889. * The world position of the particle in the scene.
  14890. */
  14891. position: Vector3;
  14892. /**
  14893. * The world direction of the particle in the scene.
  14894. */
  14895. direction: Vector3;
  14896. /**
  14897. * The color of the particle.
  14898. */
  14899. color: Color4;
  14900. /**
  14901. * The color change of the particle per step.
  14902. */
  14903. colorStep: Color4;
  14904. /**
  14905. * Defines how long will the life of the particle be.
  14906. */
  14907. lifeTime: number;
  14908. /**
  14909. * The current age of the particle.
  14910. */
  14911. age: number;
  14912. /**
  14913. * The current size of the particle.
  14914. */
  14915. size: number;
  14916. /**
  14917. * The current scale of the particle.
  14918. */
  14919. scale: Vector2;
  14920. /**
  14921. * The current angle of the particle.
  14922. */
  14923. angle: number;
  14924. /**
  14925. * Defines how fast is the angle changing.
  14926. */
  14927. angularSpeed: number;
  14928. /**
  14929. * Defines the cell index used by the particle to be rendered from a sprite.
  14930. */
  14931. cellIndex: number;
  14932. /**
  14933. * The information required to support color remapping
  14934. */
  14935. remapData: Vector4;
  14936. /** @hidden */ randomCellOffset?: number;
  14937. /** @hidden */ initialDirection: Nullable<Vector3>;
  14938. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  14939. /** @hidden */ initialStartSpriteCellID: number;
  14940. /** @hidden */ initialEndSpriteCellID: number;
  14941. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  14942. /** @hidden */ currentColor1: Color4;
  14943. /** @hidden */ currentColor2: Color4;
  14944. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  14945. /** @hidden */ currentSize1: number;
  14946. /** @hidden */ currentSize2: number;
  14947. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  14948. /** @hidden */ currentAngularSpeed1: number;
  14949. /** @hidden */ currentAngularSpeed2: number;
  14950. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  14951. /** @hidden */ currentVelocity1: number;
  14952. /** @hidden */ currentVelocity2: number;
  14953. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  14954. /** @hidden */ currentLimitVelocity1: number;
  14955. /** @hidden */ currentLimitVelocity2: number;
  14956. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  14957. /** @hidden */ currentDrag1: number;
  14958. /** @hidden */ currentDrag2: number;
  14959. /** @hidden */ randomNoiseCoordinates1: Vector3;
  14960. /** @hidden */ randomNoiseCoordinates2: Vector3;
  14961. /**
  14962. * Creates a new instance Particle
  14963. * @param particleSystem the particle system the particle belongs to
  14964. */
  14965. constructor(
  14966. /**
  14967. * The particle system the particle belongs to.
  14968. */
  14969. particleSystem: ParticleSystem);
  14970. private updateCellInfoFromSystem;
  14971. /**
  14972. * Defines how the sprite cell index is updated for the particle
  14973. */
  14974. updateCellIndex(): void;
  14975. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  14976. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  14977. /** @hidden */ reset(): void;
  14978. /**
  14979. * Copy the properties of particle to another one.
  14980. * @param other the particle to copy the information to.
  14981. */
  14982. copyTo(other: Particle): void;
  14983. }
  14984. }
  14985. declare module BABYLON {
  14986. /**
  14987. * Particle emitter represents a volume emitting particles.
  14988. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  14989. */
  14990. export interface IParticleEmitterType {
  14991. /**
  14992. * Called by the particle System when the direction is computed for the created particle.
  14993. * @param worldMatrix is the world matrix of the particle system
  14994. * @param directionToUpdate is the direction vector to update with the result
  14995. * @param particle is the particle we are computed the direction for
  14996. */
  14997. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14998. /**
  14999. * Called by the particle System when the position is computed for the created particle.
  15000. * @param worldMatrix is the world matrix of the particle system
  15001. * @param positionToUpdate is the position vector to update with the result
  15002. * @param particle is the particle we are computed the position for
  15003. */
  15004. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15005. /**
  15006. * Clones the current emitter and returns a copy of it
  15007. * @returns the new emitter
  15008. */
  15009. clone(): IParticleEmitterType;
  15010. /**
  15011. * Called by the GPUParticleSystem to setup the update shader
  15012. * @param effect defines the update shader
  15013. */
  15014. applyToShader(effect: Effect): void;
  15015. /**
  15016. * Returns a string to use to update the GPU particles update shader
  15017. * @returns the effect defines string
  15018. */
  15019. getEffectDefines(): string;
  15020. /**
  15021. * Returns a string representing the class name
  15022. * @returns a string containing the class name
  15023. */
  15024. getClassName(): string;
  15025. /**
  15026. * Serializes the particle system to a JSON object.
  15027. * @returns the JSON object
  15028. */
  15029. serialize(): any;
  15030. /**
  15031. * Parse properties from a JSON object
  15032. * @param serializationObject defines the JSON object
  15033. */
  15034. parse(serializationObject: any): void;
  15035. }
  15036. }
  15037. declare module BABYLON {
  15038. /**
  15039. * Particle emitter emitting particles from the inside of a box.
  15040. * It emits the particles randomly between 2 given directions.
  15041. */
  15042. export class BoxParticleEmitter implements IParticleEmitterType {
  15043. /**
  15044. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15045. */
  15046. direction1: Vector3;
  15047. /**
  15048. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15049. */
  15050. direction2: Vector3;
  15051. /**
  15052. * 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.
  15053. */
  15054. minEmitBox: Vector3;
  15055. /**
  15056. * 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.
  15057. */
  15058. maxEmitBox: Vector3;
  15059. /**
  15060. * Creates a new instance BoxParticleEmitter
  15061. */
  15062. constructor();
  15063. /**
  15064. * Called by the particle System when the direction is computed for the created particle.
  15065. * @param worldMatrix is the world matrix of the particle system
  15066. * @param directionToUpdate is the direction vector to update with the result
  15067. * @param particle is the particle we are computed the direction for
  15068. */
  15069. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15070. /**
  15071. * Called by the particle System when the position is computed for the created particle.
  15072. * @param worldMatrix is the world matrix of the particle system
  15073. * @param positionToUpdate is the position vector to update with the result
  15074. * @param particle is the particle we are computed the position for
  15075. */
  15076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15077. /**
  15078. * Clones the current emitter and returns a copy of it
  15079. * @returns the new emitter
  15080. */
  15081. clone(): BoxParticleEmitter;
  15082. /**
  15083. * Called by the GPUParticleSystem to setup the update shader
  15084. * @param effect defines the update shader
  15085. */
  15086. applyToShader(effect: Effect): void;
  15087. /**
  15088. * Returns a string to use to update the GPU particles update shader
  15089. * @returns a string containng the defines string
  15090. */
  15091. getEffectDefines(): string;
  15092. /**
  15093. * Returns the string "BoxParticleEmitter"
  15094. * @returns a string containing the class name
  15095. */
  15096. getClassName(): string;
  15097. /**
  15098. * Serializes the particle system to a JSON object.
  15099. * @returns the JSON object
  15100. */
  15101. serialize(): any;
  15102. /**
  15103. * Parse properties from a JSON object
  15104. * @param serializationObject defines the JSON object
  15105. */
  15106. parse(serializationObject: any): void;
  15107. }
  15108. }
  15109. declare module BABYLON {
  15110. /**
  15111. * Particle emitter emitting particles from the inside of a cone.
  15112. * It emits the particles alongside the cone volume from the base to the particle.
  15113. * The emission direction might be randomized.
  15114. */
  15115. export class ConeParticleEmitter implements IParticleEmitterType {
  15116. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15117. directionRandomizer: number;
  15118. private _radius;
  15119. private _angle;
  15120. private _height;
  15121. /**
  15122. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15123. */
  15124. radiusRange: number;
  15125. /**
  15126. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15127. */
  15128. heightRange: number;
  15129. /**
  15130. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15131. */
  15132. emitFromSpawnPointOnly: boolean;
  15133. /**
  15134. * Gets or sets the radius of the emission cone
  15135. */
  15136. radius: number;
  15137. /**
  15138. * Gets or sets the angle of the emission cone
  15139. */
  15140. angle: number;
  15141. private _buildHeight;
  15142. /**
  15143. * Creates a new instance ConeParticleEmitter
  15144. * @param radius the radius of the emission cone (1 by default)
  15145. * @param angle the cone base angle (PI by default)
  15146. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15147. */
  15148. constructor(radius?: number, angle?: number,
  15149. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15150. directionRandomizer?: number);
  15151. /**
  15152. * Called by the particle System when the direction is computed for the created particle.
  15153. * @param worldMatrix is the world matrix of the particle system
  15154. * @param directionToUpdate is the direction vector to update with the result
  15155. * @param particle is the particle we are computed the direction for
  15156. */
  15157. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15158. /**
  15159. * Called by the particle System when the position is computed for the created particle.
  15160. * @param worldMatrix is the world matrix of the particle system
  15161. * @param positionToUpdate is the position vector to update with the result
  15162. * @param particle is the particle we are computed the position for
  15163. */
  15164. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15165. /**
  15166. * Clones the current emitter and returns a copy of it
  15167. * @returns the new emitter
  15168. */
  15169. clone(): ConeParticleEmitter;
  15170. /**
  15171. * Called by the GPUParticleSystem to setup the update shader
  15172. * @param effect defines the update shader
  15173. */
  15174. applyToShader(effect: Effect): void;
  15175. /**
  15176. * Returns a string to use to update the GPU particles update shader
  15177. * @returns a string containng the defines string
  15178. */
  15179. getEffectDefines(): string;
  15180. /**
  15181. * Returns the string "ConeParticleEmitter"
  15182. * @returns a string containing the class name
  15183. */
  15184. getClassName(): string;
  15185. /**
  15186. * Serializes the particle system to a JSON object.
  15187. * @returns the JSON object
  15188. */
  15189. serialize(): any;
  15190. /**
  15191. * Parse properties from a JSON object
  15192. * @param serializationObject defines the JSON object
  15193. */
  15194. parse(serializationObject: any): void;
  15195. }
  15196. }
  15197. declare module BABYLON {
  15198. /**
  15199. * Particle emitter emitting particles from the inside of a cylinder.
  15200. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15201. */
  15202. export class CylinderParticleEmitter implements IParticleEmitterType {
  15203. /**
  15204. * The radius of the emission cylinder.
  15205. */
  15206. radius: number;
  15207. /**
  15208. * The height of the emission cylinder.
  15209. */
  15210. height: number;
  15211. /**
  15212. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15213. */
  15214. radiusRange: number;
  15215. /**
  15216. * How much to randomize the particle direction [0-1].
  15217. */
  15218. directionRandomizer: number;
  15219. /**
  15220. * Creates a new instance CylinderParticleEmitter
  15221. * @param radius the radius of the emission cylinder (1 by default)
  15222. * @param height the height of the emission cylinder (1 by default)
  15223. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15224. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15225. */
  15226. constructor(
  15227. /**
  15228. * The radius of the emission cylinder.
  15229. */
  15230. radius?: number,
  15231. /**
  15232. * The height of the emission cylinder.
  15233. */
  15234. height?: number,
  15235. /**
  15236. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15237. */
  15238. radiusRange?: number,
  15239. /**
  15240. * How much to randomize the particle direction [0-1].
  15241. */
  15242. directionRandomizer?: number);
  15243. /**
  15244. * Called by the particle System when the direction is computed for the created particle.
  15245. * @param worldMatrix is the world matrix of the particle system
  15246. * @param directionToUpdate is the direction vector to update with the result
  15247. * @param particle is the particle we are computed the direction for
  15248. */
  15249. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15250. /**
  15251. * Called by the particle System when the position is computed for the created particle.
  15252. * @param worldMatrix is the world matrix of the particle system
  15253. * @param positionToUpdate is the position vector to update with the result
  15254. * @param particle is the particle we are computed the position for
  15255. */
  15256. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15257. /**
  15258. * Clones the current emitter and returns a copy of it
  15259. * @returns the new emitter
  15260. */
  15261. clone(): CylinderParticleEmitter;
  15262. /**
  15263. * Called by the GPUParticleSystem to setup the update shader
  15264. * @param effect defines the update shader
  15265. */
  15266. applyToShader(effect: Effect): void;
  15267. /**
  15268. * Returns a string to use to update the GPU particles update shader
  15269. * @returns a string containng the defines string
  15270. */
  15271. getEffectDefines(): string;
  15272. /**
  15273. * Returns the string "CylinderParticleEmitter"
  15274. * @returns a string containing the class name
  15275. */
  15276. getClassName(): string;
  15277. /**
  15278. * Serializes the particle system to a JSON object.
  15279. * @returns the JSON object
  15280. */
  15281. serialize(): any;
  15282. /**
  15283. * Parse properties from a JSON object
  15284. * @param serializationObject defines the JSON object
  15285. */
  15286. parse(serializationObject: any): void;
  15287. }
  15288. /**
  15289. * Particle emitter emitting particles from the inside of a cylinder.
  15290. * It emits the particles randomly between two vectors.
  15291. */
  15292. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15293. /**
  15294. * The min limit of the emission direction.
  15295. */
  15296. direction1: Vector3;
  15297. /**
  15298. * The max limit of the emission direction.
  15299. */
  15300. direction2: Vector3;
  15301. /**
  15302. * Creates a new instance CylinderDirectedParticleEmitter
  15303. * @param radius the radius of the emission cylinder (1 by default)
  15304. * @param height the height of the emission cylinder (1 by default)
  15305. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15306. * @param direction1 the min limit of the emission direction (up vector by default)
  15307. * @param direction2 the max limit of the emission direction (up vector by default)
  15308. */
  15309. constructor(radius?: number, height?: number, radiusRange?: number,
  15310. /**
  15311. * The min limit of the emission direction.
  15312. */
  15313. direction1?: Vector3,
  15314. /**
  15315. * The max limit of the emission direction.
  15316. */
  15317. direction2?: Vector3);
  15318. /**
  15319. * Called by the particle System when the direction is computed for the created particle.
  15320. * @param worldMatrix is the world matrix of the particle system
  15321. * @param directionToUpdate is the direction vector to update with the result
  15322. * @param particle is the particle we are computed the direction for
  15323. */
  15324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15325. /**
  15326. * Clones the current emitter and returns a copy of it
  15327. * @returns the new emitter
  15328. */
  15329. clone(): CylinderDirectedParticleEmitter;
  15330. /**
  15331. * Called by the GPUParticleSystem to setup the update shader
  15332. * @param effect defines the update shader
  15333. */
  15334. applyToShader(effect: Effect): void;
  15335. /**
  15336. * Returns a string to use to update the GPU particles update shader
  15337. * @returns a string containng the defines string
  15338. */
  15339. getEffectDefines(): string;
  15340. /**
  15341. * Returns the string "CylinderDirectedParticleEmitter"
  15342. * @returns a string containing the class name
  15343. */
  15344. getClassName(): string;
  15345. /**
  15346. * Serializes the particle system to a JSON object.
  15347. * @returns the JSON object
  15348. */
  15349. serialize(): any;
  15350. /**
  15351. * Parse properties from a JSON object
  15352. * @param serializationObject defines the JSON object
  15353. */
  15354. parse(serializationObject: any): void;
  15355. }
  15356. }
  15357. declare module BABYLON {
  15358. /**
  15359. * Particle emitter emitting particles from the inside of a hemisphere.
  15360. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15361. */
  15362. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15363. /**
  15364. * The radius of the emission hemisphere.
  15365. */
  15366. radius: number;
  15367. /**
  15368. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15369. */
  15370. radiusRange: number;
  15371. /**
  15372. * How much to randomize the particle direction [0-1].
  15373. */
  15374. directionRandomizer: number;
  15375. /**
  15376. * Creates a new instance HemisphericParticleEmitter
  15377. * @param radius the radius of the emission hemisphere (1 by default)
  15378. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15379. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15380. */
  15381. constructor(
  15382. /**
  15383. * The radius of the emission hemisphere.
  15384. */
  15385. radius?: number,
  15386. /**
  15387. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15388. */
  15389. radiusRange?: number,
  15390. /**
  15391. * How much to randomize the particle direction [0-1].
  15392. */
  15393. directionRandomizer?: number);
  15394. /**
  15395. * Called by the particle System when the direction is computed for the created particle.
  15396. * @param worldMatrix is the world matrix of the particle system
  15397. * @param directionToUpdate is the direction vector to update with the result
  15398. * @param particle is the particle we are computed the direction for
  15399. */
  15400. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15401. /**
  15402. * Called by the particle System when the position is computed for the created particle.
  15403. * @param worldMatrix is the world matrix of the particle system
  15404. * @param positionToUpdate is the position vector to update with the result
  15405. * @param particle is the particle we are computed the position for
  15406. */
  15407. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15408. /**
  15409. * Clones the current emitter and returns a copy of it
  15410. * @returns the new emitter
  15411. */
  15412. clone(): HemisphericParticleEmitter;
  15413. /**
  15414. * Called by the GPUParticleSystem to setup the update shader
  15415. * @param effect defines the update shader
  15416. */
  15417. applyToShader(effect: Effect): void;
  15418. /**
  15419. * Returns a string to use to update the GPU particles update shader
  15420. * @returns a string containng the defines string
  15421. */
  15422. getEffectDefines(): string;
  15423. /**
  15424. * Returns the string "HemisphericParticleEmitter"
  15425. * @returns a string containing the class name
  15426. */
  15427. getClassName(): string;
  15428. /**
  15429. * Serializes the particle system to a JSON object.
  15430. * @returns the JSON object
  15431. */
  15432. serialize(): any;
  15433. /**
  15434. * Parse properties from a JSON object
  15435. * @param serializationObject defines the JSON object
  15436. */
  15437. parse(serializationObject: any): void;
  15438. }
  15439. }
  15440. declare module BABYLON {
  15441. /**
  15442. * Particle emitter emitting particles from a point.
  15443. * It emits the particles randomly between 2 given directions.
  15444. */
  15445. export class PointParticleEmitter implements IParticleEmitterType {
  15446. /**
  15447. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15448. */
  15449. direction1: Vector3;
  15450. /**
  15451. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15452. */
  15453. direction2: Vector3;
  15454. /**
  15455. * Creates a new instance PointParticleEmitter
  15456. */
  15457. constructor();
  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. * Called by the particle System when the position is computed for the created particle.
  15467. * @param worldMatrix is the world matrix of the particle system
  15468. * @param positionToUpdate is the position vector to update with the result
  15469. * @param particle is the particle we are computed the position for
  15470. */
  15471. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15472. /**
  15473. * Clones the current emitter and returns a copy of it
  15474. * @returns the new emitter
  15475. */
  15476. clone(): PointParticleEmitter;
  15477. /**
  15478. * Called by the GPUParticleSystem to setup the update shader
  15479. * @param effect defines the update shader
  15480. */
  15481. applyToShader(effect: Effect): void;
  15482. /**
  15483. * Returns a string to use to update the GPU particles update shader
  15484. * @returns a string containng the defines string
  15485. */
  15486. getEffectDefines(): string;
  15487. /**
  15488. * Returns the string "PointParticleEmitter"
  15489. * @returns a string containing the class name
  15490. */
  15491. getClassName(): string;
  15492. /**
  15493. * Serializes the particle system to a JSON object.
  15494. * @returns the JSON object
  15495. */
  15496. serialize(): any;
  15497. /**
  15498. * Parse properties from a JSON object
  15499. * @param serializationObject defines the JSON object
  15500. */
  15501. parse(serializationObject: any): void;
  15502. }
  15503. }
  15504. declare module BABYLON {
  15505. /**
  15506. * Particle emitter emitting particles from the inside of a sphere.
  15507. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15508. */
  15509. export class SphereParticleEmitter implements IParticleEmitterType {
  15510. /**
  15511. * The radius of the emission sphere.
  15512. */
  15513. radius: number;
  15514. /**
  15515. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15516. */
  15517. radiusRange: number;
  15518. /**
  15519. * How much to randomize the particle direction [0-1].
  15520. */
  15521. directionRandomizer: number;
  15522. /**
  15523. * Creates a new instance SphereParticleEmitter
  15524. * @param radius the radius of the emission sphere (1 by default)
  15525. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15526. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15527. */
  15528. constructor(
  15529. /**
  15530. * The radius of the emission sphere.
  15531. */
  15532. radius?: number,
  15533. /**
  15534. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15535. */
  15536. radiusRange?: number,
  15537. /**
  15538. * How much to randomize the particle direction [0-1].
  15539. */
  15540. directionRandomizer?: number);
  15541. /**
  15542. * Called by the particle System when the direction is computed for the created particle.
  15543. * @param worldMatrix is the world matrix of the particle system
  15544. * @param directionToUpdate is the direction vector to update with the result
  15545. * @param particle is the particle we are computed the direction for
  15546. */
  15547. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15548. /**
  15549. * Called by the particle System when the position is computed for the created particle.
  15550. * @param worldMatrix is the world matrix of the particle system
  15551. * @param positionToUpdate is the position vector to update with the result
  15552. * @param particle is the particle we are computed the position for
  15553. */
  15554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15555. /**
  15556. * Clones the current emitter and returns a copy of it
  15557. * @returns the new emitter
  15558. */
  15559. clone(): SphereParticleEmitter;
  15560. /**
  15561. * Called by the GPUParticleSystem to setup the update shader
  15562. * @param effect defines the update shader
  15563. */
  15564. applyToShader(effect: Effect): void;
  15565. /**
  15566. * Returns a string to use to update the GPU particles update shader
  15567. * @returns a string containng the defines string
  15568. */
  15569. getEffectDefines(): string;
  15570. /**
  15571. * Returns the string "SphereParticleEmitter"
  15572. * @returns a string containing the class name
  15573. */
  15574. getClassName(): string;
  15575. /**
  15576. * Serializes the particle system to a JSON object.
  15577. * @returns the JSON object
  15578. */
  15579. serialize(): any;
  15580. /**
  15581. * Parse properties from a JSON object
  15582. * @param serializationObject defines the JSON object
  15583. */
  15584. parse(serializationObject: any): void;
  15585. }
  15586. /**
  15587. * Particle emitter emitting particles from the inside of a sphere.
  15588. * It emits the particles randomly between two vectors.
  15589. */
  15590. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15591. /**
  15592. * The min limit of the emission direction.
  15593. */
  15594. direction1: Vector3;
  15595. /**
  15596. * The max limit of the emission direction.
  15597. */
  15598. direction2: Vector3;
  15599. /**
  15600. * Creates a new instance SphereDirectedParticleEmitter
  15601. * @param radius the radius of the emission sphere (1 by default)
  15602. * @param direction1 the min limit of the emission direction (up vector by default)
  15603. * @param direction2 the max limit of the emission direction (up vector by default)
  15604. */
  15605. constructor(radius?: number,
  15606. /**
  15607. * The min limit of the emission direction.
  15608. */
  15609. direction1?: Vector3,
  15610. /**
  15611. * The max limit of the emission direction.
  15612. */
  15613. direction2?: Vector3);
  15614. /**
  15615. * Called by the particle System when the direction is computed for the created particle.
  15616. * @param worldMatrix is the world matrix of the particle system
  15617. * @param directionToUpdate is the direction vector to update with the result
  15618. * @param particle is the particle we are computed the direction for
  15619. */
  15620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15621. /**
  15622. * Clones the current emitter and returns a copy of it
  15623. * @returns the new emitter
  15624. */
  15625. clone(): SphereDirectedParticleEmitter;
  15626. /**
  15627. * Called by the GPUParticleSystem to setup the update shader
  15628. * @param effect defines the update shader
  15629. */
  15630. applyToShader(effect: Effect): void;
  15631. /**
  15632. * Returns a string to use to update the GPU particles update shader
  15633. * @returns a string containng the defines string
  15634. */
  15635. getEffectDefines(): string;
  15636. /**
  15637. * Returns the string "SphereDirectedParticleEmitter"
  15638. * @returns a string containing the class name
  15639. */
  15640. getClassName(): string;
  15641. /**
  15642. * Serializes the particle system to a JSON object.
  15643. * @returns the JSON object
  15644. */
  15645. serialize(): any;
  15646. /**
  15647. * Parse properties from a JSON object
  15648. * @param serializationObject defines the JSON object
  15649. */
  15650. parse(serializationObject: any): void;
  15651. }
  15652. }
  15653. declare module BABYLON {
  15654. /**
  15655. * Interface representing a particle system in Babylon.js.
  15656. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15657. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15658. */
  15659. export interface IParticleSystem {
  15660. /**
  15661. * List of animations used by the particle system.
  15662. */
  15663. animations: Animation[];
  15664. /**
  15665. * The id of the Particle system.
  15666. */
  15667. id: string;
  15668. /**
  15669. * The name of the Particle system.
  15670. */
  15671. name: string;
  15672. /**
  15673. * The emitter represents the Mesh or position we are attaching the particle system to.
  15674. */
  15675. emitter: Nullable<AbstractMesh | Vector3>;
  15676. /**
  15677. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15678. */
  15679. isBillboardBased: boolean;
  15680. /**
  15681. * The rendering group used by the Particle system to chose when to render.
  15682. */
  15683. renderingGroupId: number;
  15684. /**
  15685. * The layer mask we are rendering the particles through.
  15686. */
  15687. layerMask: number;
  15688. /**
  15689. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15690. */
  15691. updateSpeed: number;
  15692. /**
  15693. * The amount of time the particle system is running (depends of the overall update speed).
  15694. */
  15695. targetStopDuration: number;
  15696. /**
  15697. * The texture used to render each particle. (this can be a spritesheet)
  15698. */
  15699. particleTexture: Nullable<Texture>;
  15700. /**
  15701. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15702. */
  15703. blendMode: number;
  15704. /**
  15705. * Minimum life time of emitting particles.
  15706. */
  15707. minLifeTime: number;
  15708. /**
  15709. * Maximum life time of emitting particles.
  15710. */
  15711. maxLifeTime: number;
  15712. /**
  15713. * Minimum Size of emitting particles.
  15714. */
  15715. minSize: number;
  15716. /**
  15717. * Maximum Size of emitting particles.
  15718. */
  15719. maxSize: number;
  15720. /**
  15721. * Minimum scale of emitting particles on X axis.
  15722. */
  15723. minScaleX: number;
  15724. /**
  15725. * Maximum scale of emitting particles on X axis.
  15726. */
  15727. maxScaleX: number;
  15728. /**
  15729. * Minimum scale of emitting particles on Y axis.
  15730. */
  15731. minScaleY: number;
  15732. /**
  15733. * Maximum scale of emitting particles on Y axis.
  15734. */
  15735. maxScaleY: number;
  15736. /**
  15737. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15738. */
  15739. color1: Color4;
  15740. /**
  15741. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15742. */
  15743. color2: Color4;
  15744. /**
  15745. * Color the particle will have at the end of its lifetime.
  15746. */
  15747. colorDead: Color4;
  15748. /**
  15749. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15750. */
  15751. emitRate: number;
  15752. /**
  15753. * You can use gravity if you want to give an orientation to your particles.
  15754. */
  15755. gravity: Vector3;
  15756. /**
  15757. * Minimum power of emitting particles.
  15758. */
  15759. minEmitPower: number;
  15760. /**
  15761. * Maximum power of emitting particles.
  15762. */
  15763. maxEmitPower: number;
  15764. /**
  15765. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15766. */
  15767. minAngularSpeed: number;
  15768. /**
  15769. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15770. */
  15771. maxAngularSpeed: number;
  15772. /**
  15773. * Gets or sets the minimal initial rotation in radians.
  15774. */
  15775. minInitialRotation: number;
  15776. /**
  15777. * Gets or sets the maximal initial rotation in radians.
  15778. */
  15779. maxInitialRotation: number;
  15780. /**
  15781. * The particle emitter type defines the emitter used by the particle system.
  15782. * It can be for example box, sphere, or cone...
  15783. */
  15784. particleEmitterType: Nullable<IParticleEmitterType>;
  15785. /**
  15786. * Defines the delay in milliseconds before starting the system (0 by default)
  15787. */
  15788. startDelay: number;
  15789. /**
  15790. * 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
  15791. */
  15792. preWarmCycles: number;
  15793. /**
  15794. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15795. */
  15796. preWarmStepOffset: number;
  15797. /**
  15798. * 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)
  15799. */
  15800. spriteCellChangeSpeed: number;
  15801. /**
  15802. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15803. */
  15804. startSpriteCellID: number;
  15805. /**
  15806. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15807. */
  15808. endSpriteCellID: number;
  15809. /**
  15810. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15811. */
  15812. spriteCellWidth: number;
  15813. /**
  15814. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15815. */
  15816. spriteCellHeight: number;
  15817. /**
  15818. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15819. */
  15820. spriteRandomStartCell: boolean;
  15821. /**
  15822. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15823. */
  15824. isAnimationSheetEnabled: boolean;
  15825. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15826. translationPivot: Vector2;
  15827. /**
  15828. * Gets or sets a texture used to add random noise to particle positions
  15829. */
  15830. noiseTexture: Nullable<BaseTexture>;
  15831. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15832. noiseStrength: Vector3;
  15833. /**
  15834. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15835. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15836. */
  15837. billboardMode: number;
  15838. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15839. limitVelocityDamping: number;
  15840. /**
  15841. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15842. */
  15843. beginAnimationOnStart: boolean;
  15844. /**
  15845. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15846. */
  15847. beginAnimationFrom: number;
  15848. /**
  15849. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15850. */
  15851. beginAnimationTo: number;
  15852. /**
  15853. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15854. */
  15855. beginAnimationLoop: boolean;
  15856. /**
  15857. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15858. */
  15859. disposeOnStop: boolean;
  15860. /**
  15861. * Gets the maximum number of particles active at the same time.
  15862. * @returns The max number of active particles.
  15863. */
  15864. getCapacity(): number;
  15865. /**
  15866. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15867. * @returns True if it has been started, otherwise false.
  15868. */
  15869. isStarted(): boolean;
  15870. /**
  15871. * Animates the particle system for this frame.
  15872. */
  15873. animate(): void;
  15874. /**
  15875. * Renders the particle system in its current state.
  15876. * @returns the current number of particles
  15877. */
  15878. render(): number;
  15879. /**
  15880. * Dispose the particle system and frees its associated resources.
  15881. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15882. */
  15883. dispose(disposeTexture?: boolean): void;
  15884. /**
  15885. * Clones the particle system.
  15886. * @param name The name of the cloned object
  15887. * @param newEmitter The new emitter to use
  15888. * @returns the cloned particle system
  15889. */
  15890. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  15891. /**
  15892. * Serializes the particle system to a JSON object.
  15893. * @returns the JSON object
  15894. */
  15895. serialize(): any;
  15896. /**
  15897. * Rebuild the particle system
  15898. */
  15899. rebuild(): void;
  15900. /**
  15901. * Starts the particle system and begins to emit
  15902. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  15903. */
  15904. start(delay?: number): void;
  15905. /**
  15906. * Stops the particle system.
  15907. */
  15908. stop(): void;
  15909. /**
  15910. * Remove all active particles
  15911. */
  15912. reset(): void;
  15913. /**
  15914. * Is this system ready to be used/rendered
  15915. * @return true if the system is ready
  15916. */
  15917. isReady(): boolean;
  15918. /**
  15919. * Adds a new color gradient
  15920. * @param gradient defines the gradient to use (between 0 and 1)
  15921. * @param color1 defines the color to affect to the specified gradient
  15922. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15923. * @returns the current particle system
  15924. */
  15925. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15926. /**
  15927. * Remove a specific color gradient
  15928. * @param gradient defines the gradient to remove
  15929. * @returns the current particle system
  15930. */
  15931. removeColorGradient(gradient: number): IParticleSystem;
  15932. /**
  15933. * Adds a new size gradient
  15934. * @param gradient defines the gradient to use (between 0 and 1)
  15935. * @param factor defines the size factor to affect to the specified gradient
  15936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15937. * @returns the current particle system
  15938. */
  15939. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15940. /**
  15941. * Remove a specific size gradient
  15942. * @param gradient defines the gradient to remove
  15943. * @returns the current particle system
  15944. */
  15945. removeSizeGradient(gradient: number): IParticleSystem;
  15946. /**
  15947. * Gets the current list of color gradients.
  15948. * You must use addColorGradient and removeColorGradient to udpate this list
  15949. * @returns the list of color gradients
  15950. */
  15951. getColorGradients(): Nullable<Array<ColorGradient>>;
  15952. /**
  15953. * Gets the current list of size gradients.
  15954. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15955. * @returns the list of size gradients
  15956. */
  15957. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15958. /**
  15959. * Gets the current list of angular speed gradients.
  15960. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15961. * @returns the list of angular speed gradients
  15962. */
  15963. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15964. /**
  15965. * Adds a new angular speed gradient
  15966. * @param gradient defines the gradient to use (between 0 and 1)
  15967. * @param factor defines the angular speed to affect to the specified gradient
  15968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15969. * @returns the current particle system
  15970. */
  15971. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15972. /**
  15973. * Remove a specific angular speed gradient
  15974. * @param gradient defines the gradient to remove
  15975. * @returns the current particle system
  15976. */
  15977. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15978. /**
  15979. * Gets the current list of velocity gradients.
  15980. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15981. * @returns the list of velocity gradients
  15982. */
  15983. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15984. /**
  15985. * Adds a new velocity gradient
  15986. * @param gradient defines the gradient to use (between 0 and 1)
  15987. * @param factor defines the velocity to affect to the specified gradient
  15988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15989. * @returns the current particle system
  15990. */
  15991. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15992. /**
  15993. * Remove a specific velocity gradient
  15994. * @param gradient defines the gradient to remove
  15995. * @returns the current particle system
  15996. */
  15997. removeVelocityGradient(gradient: number): IParticleSystem;
  15998. /**
  15999. * Gets the current list of limit velocity gradients.
  16000. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16001. * @returns the list of limit velocity gradients
  16002. */
  16003. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16004. /**
  16005. * Adds a new limit velocity gradient
  16006. * @param gradient defines the gradient to use (between 0 and 1)
  16007. * @param factor defines the limit velocity to affect to the specified gradient
  16008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16009. * @returns the current particle system
  16010. */
  16011. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16012. /**
  16013. * Remove a specific limit velocity gradient
  16014. * @param gradient defines the gradient to remove
  16015. * @returns the current particle system
  16016. */
  16017. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16018. /**
  16019. * Adds a new drag gradient
  16020. * @param gradient defines the gradient to use (between 0 and 1)
  16021. * @param factor defines the drag to affect to the specified gradient
  16022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16023. * @returns the current particle system
  16024. */
  16025. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16026. /**
  16027. * Remove a specific drag gradient
  16028. * @param gradient defines the gradient to remove
  16029. * @returns the current particle system
  16030. */
  16031. removeDragGradient(gradient: number): IParticleSystem;
  16032. /**
  16033. * Gets the current list of drag gradients.
  16034. * You must use addDragGradient and removeDragGradient to udpate this list
  16035. * @returns the list of drag gradients
  16036. */
  16037. getDragGradients(): Nullable<Array<FactorGradient>>;
  16038. /**
  16039. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16040. * @param gradient defines the gradient to use (between 0 and 1)
  16041. * @param factor defines the emit rate to affect to the specified gradient
  16042. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16043. * @returns the current particle system
  16044. */
  16045. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16046. /**
  16047. * Remove a specific emit rate gradient
  16048. * @param gradient defines the gradient to remove
  16049. * @returns the current particle system
  16050. */
  16051. removeEmitRateGradient(gradient: number): IParticleSystem;
  16052. /**
  16053. * Gets the current list of emit rate gradients.
  16054. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16055. * @returns the list of emit rate gradients
  16056. */
  16057. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16058. /**
  16059. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16060. * @param gradient defines the gradient to use (between 0 and 1)
  16061. * @param factor defines the start size to affect to the specified gradient
  16062. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16063. * @returns the current particle system
  16064. */
  16065. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16066. /**
  16067. * Remove a specific start size gradient
  16068. * @param gradient defines the gradient to remove
  16069. * @returns the current particle system
  16070. */
  16071. removeStartSizeGradient(gradient: number): IParticleSystem;
  16072. /**
  16073. * Gets the current list of start size gradients.
  16074. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16075. * @returns the list of start size gradients
  16076. */
  16077. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16078. /**
  16079. * Adds a new life time gradient
  16080. * @param gradient defines the gradient to use (between 0 and 1)
  16081. * @param factor defines the life time factor to affect to the specified gradient
  16082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16083. * @returns the current particle system
  16084. */
  16085. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16086. /**
  16087. * Remove a specific life time gradient
  16088. * @param gradient defines the gradient to remove
  16089. * @returns the current particle system
  16090. */
  16091. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16092. /**
  16093. * Gets the current list of life time gradients.
  16094. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16095. * @returns the list of life time gradients
  16096. */
  16097. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16098. /**
  16099. * Gets the current list of color gradients.
  16100. * You must use addColorGradient and removeColorGradient to udpate this list
  16101. * @returns the list of color gradients
  16102. */
  16103. getColorGradients(): Nullable<Array<ColorGradient>>;
  16104. /**
  16105. * Adds a new ramp gradient used to remap particle colors
  16106. * @param gradient defines the gradient to use (between 0 and 1)
  16107. * @param color defines the color to affect to the specified gradient
  16108. * @returns the current particle system
  16109. */
  16110. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16111. /**
  16112. * Gets the current list of ramp gradients.
  16113. * You must use addRampGradient and removeRampGradient to udpate this list
  16114. * @returns the list of ramp gradients
  16115. */
  16116. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16117. /** Gets or sets a boolean indicating that ramp gradients must be used
  16118. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16119. */
  16120. useRampGradients: boolean;
  16121. /**
  16122. * Adds a new color remap gradient
  16123. * @param gradient defines the gradient to use (between 0 and 1)
  16124. * @param min defines the color remap minimal range
  16125. * @param max defines the color remap maximal range
  16126. * @returns the current particle system
  16127. */
  16128. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16129. /**
  16130. * Gets the current list of color remap gradients.
  16131. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16132. * @returns the list of color remap gradients
  16133. */
  16134. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16135. /**
  16136. * Adds a new alpha remap gradient
  16137. * @param gradient defines the gradient to use (between 0 and 1)
  16138. * @param min defines the alpha remap minimal range
  16139. * @param max defines the alpha remap maximal range
  16140. * @returns the current particle system
  16141. */
  16142. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16143. /**
  16144. * Gets the current list of alpha remap gradients.
  16145. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16146. * @returns the list of alpha remap gradients
  16147. */
  16148. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16149. /**
  16150. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16151. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16152. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16153. * @returns the emitter
  16154. */
  16155. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16156. /**
  16157. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16158. * @param radius The radius of the hemisphere to emit from
  16159. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16160. * @returns the emitter
  16161. */
  16162. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16163. /**
  16164. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16165. * @param radius The radius of the sphere to emit from
  16166. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16167. * @returns the emitter
  16168. */
  16169. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16170. /**
  16171. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16172. * @param radius The radius of the sphere to emit from
  16173. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16174. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16175. * @returns the emitter
  16176. */
  16177. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16178. /**
  16179. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16180. * @param radius The radius of the emission cylinder
  16181. * @param height The height of the emission cylinder
  16182. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16183. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16184. * @returns the emitter
  16185. */
  16186. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16187. /**
  16188. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16189. * @param radius The radius of the cylinder to emit from
  16190. * @param height The height of the emission cylinder
  16191. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16192. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16193. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16194. * @returns the emitter
  16195. */
  16196. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16197. /**
  16198. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16199. * @param radius The radius of the cone to emit from
  16200. * @param angle The base angle of the cone
  16201. * @returns the emitter
  16202. */
  16203. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16204. /**
  16205. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16206. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16207. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16208. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16209. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16210. * @returns the emitter
  16211. */
  16212. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16213. /**
  16214. * Get hosting scene
  16215. * @returns the scene
  16216. */
  16217. getScene(): Scene;
  16218. }
  16219. }
  16220. declare module BABYLON {
  16221. /**
  16222. * Creates an instance based on a source mesh.
  16223. */
  16224. export class InstancedMesh extends AbstractMesh {
  16225. private _sourceMesh;
  16226. private _currentLOD;
  16227. /** @hidden */ indexInSourceMeshInstanceArray: number;
  16228. constructor(name: string, source: Mesh);
  16229. /**
  16230. * Returns the string "InstancedMesh".
  16231. */
  16232. getClassName(): string;
  16233. /**
  16234. * If the source mesh receives shadows
  16235. */
  16236. readonly receiveShadows: boolean;
  16237. /**
  16238. * The material of the source mesh
  16239. */
  16240. readonly material: Nullable<Material>;
  16241. /**
  16242. * Visibility of the source mesh
  16243. */
  16244. readonly visibility: number;
  16245. /**
  16246. * Skeleton of the source mesh
  16247. */
  16248. readonly skeleton: Nullable<Skeleton>;
  16249. /**
  16250. * Rendering ground id of the source mesh
  16251. */
  16252. renderingGroupId: number;
  16253. /**
  16254. * Returns the total number of vertices (integer).
  16255. */
  16256. getTotalVertices(): number;
  16257. /**
  16258. * Returns a positive integer : the total number of indices in this mesh geometry.
  16259. * @returns the numner of indices or zero if the mesh has no geometry.
  16260. */
  16261. getTotalIndices(): number;
  16262. /**
  16263. * The source mesh of the instance
  16264. */
  16265. readonly sourceMesh: Mesh;
  16266. /**
  16267. * Is this node ready to be used/rendered
  16268. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16269. * @return {boolean} is it ready
  16270. */
  16271. isReady(completeCheck?: boolean): boolean;
  16272. /**
  16273. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16274. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16275. * @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.
  16276. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16277. */
  16278. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16279. /**
  16280. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16281. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16282. * The `data` are either a numeric array either a Float32Array.
  16283. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16284. * 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).
  16285. * Note that a new underlying VertexBuffer object is created each call.
  16286. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16287. *
  16288. * Possible `kind` values :
  16289. * - VertexBuffer.PositionKind
  16290. * - VertexBuffer.UVKind
  16291. * - VertexBuffer.UV2Kind
  16292. * - VertexBuffer.UV3Kind
  16293. * - VertexBuffer.UV4Kind
  16294. * - VertexBuffer.UV5Kind
  16295. * - VertexBuffer.UV6Kind
  16296. * - VertexBuffer.ColorKind
  16297. * - VertexBuffer.MatricesIndicesKind
  16298. * - VertexBuffer.MatricesIndicesExtraKind
  16299. * - VertexBuffer.MatricesWeightsKind
  16300. * - VertexBuffer.MatricesWeightsExtraKind
  16301. *
  16302. * Returns the Mesh.
  16303. */
  16304. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16305. /**
  16306. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16307. * If the mesh has no geometry, it is simply returned as it is.
  16308. * The `data` are either a numeric array either a Float32Array.
  16309. * No new underlying VertexBuffer object is created.
  16310. * 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.
  16311. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16312. *
  16313. * Possible `kind` values :
  16314. * - VertexBuffer.PositionKind
  16315. * - VertexBuffer.UVKind
  16316. * - VertexBuffer.UV2Kind
  16317. * - VertexBuffer.UV3Kind
  16318. * - VertexBuffer.UV4Kind
  16319. * - VertexBuffer.UV5Kind
  16320. * - VertexBuffer.UV6Kind
  16321. * - VertexBuffer.ColorKind
  16322. * - VertexBuffer.MatricesIndicesKind
  16323. * - VertexBuffer.MatricesIndicesExtraKind
  16324. * - VertexBuffer.MatricesWeightsKind
  16325. * - VertexBuffer.MatricesWeightsExtraKind
  16326. *
  16327. * Returns the Mesh.
  16328. */
  16329. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16330. /**
  16331. * Sets the mesh indices.
  16332. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16333. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16334. * This method creates a new index buffer each call.
  16335. * Returns the Mesh.
  16336. */
  16337. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16338. /**
  16339. * Boolean : True if the mesh owns the requested kind of data.
  16340. */
  16341. isVerticesDataPresent(kind: string): boolean;
  16342. /**
  16343. * Returns an array of indices (IndicesArray).
  16344. */
  16345. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  16346. /**
  16347. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16348. * This means the mesh underlying bounding box and sphere are recomputed.
  16349. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16350. * @returns the current mesh
  16351. */
  16352. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16353. /** @hidden */ preActivate(): InstancedMesh;
  16354. /** @hidden */ activate(renderId: number): boolean;
  16355. /**
  16356. * Returns the current associated LOD AbstractMesh.
  16357. */
  16358. getLOD(camera: Camera): AbstractMesh;
  16359. /** @hidden */ syncSubMeshes(): InstancedMesh;
  16360. /** @hidden */ generatePointsArray(): boolean;
  16361. /**
  16362. * Creates a new InstancedMesh from the current mesh.
  16363. * - name (string) : the cloned mesh name
  16364. * - newParent (optional Node) : the optional Node to parent the clone to.
  16365. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16366. *
  16367. * Returns the clone.
  16368. */
  16369. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16370. /**
  16371. * Disposes the InstancedMesh.
  16372. * Returns nothing.
  16373. */
  16374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16375. }
  16376. }
  16377. declare module BABYLON {
  16378. /**
  16379. * Defines the options associated with the creation of a shader material.
  16380. */
  16381. export interface IShaderMaterialOptions {
  16382. /**
  16383. * Does the material work in alpha blend mode
  16384. */
  16385. needAlphaBlending: boolean;
  16386. /**
  16387. * Does the material work in alpha test mode
  16388. */
  16389. needAlphaTesting: boolean;
  16390. /**
  16391. * The list of attribute names used in the shader
  16392. */
  16393. attributes: string[];
  16394. /**
  16395. * The list of unifrom names used in the shader
  16396. */
  16397. uniforms: string[];
  16398. /**
  16399. * The list of UBO names used in the shader
  16400. */
  16401. uniformBuffers: string[];
  16402. /**
  16403. * The list of sampler names used in the shader
  16404. */
  16405. samplers: string[];
  16406. /**
  16407. * The list of defines used in the shader
  16408. */
  16409. defines: string[];
  16410. }
  16411. /**
  16412. * 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.
  16413. *
  16414. * This returned material effects how the mesh will look based on the code in the shaders.
  16415. *
  16416. * @see http://doc.babylonjs.com/how_to/shader_material
  16417. */
  16418. export class ShaderMaterial extends Material {
  16419. private _shaderPath;
  16420. private _options;
  16421. private _textures;
  16422. private _textureArrays;
  16423. private _floats;
  16424. private _ints;
  16425. private _floatsArrays;
  16426. private _colors3;
  16427. private _colors3Arrays;
  16428. private _colors4;
  16429. private _vectors2;
  16430. private _vectors3;
  16431. private _vectors4;
  16432. private _matrices;
  16433. private _matrices3x3;
  16434. private _matrices2x2;
  16435. private _vectors2Arrays;
  16436. private _vectors3Arrays;
  16437. private _cachedWorldViewMatrix;
  16438. private _renderId;
  16439. /**
  16440. * Instantiate a new shader material.
  16441. * 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.
  16442. * This returned material effects how the mesh will look based on the code in the shaders.
  16443. * @see http://doc.babylonjs.com/how_to/shader_material
  16444. * @param name Define the name of the material in the scene
  16445. * @param scene Define the scene the material belongs to
  16446. * @param shaderPath Defines the route to the shader code in one of three ways:
  16447. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16448. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16449. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16450. * @param options Define the options used to create the shader
  16451. */
  16452. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16453. /**
  16454. * Gets the options used to compile the shader.
  16455. * They can be modified to trigger a new compilation
  16456. */
  16457. readonly options: IShaderMaterialOptions;
  16458. /**
  16459. * Gets the current class name of the material e.g. "ShaderMaterial"
  16460. * Mainly use in serialization.
  16461. * @returns the class name
  16462. */
  16463. getClassName(): string;
  16464. /**
  16465. * Specifies if the material will require alpha blending
  16466. * @returns a boolean specifying if alpha blending is needed
  16467. */
  16468. needAlphaBlending(): boolean;
  16469. /**
  16470. * Specifies if this material should be rendered in alpha test mode
  16471. * @returns a boolean specifying if an alpha test is needed.
  16472. */
  16473. needAlphaTesting(): boolean;
  16474. private _checkUniform;
  16475. /**
  16476. * Set a texture in the shader.
  16477. * @param name Define the name of the uniform samplers as defined in the shader
  16478. * @param texture Define the texture to bind to this sampler
  16479. * @return the material itself allowing "fluent" like uniform updates
  16480. */
  16481. setTexture(name: string, texture: Texture): ShaderMaterial;
  16482. /**
  16483. * Set a texture array in the shader.
  16484. * @param name Define the name of the uniform sampler array as defined in the shader
  16485. * @param textures Define the list of textures to bind to this sampler
  16486. * @return the material itself allowing "fluent" like uniform updates
  16487. */
  16488. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16489. /**
  16490. * Set a float in the shader.
  16491. * @param name Define the name of the uniform as defined in the shader
  16492. * @param value Define the value to give to the uniform
  16493. * @return the material itself allowing "fluent" like uniform updates
  16494. */
  16495. setFloat(name: string, value: number): ShaderMaterial;
  16496. /**
  16497. * Set a int in the shader.
  16498. * @param name Define the name of the uniform as defined in the shader
  16499. * @param value Define the value to give to the uniform
  16500. * @return the material itself allowing "fluent" like uniform updates
  16501. */
  16502. setInt(name: string, value: number): ShaderMaterial;
  16503. /**
  16504. * Set an array of floats in the shader.
  16505. * @param name Define the name of the uniform as defined in the shader
  16506. * @param value Define the value to give to the uniform
  16507. * @return the material itself allowing "fluent" like uniform updates
  16508. */
  16509. setFloats(name: string, value: number[]): ShaderMaterial;
  16510. /**
  16511. * Set a vec3 in the shader from a Color3.
  16512. * @param name Define the name of the uniform as defined in the shader
  16513. * @param value Define the value to give to the uniform
  16514. * @return the material itself allowing "fluent" like uniform updates
  16515. */
  16516. setColor3(name: string, value: Color3): ShaderMaterial;
  16517. /**
  16518. * Set a vec3 array in the shader from a Color3 array.
  16519. * @param name Define the name of the uniform as defined in the shader
  16520. * @param value Define the value to give to the uniform
  16521. * @return the material itself allowing "fluent" like uniform updates
  16522. */
  16523. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16524. /**
  16525. * Set a vec4 in the shader from a Color4.
  16526. * @param name Define the name of the uniform as defined in the shader
  16527. * @param value Define the value to give to the uniform
  16528. * @return the material itself allowing "fluent" like uniform updates
  16529. */
  16530. setColor4(name: string, value: Color4): ShaderMaterial;
  16531. /**
  16532. * Set a vec2 in the shader from a Vector2.
  16533. * @param name Define the name of the uniform as defined in the shader
  16534. * @param value Define the value to give to the uniform
  16535. * @return the material itself allowing "fluent" like uniform updates
  16536. */
  16537. setVector2(name: string, value: Vector2): ShaderMaterial;
  16538. /**
  16539. * Set a vec3 in the shader from a Vector3.
  16540. * @param name Define the name of the uniform as defined in the shader
  16541. * @param value Define the value to give to the uniform
  16542. * @return the material itself allowing "fluent" like uniform updates
  16543. */
  16544. setVector3(name: string, value: Vector3): ShaderMaterial;
  16545. /**
  16546. * Set a vec4 in the shader from a Vector4.
  16547. * @param name Define the name of the uniform as defined in the shader
  16548. * @param value Define the value to give to the uniform
  16549. * @return the material itself allowing "fluent" like uniform updates
  16550. */
  16551. setVector4(name: string, value: Vector4): ShaderMaterial;
  16552. /**
  16553. * Set a mat4 in the shader from a Matrix.
  16554. * @param name Define the name of the uniform as defined in the shader
  16555. * @param value Define the value to give to the uniform
  16556. * @return the material itself allowing "fluent" like uniform updates
  16557. */
  16558. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16559. /**
  16560. * Set a mat3 in the shader from a Float32Array.
  16561. * @param name Define the name of the uniform as defined in the shader
  16562. * @param value Define the value to give to the uniform
  16563. * @return the material itself allowing "fluent" like uniform updates
  16564. */
  16565. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16566. /**
  16567. * Set a mat2 in the shader from a Float32Array.
  16568. * @param name Define the name of the uniform as defined in the shader
  16569. * @param value Define the value to give to the uniform
  16570. * @return the material itself allowing "fluent" like uniform updates
  16571. */
  16572. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16573. /**
  16574. * Set a vec2 array in the shader from a number array.
  16575. * @param name Define the name of the uniform as defined in the shader
  16576. * @param value Define the value to give to the uniform
  16577. * @return the material itself allowing "fluent" like uniform updates
  16578. */
  16579. setArray2(name: string, value: number[]): ShaderMaterial;
  16580. /**
  16581. * Set a vec3 array in the shader from a number array.
  16582. * @param name Define the name of the uniform as defined in the shader
  16583. * @param value Define the value to give to the uniform
  16584. * @return the material itself allowing "fluent" like uniform updates
  16585. */
  16586. setArray3(name: string, value: number[]): ShaderMaterial;
  16587. private _checkCache;
  16588. /**
  16589. * Specifies that the submesh is ready to be used
  16590. * @param mesh defines the mesh to check
  16591. * @param subMesh defines which submesh to check
  16592. * @param useInstances specifies that instances should be used
  16593. * @returns a boolean indicating that the submesh is ready or not
  16594. */
  16595. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16596. /**
  16597. * Checks if the material is ready to render the requested mesh
  16598. * @param mesh Define the mesh to render
  16599. * @param useInstances Define whether or not the material is used with instances
  16600. * @returns true if ready, otherwise false
  16601. */
  16602. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16603. /**
  16604. * Binds the world matrix to the material
  16605. * @param world defines the world transformation matrix
  16606. */
  16607. bindOnlyWorldMatrix(world: Matrix): void;
  16608. /**
  16609. * Binds the material to the mesh
  16610. * @param world defines the world transformation matrix
  16611. * @param mesh defines the mesh to bind the material to
  16612. */
  16613. bind(world: Matrix, mesh?: Mesh): void;
  16614. /**
  16615. * Gets the active textures from the material
  16616. * @returns an array of textures
  16617. */
  16618. getActiveTextures(): BaseTexture[];
  16619. /**
  16620. * Specifies if the material uses a texture
  16621. * @param texture defines the texture to check against the material
  16622. * @returns a boolean specifying if the material uses the texture
  16623. */
  16624. hasTexture(texture: BaseTexture): boolean;
  16625. /**
  16626. * Makes a duplicate of the material, and gives it a new name
  16627. * @param name defines the new name for the duplicated material
  16628. * @returns the cloned material
  16629. */
  16630. clone(name: string): ShaderMaterial;
  16631. /**
  16632. * Disposes the material
  16633. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16634. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16635. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16636. */
  16637. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16638. /**
  16639. * Serializes this material in a JSON representation
  16640. * @returns the serialized material object
  16641. */
  16642. serialize(): any;
  16643. /**
  16644. * Creates a shader material from parsed shader material data
  16645. * @param source defines the JSON represnetation of the material
  16646. * @param scene defines the hosting scene
  16647. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16648. * @returns a new material
  16649. */
  16650. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16651. }
  16652. }
  16653. declare module BABYLON {
  16654. /** @hidden */
  16655. export var colorPixelShader: {
  16656. name: string;
  16657. shader: string;
  16658. };
  16659. }
  16660. declare module BABYLON {
  16661. /** @hidden */
  16662. export var colorVertexShader: {
  16663. name: string;
  16664. shader: string;
  16665. };
  16666. }
  16667. declare module BABYLON {
  16668. /**
  16669. * Line mesh
  16670. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16671. */
  16672. export class LinesMesh extends Mesh {
  16673. /**
  16674. * If vertex color should be applied to the mesh
  16675. */
  16676. useVertexColor?: boolean | undefined;
  16677. /**
  16678. * If vertex alpha should be applied to the mesh
  16679. */
  16680. useVertexAlpha?: boolean | undefined;
  16681. /**
  16682. * Color of the line (Default: White)
  16683. */
  16684. color: Color3;
  16685. /**
  16686. * Alpha of the line (Default: 1)
  16687. */
  16688. alpha: number;
  16689. /**
  16690. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16691. * This margin is expressed in world space coordinates, so its value may vary.
  16692. * Default value is 0.1
  16693. */
  16694. intersectionThreshold: number;
  16695. private _colorShader;
  16696. /**
  16697. * Creates a new LinesMesh
  16698. * @param name defines the name
  16699. * @param scene defines the hosting scene
  16700. * @param parent defines the parent mesh if any
  16701. * @param source defines the optional source LinesMesh used to clone data from
  16702. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16703. * When false, achieved by calling a clone(), also passing False.
  16704. * This will make creation of children, recursive.
  16705. * @param useVertexColor defines if this LinesMesh supports vertex color
  16706. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16707. */
  16708. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16709. /**
  16710. * If vertex color should be applied to the mesh
  16711. */
  16712. useVertexColor?: boolean | undefined,
  16713. /**
  16714. * If vertex alpha should be applied to the mesh
  16715. */
  16716. useVertexAlpha?: boolean | undefined);
  16717. private _addClipPlaneDefine;
  16718. private _removeClipPlaneDefine;
  16719. isReady(): boolean;
  16720. /**
  16721. * Returns the string "LineMesh"
  16722. */
  16723. getClassName(): string;
  16724. /**
  16725. * @hidden
  16726. */
  16727. /**
  16728. * @hidden
  16729. */
  16730. material: Material;
  16731. /**
  16732. * @hidden
  16733. */
  16734. readonly checkCollisions: boolean;
  16735. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16736. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16737. /**
  16738. * Disposes of the line mesh
  16739. * @param doNotRecurse If children should be disposed
  16740. */
  16741. dispose(doNotRecurse?: boolean): void;
  16742. /**
  16743. * Returns a new LineMesh object cloned from the current one.
  16744. */
  16745. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16746. /**
  16747. * Creates a new InstancedLinesMesh object from the mesh model.
  16748. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16749. * @param name defines the name of the new instance
  16750. * @returns a new InstancedLinesMesh
  16751. */
  16752. createInstance(name: string): InstancedLinesMesh;
  16753. }
  16754. /**
  16755. * Creates an instance based on a source LinesMesh
  16756. */
  16757. export class InstancedLinesMesh extends InstancedMesh {
  16758. /**
  16759. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16760. * This margin is expressed in world space coordinates, so its value may vary.
  16761. * Initilized with the intersectionThreshold value of the source LinesMesh
  16762. */
  16763. intersectionThreshold: number;
  16764. constructor(name: string, source: LinesMesh);
  16765. /**
  16766. * Returns the string "InstancedLinesMesh".
  16767. */
  16768. getClassName(): string;
  16769. }
  16770. }
  16771. declare module BABYLON {
  16772. /** @hidden */
  16773. export var linePixelShader: {
  16774. name: string;
  16775. shader: string;
  16776. };
  16777. }
  16778. declare module BABYLON {
  16779. /** @hidden */
  16780. export var lineVertexShader: {
  16781. name: string;
  16782. shader: string;
  16783. };
  16784. }
  16785. declare module BABYLON {
  16786. interface AbstractMesh {
  16787. /**
  16788. * Disables the mesh edge rendering mode
  16789. * @returns the currentAbstractMesh
  16790. */
  16791. disableEdgesRendering(): AbstractMesh;
  16792. /**
  16793. * Enables the edge rendering mode on the mesh.
  16794. * This mode makes the mesh edges visible
  16795. * @param epsilon defines the maximal distance between two angles to detect a face
  16796. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16797. * @returns the currentAbstractMesh
  16798. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16799. */
  16800. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16801. /**
  16802. * Gets the edgesRenderer associated with the mesh
  16803. */
  16804. edgesRenderer: Nullable<EdgesRenderer>;
  16805. }
  16806. interface LinesMesh {
  16807. /**
  16808. * Enables the edge rendering mode on the mesh.
  16809. * This mode makes the mesh edges visible
  16810. * @param epsilon defines the maximal distance between two angles to detect a face
  16811. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16812. * @returns the currentAbstractMesh
  16813. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16814. */
  16815. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16816. }
  16817. interface InstancedLinesMesh {
  16818. /**
  16819. * Enables the edge rendering mode on the mesh.
  16820. * This mode makes the mesh edges visible
  16821. * @param epsilon defines the maximal distance between two angles to detect a face
  16822. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16823. * @returns the current InstancedLinesMesh
  16824. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16825. */
  16826. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16827. }
  16828. /**
  16829. * Defines the minimum contract an Edges renderer should follow.
  16830. */
  16831. export interface IEdgesRenderer extends IDisposable {
  16832. /**
  16833. * Gets or sets a boolean indicating if the edgesRenderer is active
  16834. */
  16835. isEnabled: boolean;
  16836. /**
  16837. * Renders the edges of the attached mesh,
  16838. */
  16839. render(): void;
  16840. /**
  16841. * Checks wether or not the edges renderer is ready to render.
  16842. * @return true if ready, otherwise false.
  16843. */
  16844. isReady(): boolean;
  16845. }
  16846. /**
  16847. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16848. */
  16849. export class EdgesRenderer implements IEdgesRenderer {
  16850. /**
  16851. * Define the size of the edges with an orthographic camera
  16852. */
  16853. edgesWidthScalerForOrthographic: number;
  16854. /**
  16855. * Define the size of the edges with a perspective camera
  16856. */
  16857. edgesWidthScalerForPerspective: number;
  16858. protected _source: AbstractMesh;
  16859. protected _linesPositions: number[];
  16860. protected _linesNormals: number[];
  16861. protected _linesIndices: number[];
  16862. protected _epsilon: number;
  16863. protected _indicesCount: number;
  16864. protected _lineShader: ShaderMaterial;
  16865. protected _ib: WebGLBuffer;
  16866. protected _buffers: {
  16867. [key: string]: Nullable<VertexBuffer>;
  16868. };
  16869. protected _checkVerticesInsteadOfIndices: boolean;
  16870. private _meshRebuildObserver;
  16871. private _meshDisposeObserver;
  16872. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16873. isEnabled: boolean;
  16874. /**
  16875. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16876. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16877. * @param source Mesh used to create edges
  16878. * @param epsilon sum of angles in adjacency to check for edge
  16879. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16880. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16881. */
  16882. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16883. protected _prepareRessources(): void;
  16884. /** @hidden */ rebuild(): void;
  16885. /**
  16886. * Releases the required resources for the edges renderer
  16887. */
  16888. dispose(): void;
  16889. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16890. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16891. /**
  16892. * Checks if the pair of p0 and p1 is en edge
  16893. * @param faceIndex
  16894. * @param edge
  16895. * @param faceNormals
  16896. * @param p0
  16897. * @param p1
  16898. * @private
  16899. */
  16900. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16901. /**
  16902. * push line into the position, normal and index buffer
  16903. * @protected
  16904. */
  16905. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16906. /**
  16907. * Generates lines edges from adjacencjes
  16908. * @private
  16909. */ generateEdgesLines(): void;
  16910. /**
  16911. * Checks wether or not the edges renderer is ready to render.
  16912. * @return true if ready, otherwise false.
  16913. */
  16914. isReady(): boolean;
  16915. /**
  16916. * Renders the edges of the attached mesh,
  16917. */
  16918. render(): void;
  16919. }
  16920. /**
  16921. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16922. */
  16923. export class LineEdgesRenderer extends EdgesRenderer {
  16924. /**
  16925. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16926. * @param source LineMesh used to generate edges
  16927. * @param epsilon not important (specified angle for edge detection)
  16928. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16929. */
  16930. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16931. /**
  16932. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16933. */ generateEdgesLines(): void;
  16934. }
  16935. }
  16936. declare module BABYLON {
  16937. /**
  16938. * This represents the object necessary to create a rendering group.
  16939. * This is exclusively used and created by the rendering manager.
  16940. * To modify the behavior, you use the available helpers in your scene or meshes.
  16941. * @hidden
  16942. */
  16943. export class RenderingGroup {
  16944. index: number;
  16945. private _scene;
  16946. private _opaqueSubMeshes;
  16947. private _transparentSubMeshes;
  16948. private _alphaTestSubMeshes;
  16949. private _depthOnlySubMeshes;
  16950. private _particleSystems;
  16951. private _spriteManagers;
  16952. private _opaqueSortCompareFn;
  16953. private _alphaTestSortCompareFn;
  16954. private _transparentSortCompareFn;
  16955. private _renderOpaque;
  16956. private _renderAlphaTest;
  16957. private _renderTransparent;
  16958. /** @hidden */ edgesRenderers: SmartArray<IEdgesRenderer>;
  16959. onBeforeTransparentRendering: () => void;
  16960. /**
  16961. * Set the opaque sort comparison function.
  16962. * If null the sub meshes will be render in the order they were created
  16963. */
  16964. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16965. /**
  16966. * Set the alpha test sort comparison function.
  16967. * If null the sub meshes will be render in the order they were created
  16968. */
  16969. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16970. /**
  16971. * Set the transparent sort comparison function.
  16972. * If null the sub meshes will be render in the order they were created
  16973. */
  16974. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16975. /**
  16976. * Creates a new rendering group.
  16977. * @param index The rendering group index
  16978. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16979. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16980. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16981. */
  16982. 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>);
  16983. /**
  16984. * Render all the sub meshes contained in the group.
  16985. * @param customRenderFunction Used to override the default render behaviour of the group.
  16986. * @returns true if rendered some submeshes.
  16987. */
  16988. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16989. /**
  16990. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16991. * @param subMeshes The submeshes to render
  16992. */
  16993. private renderOpaqueSorted;
  16994. /**
  16995. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16996. * @param subMeshes The submeshes to render
  16997. */
  16998. private renderAlphaTestSorted;
  16999. /**
  17000. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17001. * @param subMeshes The submeshes to render
  17002. */
  17003. private renderTransparentSorted;
  17004. /**
  17005. * Renders the submeshes in a specified order.
  17006. * @param subMeshes The submeshes to sort before render
  17007. * @param sortCompareFn The comparison function use to sort
  17008. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17009. * @param transparent Specifies to activate blending if true
  17010. */
  17011. private static renderSorted;
  17012. /**
  17013. * Renders the submeshes in the order they were dispatched (no sort applied).
  17014. * @param subMeshes The submeshes to render
  17015. */
  17016. private static renderUnsorted;
  17017. /**
  17018. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17019. * are rendered back to front if in the same alpha index.
  17020. *
  17021. * @param a The first submesh
  17022. * @param b The second submesh
  17023. * @returns The result of the comparison
  17024. */
  17025. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17026. /**
  17027. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17028. * are rendered back to front.
  17029. *
  17030. * @param a The first submesh
  17031. * @param b The second submesh
  17032. * @returns The result of the comparison
  17033. */
  17034. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17035. /**
  17036. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17037. * are rendered front to back (prevent overdraw).
  17038. *
  17039. * @param a The first submesh
  17040. * @param b The second submesh
  17041. * @returns The result of the comparison
  17042. */
  17043. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17044. /**
  17045. * Resets the different lists of submeshes to prepare a new frame.
  17046. */
  17047. prepare(): void;
  17048. dispose(): void;
  17049. /**
  17050. * Inserts the submesh in its correct queue depending on its material.
  17051. * @param subMesh The submesh to dispatch
  17052. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17053. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17054. */
  17055. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17056. dispatchSprites(spriteManager: ISpriteManager): void;
  17057. dispatchParticles(particleSystem: IParticleSystem): void;
  17058. private _renderParticles;
  17059. private _renderSprites;
  17060. }
  17061. }
  17062. declare module BABYLON {
  17063. /**
  17064. * Interface describing the different options available in the rendering manager
  17065. * regarding Auto Clear between groups.
  17066. */
  17067. export interface IRenderingManagerAutoClearSetup {
  17068. /**
  17069. * Defines whether or not autoclear is enable.
  17070. */
  17071. autoClear: boolean;
  17072. /**
  17073. * Defines whether or not to autoclear the depth buffer.
  17074. */
  17075. depth: boolean;
  17076. /**
  17077. * Defines whether or not to autoclear the stencil buffer.
  17078. */
  17079. stencil: boolean;
  17080. }
  17081. /**
  17082. * This class is used by the onRenderingGroupObservable
  17083. */
  17084. export class RenderingGroupInfo {
  17085. /**
  17086. * The Scene that being rendered
  17087. */
  17088. scene: Scene;
  17089. /**
  17090. * The camera currently used for the rendering pass
  17091. */
  17092. camera: Nullable<Camera>;
  17093. /**
  17094. * The ID of the renderingGroup being processed
  17095. */
  17096. renderingGroupId: number;
  17097. }
  17098. /**
  17099. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17100. * It is enable to manage the different groups as well as the different necessary sort functions.
  17101. * This should not be used directly aside of the few static configurations
  17102. */
  17103. export class RenderingManager {
  17104. /**
  17105. * The max id used for rendering groups (not included)
  17106. */
  17107. static MAX_RENDERINGGROUPS: number;
  17108. /**
  17109. * The min id used for rendering groups (included)
  17110. */
  17111. static MIN_RENDERINGGROUPS: number;
  17112. /**
  17113. * Used to globally prevent autoclearing scenes.
  17114. */
  17115. static AUTOCLEAR: boolean;
  17116. /**
  17117. * @hidden
  17118. */ useSceneAutoClearSetup: boolean;
  17119. private _scene;
  17120. private _renderingGroups;
  17121. private _depthStencilBufferAlreadyCleaned;
  17122. private _autoClearDepthStencil;
  17123. private _customOpaqueSortCompareFn;
  17124. private _customAlphaTestSortCompareFn;
  17125. private _customTransparentSortCompareFn;
  17126. private _renderingGroupInfo;
  17127. /**
  17128. * Instantiates a new rendering group for a particular scene
  17129. * @param scene Defines the scene the groups belongs to
  17130. */
  17131. constructor(scene: Scene);
  17132. private _clearDepthStencilBuffer;
  17133. /**
  17134. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17135. * @hidden
  17136. */
  17137. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17138. /**
  17139. * Resets the different information of the group to prepare a new frame
  17140. * @hidden
  17141. */
  17142. reset(): void;
  17143. /**
  17144. * Dispose and release the group and its associated resources.
  17145. * @hidden
  17146. */
  17147. dispose(): void;
  17148. /**
  17149. * Clear the info related to rendering groups preventing retention points during dispose.
  17150. */
  17151. freeRenderingGroups(): void;
  17152. private _prepareRenderingGroup;
  17153. /**
  17154. * Add a sprite manager to the rendering manager in order to render it this frame.
  17155. * @param spriteManager Define the sprite manager to render
  17156. */
  17157. dispatchSprites(spriteManager: ISpriteManager): void;
  17158. /**
  17159. * Add a particle system to the rendering manager in order to render it this frame.
  17160. * @param particleSystem Define the particle system to render
  17161. */
  17162. dispatchParticles(particleSystem: IParticleSystem): void;
  17163. /**
  17164. * Add a submesh to the manager in order to render it this frame
  17165. * @param subMesh The submesh to dispatch
  17166. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17167. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17168. */
  17169. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17170. /**
  17171. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17172. * This allowed control for front to back rendering or reversly depending of the special needs.
  17173. *
  17174. * @param renderingGroupId The rendering group id corresponding to its index
  17175. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17176. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17177. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17178. */
  17179. 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;
  17180. /**
  17181. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17182. *
  17183. * @param renderingGroupId The rendering group id corresponding to its index
  17184. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17185. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17186. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17187. */
  17188. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17189. /**
  17190. * Gets the current auto clear configuration for one rendering group of the rendering
  17191. * manager.
  17192. * @param index the rendering group index to get the information for
  17193. * @returns The auto clear setup for the requested rendering group
  17194. */
  17195. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17196. }
  17197. }
  17198. declare module BABYLON {
  17199. /**
  17200. * This Helps creating a texture that will be created from a camera in your scene.
  17201. * It is basically a dynamic texture that could be used to create special effects for instance.
  17202. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17203. */
  17204. export class RenderTargetTexture extends Texture {
  17205. isCube: boolean;
  17206. /**
  17207. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17208. */
  17209. static readonly REFRESHRATE_RENDER_ONCE: number;
  17210. /**
  17211. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17212. */
  17213. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17214. /**
  17215. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17216. * the central point of your effect and can save a lot of performances.
  17217. */
  17218. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17219. /**
  17220. * Use this predicate to dynamically define the list of mesh you want to render.
  17221. * If set, the renderList property will be overwritten.
  17222. */
  17223. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17224. private _renderList;
  17225. /**
  17226. * Use this list to define the list of mesh you want to render.
  17227. */
  17228. renderList: Nullable<Array<AbstractMesh>>;
  17229. private _hookArray;
  17230. /**
  17231. * Define if particles should be rendered in your texture.
  17232. */
  17233. renderParticles: boolean;
  17234. /**
  17235. * Define if sprites should be rendered in your texture.
  17236. */
  17237. renderSprites: boolean;
  17238. /**
  17239. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17240. */
  17241. coordinatesMode: number;
  17242. /**
  17243. * Define the camera used to render the texture.
  17244. */
  17245. activeCamera: Nullable<Camera>;
  17246. /**
  17247. * Override the render function of the texture with your own one.
  17248. */
  17249. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17250. /**
  17251. * Define if camera post processes should be use while rendering the texture.
  17252. */
  17253. useCameraPostProcesses: boolean;
  17254. /**
  17255. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17256. */
  17257. ignoreCameraViewport: boolean;
  17258. private _postProcessManager;
  17259. private _postProcesses;
  17260. private _resizeObserver;
  17261. /**
  17262. * An event triggered when the texture is unbind.
  17263. */
  17264. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17265. /**
  17266. * An event triggered when the texture is unbind.
  17267. */
  17268. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17269. private _onAfterUnbindObserver;
  17270. /**
  17271. * Set a after unbind callback in the texture.
  17272. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17273. */
  17274. onAfterUnbind: () => void;
  17275. /**
  17276. * An event triggered before rendering the texture
  17277. */
  17278. onBeforeRenderObservable: Observable<number>;
  17279. private _onBeforeRenderObserver;
  17280. /**
  17281. * Set a before render callback in the texture.
  17282. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17283. */
  17284. onBeforeRender: (faceIndex: number) => void;
  17285. /**
  17286. * An event triggered after rendering the texture
  17287. */
  17288. onAfterRenderObservable: Observable<number>;
  17289. private _onAfterRenderObserver;
  17290. /**
  17291. * Set a after render callback in the texture.
  17292. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17293. */
  17294. onAfterRender: (faceIndex: number) => void;
  17295. /**
  17296. * An event triggered after the texture clear
  17297. */
  17298. onClearObservable: Observable<Engine>;
  17299. private _onClearObserver;
  17300. /**
  17301. * Set a clear callback in the texture.
  17302. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17303. */
  17304. onClear: (Engine: Engine) => void;
  17305. /**
  17306. * Define the clear color of the Render Target if it should be different from the scene.
  17307. */
  17308. clearColor: Color4;
  17309. protected _size: number | {
  17310. width: number;
  17311. height: number;
  17312. };
  17313. protected _initialSizeParameter: number | {
  17314. width: number;
  17315. height: number;
  17316. } | {
  17317. ratio: number;
  17318. };
  17319. protected _sizeRatio: Nullable<number>;
  17320. /** @hidden */ generateMipMaps: boolean;
  17321. protected _renderingManager: RenderingManager;
  17322. /** @hidden */ waitingRenderList: string[];
  17323. protected _doNotChangeAspectRatio: boolean;
  17324. protected _currentRefreshId: number;
  17325. protected _refreshRate: number;
  17326. protected _textureMatrix: Matrix;
  17327. protected _samples: number;
  17328. protected _renderTargetOptions: RenderTargetCreationOptions;
  17329. /**
  17330. * Gets render target creation options that were used.
  17331. */
  17332. readonly renderTargetOptions: RenderTargetCreationOptions;
  17333. protected _engine: Engine;
  17334. protected _onRatioRescale(): void;
  17335. /**
  17336. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17337. * It must define where the camera used to render the texture is set
  17338. */
  17339. boundingBoxPosition: Vector3;
  17340. private _boundingBoxSize;
  17341. /**
  17342. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17343. * When defined, the cubemap will switch to local mode
  17344. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17345. * @example https://www.babylonjs-playground.com/#RNASML
  17346. */
  17347. boundingBoxSize: Vector3;
  17348. /**
  17349. * In case the RTT has been created with a depth texture, get the associated
  17350. * depth texture.
  17351. * Otherwise, return null.
  17352. */
  17353. depthStencilTexture: Nullable<InternalTexture>;
  17354. /**
  17355. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17356. * or used a shadow, depth texture...
  17357. * @param name The friendly name of the texture
  17358. * @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)
  17359. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17360. * @param generateMipMaps True if mip maps need to be generated after render.
  17361. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17362. * @param type The type of the buffer in the RTT (int, half float, float...)
  17363. * @param isCube True if a cube texture needs to be created
  17364. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17365. * @param generateDepthBuffer True to generate a depth buffer
  17366. * @param generateStencilBuffer True to generate a stencil buffer
  17367. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17368. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17369. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17370. */
  17371. constructor(name: string, size: number | {
  17372. width: number;
  17373. height: number;
  17374. } | {
  17375. ratio: number;
  17376. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17377. /**
  17378. * Creates a depth stencil texture.
  17379. * This is only available in WebGL 2 or with the depth texture extension available.
  17380. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17381. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17382. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17383. */
  17384. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17385. private _processSizeParameter;
  17386. /**
  17387. * Define the number of samples to use in case of MSAA.
  17388. * It defaults to one meaning no MSAA has been enabled.
  17389. */
  17390. samples: number;
  17391. /**
  17392. * Resets the refresh counter of the texture and start bak from scratch.
  17393. * Could be useful to regenerate the texture if it is setup to render only once.
  17394. */
  17395. resetRefreshCounter(): void;
  17396. /**
  17397. * Define the refresh rate of the texture or the rendering frequency.
  17398. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17399. */
  17400. refreshRate: number;
  17401. /**
  17402. * Adds a post process to the render target rendering passes.
  17403. * @param postProcess define the post process to add
  17404. */
  17405. addPostProcess(postProcess: PostProcess): void;
  17406. /**
  17407. * Clear all the post processes attached to the render target
  17408. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17409. */
  17410. clearPostProcesses(dispose?: boolean): void;
  17411. /**
  17412. * Remove one of the post process from the list of attached post processes to the texture
  17413. * @param postProcess define the post process to remove from the list
  17414. */
  17415. removePostProcess(postProcess: PostProcess): void;
  17416. /** @hidden */ shouldRender(): boolean;
  17417. /**
  17418. * Gets the actual render size of the texture.
  17419. * @returns the width of the render size
  17420. */
  17421. getRenderSize(): number;
  17422. /**
  17423. * Gets the actual render width of the texture.
  17424. * @returns the width of the render size
  17425. */
  17426. getRenderWidth(): number;
  17427. /**
  17428. * Gets the actual render height of the texture.
  17429. * @returns the height of the render size
  17430. */
  17431. getRenderHeight(): number;
  17432. /**
  17433. * Get if the texture can be rescaled or not.
  17434. */
  17435. readonly canRescale: boolean;
  17436. /**
  17437. * Resize the texture using a ratio.
  17438. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17439. */
  17440. scale(ratio: number): void;
  17441. /**
  17442. * Get the texture reflection matrix used to rotate/transform the reflection.
  17443. * @returns the reflection matrix
  17444. */
  17445. getReflectionTextureMatrix(): Matrix;
  17446. /**
  17447. * Resize the texture to a new desired size.
  17448. * Be carrefull as it will recreate all the data in the new texture.
  17449. * @param size Define the new size. It can be:
  17450. * - a number for squared texture,
  17451. * - an object containing { width: number, height: number }
  17452. * - or an object containing a ratio { ratio: number }
  17453. */
  17454. resize(size: number | {
  17455. width: number;
  17456. height: number;
  17457. } | {
  17458. ratio: number;
  17459. }): void;
  17460. /**
  17461. * Renders all the objects from the render list into the texture.
  17462. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17463. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17464. */
  17465. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17466. private _bestReflectionRenderTargetDimension;
  17467. /**
  17468. * @hidden
  17469. * @param faceIndex face index to bind to if this is a cubetexture
  17470. */ bindFrameBuffer(faceIndex?: number): void;
  17471. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17472. private renderToTarget;
  17473. /**
  17474. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17475. * This allowed control for front to back rendering or reversly depending of the special needs.
  17476. *
  17477. * @param renderingGroupId The rendering group id corresponding to its index
  17478. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17479. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17480. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17481. */
  17482. 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;
  17483. /**
  17484. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17485. *
  17486. * @param renderingGroupId The rendering group id corresponding to its index
  17487. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17488. */
  17489. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17490. /**
  17491. * Clones the texture.
  17492. * @returns the cloned texture
  17493. */
  17494. clone(): RenderTargetTexture;
  17495. /**
  17496. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17497. * @returns The JSON representation of the texture
  17498. */
  17499. serialize(): any;
  17500. /**
  17501. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17502. */
  17503. disposeFramebufferObjects(): void;
  17504. /**
  17505. * Dispose the texture and release its associated resources.
  17506. */
  17507. dispose(): void;
  17508. /** @hidden */ rebuild(): void;
  17509. /**
  17510. * Clear the info related to rendering groups preventing retention point in material dispose.
  17511. */
  17512. freeRenderingGroups(): void;
  17513. /**
  17514. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17515. * @returns the view count
  17516. */
  17517. getViewCount(): number;
  17518. }
  17519. }
  17520. declare module BABYLON {
  17521. /**
  17522. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17523. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17524. * You can then easily use it as a reflectionTexture on a flat surface.
  17525. * In case the surface is not a plane, please consider relying on reflection probes.
  17526. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17527. */
  17528. export class MirrorTexture extends RenderTargetTexture {
  17529. private scene;
  17530. /**
  17531. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17532. * 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.
  17533. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17534. */
  17535. mirrorPlane: Plane;
  17536. /**
  17537. * Define the blur ratio used to blur the reflection if needed.
  17538. */
  17539. blurRatio: number;
  17540. /**
  17541. * Define the adaptive blur kernel used to blur the reflection if needed.
  17542. * This will autocompute the closest best match for the `blurKernel`
  17543. */
  17544. adaptiveBlurKernel: number;
  17545. /**
  17546. * Define the blur kernel used to blur the reflection if needed.
  17547. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17548. */
  17549. blurKernel: number;
  17550. /**
  17551. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17552. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17553. */
  17554. blurKernelX: number;
  17555. /**
  17556. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17557. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17558. */
  17559. blurKernelY: number;
  17560. private _autoComputeBlurKernel;
  17561. protected _onRatioRescale(): void;
  17562. private _updateGammaSpace;
  17563. private _imageProcessingConfigChangeObserver;
  17564. private _transformMatrix;
  17565. private _mirrorMatrix;
  17566. private _savedViewMatrix;
  17567. private _blurX;
  17568. private _blurY;
  17569. private _adaptiveBlurKernel;
  17570. private _blurKernelX;
  17571. private _blurKernelY;
  17572. private _blurRatio;
  17573. /**
  17574. * Instantiates a Mirror Texture.
  17575. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17576. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17577. * You can then easily use it as a reflectionTexture on a flat surface.
  17578. * In case the surface is not a plane, please consider relying on reflection probes.
  17579. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17580. * @param name
  17581. * @param size
  17582. * @param scene
  17583. * @param generateMipMaps
  17584. * @param type
  17585. * @param samplingMode
  17586. * @param generateDepthBuffer
  17587. */
  17588. constructor(name: string, size: number | {
  17589. width: number;
  17590. height: number;
  17591. } | {
  17592. ratio: number;
  17593. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17594. private _preparePostProcesses;
  17595. /**
  17596. * Clone the mirror texture.
  17597. * @returns the cloned texture
  17598. */
  17599. clone(): MirrorTexture;
  17600. /**
  17601. * Serialize the texture to a JSON representation you could use in Parse later on
  17602. * @returns the serialized JSON representation
  17603. */
  17604. serialize(): any;
  17605. /**
  17606. * Dispose the texture and release its associated resources.
  17607. */
  17608. dispose(): void;
  17609. }
  17610. }
  17611. declare module BABYLON {
  17612. /**
  17613. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17614. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17615. */
  17616. export class Texture extends BaseTexture {
  17617. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17618. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17619. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17620. /** nearest is mag = nearest and min = nearest and mip = linear */
  17621. static readonly NEAREST_SAMPLINGMODE: number;
  17622. /** nearest is mag = nearest and min = nearest and mip = linear */
  17623. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17624. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17625. static readonly BILINEAR_SAMPLINGMODE: number;
  17626. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17627. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17628. /** Trilinear is mag = linear and min = linear and mip = linear */
  17629. static readonly TRILINEAR_SAMPLINGMODE: number;
  17630. /** Trilinear is mag = linear and min = linear and mip = linear */
  17631. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17632. /** mag = nearest and min = nearest and mip = nearest */
  17633. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17634. /** mag = nearest and min = linear and mip = nearest */
  17635. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17636. /** mag = nearest and min = linear and mip = linear */
  17637. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17638. /** mag = nearest and min = linear and mip = none */
  17639. static readonly NEAREST_LINEAR: number;
  17640. /** mag = nearest and min = nearest and mip = none */
  17641. static readonly NEAREST_NEAREST: number;
  17642. /** mag = linear and min = nearest and mip = nearest */
  17643. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17644. /** mag = linear and min = nearest and mip = linear */
  17645. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17646. /** mag = linear and min = linear and mip = none */
  17647. static readonly LINEAR_LINEAR: number;
  17648. /** mag = linear and min = nearest and mip = none */
  17649. static readonly LINEAR_NEAREST: number;
  17650. /** Explicit coordinates mode */
  17651. static readonly EXPLICIT_MODE: number;
  17652. /** Spherical coordinates mode */
  17653. static readonly SPHERICAL_MODE: number;
  17654. /** Planar coordinates mode */
  17655. static readonly PLANAR_MODE: number;
  17656. /** Cubic coordinates mode */
  17657. static readonly CUBIC_MODE: number;
  17658. /** Projection coordinates mode */
  17659. static readonly PROJECTION_MODE: number;
  17660. /** Inverse Cubic coordinates mode */
  17661. static readonly SKYBOX_MODE: number;
  17662. /** Inverse Cubic coordinates mode */
  17663. static readonly INVCUBIC_MODE: number;
  17664. /** Equirectangular coordinates mode */
  17665. static readonly EQUIRECTANGULAR_MODE: number;
  17666. /** Equirectangular Fixed coordinates mode */
  17667. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17668. /** Equirectangular Fixed Mirrored coordinates mode */
  17669. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17670. /** Texture is not repeating outside of 0..1 UVs */
  17671. static readonly CLAMP_ADDRESSMODE: number;
  17672. /** Texture is repeating outside of 0..1 UVs */
  17673. static readonly WRAP_ADDRESSMODE: number;
  17674. /** Texture is repeating and mirrored */
  17675. static readonly MIRROR_ADDRESSMODE: number;
  17676. /**
  17677. * 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
  17678. */
  17679. static UseSerializedUrlIfAny: boolean;
  17680. /**
  17681. * Define the url of the texture.
  17682. */
  17683. url: Nullable<string>;
  17684. /**
  17685. * Define an offset on the texture to offset the u coordinates of the UVs
  17686. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17687. */
  17688. uOffset: number;
  17689. /**
  17690. * Define an offset on the texture to offset the v coordinates of the UVs
  17691. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17692. */
  17693. vOffset: number;
  17694. /**
  17695. * Define an offset on the texture to scale the u coordinates of the UVs
  17696. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17697. */
  17698. uScale: number;
  17699. /**
  17700. * Define an offset on the texture to scale the v coordinates of the UVs
  17701. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17702. */
  17703. vScale: number;
  17704. /**
  17705. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17706. * @see http://doc.babylonjs.com/how_to/more_materials
  17707. */
  17708. uAng: number;
  17709. /**
  17710. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17711. * @see http://doc.babylonjs.com/how_to/more_materials
  17712. */
  17713. vAng: number;
  17714. /**
  17715. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17716. * @see http://doc.babylonjs.com/how_to/more_materials
  17717. */
  17718. wAng: number;
  17719. /**
  17720. * Defines the center of rotation (U)
  17721. */
  17722. uRotationCenter: number;
  17723. /**
  17724. * Defines the center of rotation (V)
  17725. */
  17726. vRotationCenter: number;
  17727. /**
  17728. * Defines the center of rotation (W)
  17729. */
  17730. wRotationCenter: number;
  17731. /**
  17732. * Are mip maps generated for this texture or not.
  17733. */
  17734. readonly noMipmap: boolean;
  17735. /**
  17736. * List of inspectable custom properties (used by the Inspector)
  17737. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17738. */
  17739. inspectableCustomProperties: Nullable<IInspectable[]>;
  17740. private _noMipmap;
  17741. /** @hidden */ invertY: boolean;
  17742. private _rowGenerationMatrix;
  17743. private _cachedTextureMatrix;
  17744. private _projectionModeMatrix;
  17745. private _t0;
  17746. private _t1;
  17747. private _t2;
  17748. private _cachedUOffset;
  17749. private _cachedVOffset;
  17750. private _cachedUScale;
  17751. private _cachedVScale;
  17752. private _cachedUAng;
  17753. private _cachedVAng;
  17754. private _cachedWAng;
  17755. private _cachedProjectionMatrixId;
  17756. private _cachedCoordinatesMode;
  17757. /** @hidden */
  17758. protected _initialSamplingMode: number;
  17759. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17760. private _deleteBuffer;
  17761. protected _format: Nullable<number>;
  17762. private _delayedOnLoad;
  17763. private _delayedOnError;
  17764. /**
  17765. * Observable triggered once the texture has been loaded.
  17766. */
  17767. onLoadObservable: Observable<Texture>;
  17768. protected _isBlocking: boolean;
  17769. /**
  17770. * Is the texture preventing material to render while loading.
  17771. * If false, a default texture will be used instead of the loading one during the preparation step.
  17772. */
  17773. isBlocking: boolean;
  17774. /**
  17775. * Get the current sampling mode associated with the texture.
  17776. */
  17777. readonly samplingMode: number;
  17778. /**
  17779. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17780. */
  17781. readonly invertY: boolean;
  17782. /**
  17783. * Instantiates a new texture.
  17784. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17785. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17786. * @param url define the url of the picture to load as a texture
  17787. * @param scene define the scene the texture will belong to
  17788. * @param noMipmap define if the texture will require mip maps or not
  17789. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17790. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17791. * @param onLoad define a callback triggered when the texture has been loaded
  17792. * @param onError define a callback triggered when an error occurred during the loading session
  17793. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17794. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17795. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17796. */
  17797. 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);
  17798. /**
  17799. * Update the url (and optional buffer) of this texture if url was null during construction.
  17800. * @param url the url of the texture
  17801. * @param buffer the buffer of the texture (defaults to null)
  17802. * @param onLoad callback called when the texture is loaded (defaults to null)
  17803. */
  17804. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17805. /**
  17806. * Finish the loading sequence of a texture flagged as delayed load.
  17807. * @hidden
  17808. */
  17809. delayLoad(): void;
  17810. private _prepareRowForTextureGeneration;
  17811. /**
  17812. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17813. * @returns the transform matrix of the texture.
  17814. */
  17815. getTextureMatrix(): Matrix;
  17816. /**
  17817. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17818. * @returns The reflection texture transform
  17819. */
  17820. getReflectionTextureMatrix(): Matrix;
  17821. /**
  17822. * Clones the texture.
  17823. * @returns the cloned texture
  17824. */
  17825. clone(): Texture;
  17826. /**
  17827. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17828. * @returns The JSON representation of the texture
  17829. */
  17830. serialize(): any;
  17831. /**
  17832. * Get the current class name of the texture useful for serialization or dynamic coding.
  17833. * @returns "Texture"
  17834. */
  17835. getClassName(): string;
  17836. /**
  17837. * Dispose the texture and release its associated resources.
  17838. */
  17839. dispose(): void;
  17840. /**
  17841. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17842. * @param parsedTexture Define the JSON representation of the texture
  17843. * @param scene Define the scene the parsed texture should be instantiated in
  17844. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17845. * @returns The parsed texture if successful
  17846. */
  17847. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17848. /**
  17849. * Creates a texture from its base 64 representation.
  17850. * @param data Define the base64 payload without the data: prefix
  17851. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17852. * @param scene Define the scene the texture should belong to
  17853. * @param noMipmap Forces the texture to not create mip map information if true
  17854. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17855. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17856. * @param onLoad define a callback triggered when the texture has been loaded
  17857. * @param onError define a callback triggered when an error occurred during the loading session
  17858. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17859. * @returns the created texture
  17860. */
  17861. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17862. /**
  17863. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17864. * @param data Define the base64 payload without the data: prefix
  17865. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17866. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17867. * @param scene Define the scene the texture should belong to
  17868. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17869. * @param noMipmap Forces the texture to not create mip map information if true
  17870. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17871. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17872. * @param onLoad define a callback triggered when the texture has been loaded
  17873. * @param onError define a callback triggered when an error occurred during the loading session
  17874. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17875. * @returns the created texture
  17876. */
  17877. 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;
  17878. }
  17879. }
  17880. declare module BABYLON {
  17881. /**
  17882. * Raw texture can help creating a texture directly from an array of data.
  17883. * This can be super useful if you either get the data from an uncompressed source or
  17884. * if you wish to create your texture pixel by pixel.
  17885. */
  17886. export class RawTexture extends Texture {
  17887. /**
  17888. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17889. */
  17890. format: number;
  17891. private _engine;
  17892. /**
  17893. * Instantiates a new RawTexture.
  17894. * Raw texture can help creating a texture directly from an array of data.
  17895. * This can be super useful if you either get the data from an uncompressed source or
  17896. * if you wish to create your texture pixel by pixel.
  17897. * @param data define the array of data to use to create the texture
  17898. * @param width define the width of the texture
  17899. * @param height define the height of the texture
  17900. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17901. * @param scene define the scene the texture belongs to
  17902. * @param generateMipMaps define whether mip maps should be generated or not
  17903. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17904. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17905. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17906. */
  17907. constructor(data: ArrayBufferView, width: number, height: number,
  17908. /**
  17909. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17910. */
  17911. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  17912. /**
  17913. * Updates the texture underlying data.
  17914. * @param data Define the new data of the texture
  17915. */
  17916. update(data: ArrayBufferView): void;
  17917. /**
  17918. * Creates a luminance texture from some data.
  17919. * @param data Define the texture data
  17920. * @param width Define the width of the texture
  17921. * @param height Define the height of the texture
  17922. * @param scene Define the scene the texture belongs to
  17923. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17924. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17925. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17926. * @returns the luminance texture
  17927. */
  17928. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17929. /**
  17930. * Creates a luminance alpha texture from some data.
  17931. * @param data Define the texture data
  17932. * @param width Define the width of the texture
  17933. * @param height Define the height of the texture
  17934. * @param scene Define the scene the texture belongs to
  17935. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17936. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17937. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17938. * @returns the luminance alpha texture
  17939. */
  17940. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17941. /**
  17942. * Creates an alpha texture from some data.
  17943. * @param data Define the texture data
  17944. * @param width Define the width of the texture
  17945. * @param height Define the height of the texture
  17946. * @param scene Define the scene the texture belongs to
  17947. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17948. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17949. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17950. * @returns the alpha texture
  17951. */
  17952. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17953. /**
  17954. * Creates a RGB texture from some data.
  17955. * @param data Define the texture data
  17956. * @param width Define the width of the texture
  17957. * @param height Define the height of the texture
  17958. * @param scene Define the scene the texture belongs to
  17959. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17960. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17961. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17962. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17963. * @returns the RGB alpha texture
  17964. */
  17965. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17966. /**
  17967. * Creates a RGBA texture from some data.
  17968. * @param data Define the texture data
  17969. * @param width Define the width of the texture
  17970. * @param height Define the height of the texture
  17971. * @param scene Define the scene the texture belongs to
  17972. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17973. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17974. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17975. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17976. * @returns the RGBA texture
  17977. */
  17978. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17979. /**
  17980. * Creates a R texture from some data.
  17981. * @param data Define the texture data
  17982. * @param width Define the width of the texture
  17983. * @param height Define the height of the texture
  17984. * @param scene Define the scene the texture belongs to
  17985. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17986. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17987. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17988. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17989. * @returns the R texture
  17990. */
  17991. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17992. }
  17993. }
  17994. declare module BABYLON {
  17995. /**
  17996. * Defines a runtime animation
  17997. */
  17998. export class RuntimeAnimation {
  17999. private _events;
  18000. /**
  18001. * The current frame of the runtime animation
  18002. */
  18003. private _currentFrame;
  18004. /**
  18005. * The animation used by the runtime animation
  18006. */
  18007. private _animation;
  18008. /**
  18009. * The target of the runtime animation
  18010. */
  18011. private _target;
  18012. /**
  18013. * The initiating animatable
  18014. */
  18015. private _host;
  18016. /**
  18017. * The original value of the runtime animation
  18018. */
  18019. private _originalValue;
  18020. /**
  18021. * The original blend value of the runtime animation
  18022. */
  18023. private _originalBlendValue;
  18024. /**
  18025. * The offsets cache of the runtime animation
  18026. */
  18027. private _offsetsCache;
  18028. /**
  18029. * The high limits cache of the runtime animation
  18030. */
  18031. private _highLimitsCache;
  18032. /**
  18033. * Specifies if the runtime animation has been stopped
  18034. */
  18035. private _stopped;
  18036. /**
  18037. * The blending factor of the runtime animation
  18038. */
  18039. private _blendingFactor;
  18040. /**
  18041. * The BabylonJS scene
  18042. */
  18043. private _scene;
  18044. /**
  18045. * The current value of the runtime animation
  18046. */
  18047. private _currentValue;
  18048. /** @hidden */ animationState: _IAnimationState;
  18049. /**
  18050. * The active target of the runtime animation
  18051. */
  18052. private _activeTargets;
  18053. private _currentActiveTarget;
  18054. private _directTarget;
  18055. /**
  18056. * The target path of the runtime animation
  18057. */
  18058. private _targetPath;
  18059. /**
  18060. * The weight of the runtime animation
  18061. */
  18062. private _weight;
  18063. /**
  18064. * The ratio offset of the runtime animation
  18065. */
  18066. private _ratioOffset;
  18067. /**
  18068. * The previous delay of the runtime animation
  18069. */
  18070. private _previousDelay;
  18071. /**
  18072. * The previous ratio of the runtime animation
  18073. */
  18074. private _previousRatio;
  18075. private _enableBlending;
  18076. private _keys;
  18077. private _minFrame;
  18078. private _maxFrame;
  18079. private _minValue;
  18080. private _maxValue;
  18081. private _targetIsArray;
  18082. /**
  18083. * Gets the current frame of the runtime animation
  18084. */
  18085. readonly currentFrame: number;
  18086. /**
  18087. * Gets the weight of the runtime animation
  18088. */
  18089. readonly weight: number;
  18090. /**
  18091. * Gets the current value of the runtime animation
  18092. */
  18093. readonly currentValue: any;
  18094. /**
  18095. * Gets the target path of the runtime animation
  18096. */
  18097. readonly targetPath: string;
  18098. /**
  18099. * Gets the actual target of the runtime animation
  18100. */
  18101. readonly target: any;
  18102. /** @hidden */ onLoop: () => void;
  18103. /**
  18104. * Create a new RuntimeAnimation object
  18105. * @param target defines the target of the animation
  18106. * @param animation defines the source animation object
  18107. * @param scene defines the hosting scene
  18108. * @param host defines the initiating Animatable
  18109. */
  18110. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18111. private _preparePath;
  18112. /**
  18113. * Gets the animation from the runtime animation
  18114. */
  18115. readonly animation: Animation;
  18116. /**
  18117. * Resets the runtime animation to the beginning
  18118. * @param restoreOriginal defines whether to restore the target property to the original value
  18119. */
  18120. reset(restoreOriginal?: boolean): void;
  18121. /**
  18122. * Specifies if the runtime animation is stopped
  18123. * @returns Boolean specifying if the runtime animation is stopped
  18124. */
  18125. isStopped(): boolean;
  18126. /**
  18127. * Disposes of the runtime animation
  18128. */
  18129. dispose(): void;
  18130. /**
  18131. * Apply the interpolated value to the target
  18132. * @param currentValue defines the value computed by the animation
  18133. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18134. */
  18135. setValue(currentValue: any, weight: number): void;
  18136. private _getOriginalValues;
  18137. private _setValue;
  18138. /**
  18139. * Gets the loop pmode of the runtime animation
  18140. * @returns Loop Mode
  18141. */
  18142. private _getCorrectLoopMode;
  18143. /**
  18144. * Move the current animation to a given frame
  18145. * @param frame defines the frame to move to
  18146. */
  18147. goToFrame(frame: number): void;
  18148. /**
  18149. * @hidden Internal use only
  18150. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18151. /**
  18152. * Execute the current animation
  18153. * @param delay defines the delay to add to the current frame
  18154. * @param from defines the lower bound of the animation range
  18155. * @param to defines the upper bound of the animation range
  18156. * @param loop defines if the current animation must loop
  18157. * @param speedRatio defines the current speed ratio
  18158. * @param weight defines the weight of the animation (default is -1 so no weight)
  18159. * @param onLoop optional callback called when animation loops
  18160. * @returns a boolean indicating if the animation is running
  18161. */
  18162. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18163. }
  18164. }
  18165. declare module BABYLON {
  18166. /**
  18167. * Class used to store an actual running animation
  18168. */
  18169. export class Animatable {
  18170. /** defines the target object */
  18171. target: any;
  18172. /** defines the starting frame number (default is 0) */
  18173. fromFrame: number;
  18174. /** defines the ending frame number (default is 100) */
  18175. toFrame: number;
  18176. /** defines if the animation must loop (default is false) */
  18177. loopAnimation: boolean;
  18178. /** defines a callback to call when animation ends if it is not looping */
  18179. onAnimationEnd?: (() => void) | null | undefined;
  18180. /** defines a callback to call when animation loops */
  18181. onAnimationLoop?: (() => void) | null | undefined;
  18182. private _localDelayOffset;
  18183. private _pausedDelay;
  18184. private _runtimeAnimations;
  18185. private _paused;
  18186. private _scene;
  18187. private _speedRatio;
  18188. private _weight;
  18189. private _syncRoot;
  18190. /**
  18191. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18192. * This will only apply for non looping animation (default is true)
  18193. */
  18194. disposeOnEnd: boolean;
  18195. /**
  18196. * Gets a boolean indicating if the animation has started
  18197. */
  18198. animationStarted: boolean;
  18199. /**
  18200. * Observer raised when the animation ends
  18201. */
  18202. onAnimationEndObservable: Observable<Animatable>;
  18203. /**
  18204. * Observer raised when the animation loops
  18205. */
  18206. onAnimationLoopObservable: Observable<Animatable>;
  18207. /**
  18208. * Gets the root Animatable used to synchronize and normalize animations
  18209. */
  18210. readonly syncRoot: Nullable<Animatable>;
  18211. /**
  18212. * Gets the current frame of the first RuntimeAnimation
  18213. * Used to synchronize Animatables
  18214. */
  18215. readonly masterFrame: number;
  18216. /**
  18217. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18218. */
  18219. weight: number;
  18220. /**
  18221. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18222. */
  18223. speedRatio: number;
  18224. /**
  18225. * Creates a new Animatable
  18226. * @param scene defines the hosting scene
  18227. * @param target defines the target object
  18228. * @param fromFrame defines the starting frame number (default is 0)
  18229. * @param toFrame defines the ending frame number (default is 100)
  18230. * @param loopAnimation defines if the animation must loop (default is false)
  18231. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18232. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18233. * @param animations defines a group of animation to add to the new Animatable
  18234. * @param onAnimationLoop defines a callback to call when animation loops
  18235. */
  18236. constructor(scene: Scene,
  18237. /** defines the target object */
  18238. target: any,
  18239. /** defines the starting frame number (default is 0) */
  18240. fromFrame?: number,
  18241. /** defines the ending frame number (default is 100) */
  18242. toFrame?: number,
  18243. /** defines if the animation must loop (default is false) */
  18244. loopAnimation?: boolean, speedRatio?: number,
  18245. /** defines a callback to call when animation ends if it is not looping */
  18246. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18247. /** defines a callback to call when animation loops */
  18248. onAnimationLoop?: (() => void) | null | undefined);
  18249. /**
  18250. * Synchronize and normalize current Animatable with a source Animatable
  18251. * This is useful when using animation weights and when animations are not of the same length
  18252. * @param root defines the root Animatable to synchronize with
  18253. * @returns the current Animatable
  18254. */
  18255. syncWith(root: Animatable): Animatable;
  18256. /**
  18257. * Gets the list of runtime animations
  18258. * @returns an array of RuntimeAnimation
  18259. */
  18260. getAnimations(): RuntimeAnimation[];
  18261. /**
  18262. * Adds more animations to the current animatable
  18263. * @param target defines the target of the animations
  18264. * @param animations defines the new animations to add
  18265. */
  18266. appendAnimations(target: any, animations: Animation[]): void;
  18267. /**
  18268. * Gets the source animation for a specific property
  18269. * @param property defines the propertyu to look for
  18270. * @returns null or the source animation for the given property
  18271. */
  18272. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18273. /**
  18274. * Gets the runtime animation for a specific property
  18275. * @param property defines the propertyu to look for
  18276. * @returns null or the runtime animation for the given property
  18277. */
  18278. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18279. /**
  18280. * Resets the animatable to its original state
  18281. */
  18282. reset(): void;
  18283. /**
  18284. * Allows the animatable to blend with current running animations
  18285. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18286. * @param blendingSpeed defines the blending speed to use
  18287. */
  18288. enableBlending(blendingSpeed: number): void;
  18289. /**
  18290. * Disable animation blending
  18291. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18292. */
  18293. disableBlending(): void;
  18294. /**
  18295. * Jump directly to a given frame
  18296. * @param frame defines the frame to jump to
  18297. */
  18298. goToFrame(frame: number): void;
  18299. /**
  18300. * Pause the animation
  18301. */
  18302. pause(): void;
  18303. /**
  18304. * Restart the animation
  18305. */
  18306. restart(): void;
  18307. private _raiseOnAnimationEnd;
  18308. /**
  18309. * Stop and delete the current animation
  18310. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18311. * @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)
  18312. */
  18313. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18314. /**
  18315. * Wait asynchronously for the animation to end
  18316. * @returns a promise which will be fullfilled when the animation ends
  18317. */
  18318. waitAsync(): Promise<Animatable>;
  18319. /** @hidden */ animate(delay: number): boolean;
  18320. }
  18321. interface Scene {
  18322. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18323. /** @hidden */ processLateAnimationBindingsForMatrices(holder: {
  18324. totalWeight: number;
  18325. animations: RuntimeAnimation[];
  18326. originalValue: Matrix;
  18327. }): any;
  18328. /** @hidden */ processLateAnimationBindingsForQuaternions(holder: {
  18329. totalWeight: number;
  18330. animations: RuntimeAnimation[];
  18331. originalValue: Quaternion;
  18332. }, refQuaternion: Quaternion): Quaternion;
  18333. /** @hidden */ processLateAnimationBindings(): void;
  18334. /**
  18335. * Will start the animation sequence of a given target
  18336. * @param target defines the target
  18337. * @param from defines from which frame should animation start
  18338. * @param to defines until which frame should animation run.
  18339. * @param weight defines the weight to apply to the animation (1.0 by default)
  18340. * @param loop defines if the animation loops
  18341. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18342. * @param onAnimationEnd defines the function to be executed when the animation ends
  18343. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18344. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18345. * @param onAnimationLoop defines the callback to call when an animation loops
  18346. * @returns the animatable object created for this animation
  18347. */
  18348. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18349. /**
  18350. * Will start the animation sequence of a given target
  18351. * @param target defines the target
  18352. * @param from defines from which frame should animation start
  18353. * @param to defines until which frame should animation run.
  18354. * @param loop defines if the animation loops
  18355. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18356. * @param onAnimationEnd defines the function to be executed when the animation ends
  18357. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18358. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18359. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18360. * @param onAnimationLoop defines the callback to call when an animation loops
  18361. * @returns the animatable object created for this animation
  18362. */
  18363. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18364. /**
  18365. * Will start the animation sequence of a given target and its hierarchy
  18366. * @param target defines the target
  18367. * @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.
  18368. * @param from defines from which frame should animation start
  18369. * @param to defines until which frame should animation run.
  18370. * @param loop defines if the animation loops
  18371. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18372. * @param onAnimationEnd defines the function to be executed when the animation ends
  18373. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18374. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18375. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18376. * @param onAnimationLoop defines the callback to call when an animation loops
  18377. * @returns the list of created animatables
  18378. */
  18379. 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[];
  18380. /**
  18381. * Begin a new animation on a given node
  18382. * @param target defines the target where the animation will take place
  18383. * @param animations defines the list of animations to start
  18384. * @param from defines the initial value
  18385. * @param to defines the final value
  18386. * @param loop defines if you want animation to loop (off by default)
  18387. * @param speedRatio defines the speed ratio to apply to all animations
  18388. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18389. * @param onAnimationLoop defines the callback to call when an animation loops
  18390. * @returns the list of created animatables
  18391. */
  18392. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18393. /**
  18394. * Begin a new animation on a given node and its hierarchy
  18395. * @param target defines the root node where the animation will take place
  18396. * @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.
  18397. * @param animations defines the list of animations to start
  18398. * @param from defines the initial value
  18399. * @param to defines the final value
  18400. * @param loop defines if you want animation to loop (off by default)
  18401. * @param speedRatio defines the speed ratio to apply to all animations
  18402. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18403. * @param onAnimationLoop defines the callback to call when an animation loops
  18404. * @returns the list of animatables created for all nodes
  18405. */
  18406. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18407. /**
  18408. * Gets the animatable associated with a specific target
  18409. * @param target defines the target of the animatable
  18410. * @returns the required animatable if found
  18411. */
  18412. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18413. /**
  18414. * Gets all animatables associated with a given target
  18415. * @param target defines the target to look animatables for
  18416. * @returns an array of Animatables
  18417. */
  18418. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18419. /**
  18420. * Will stop the animation of the given target
  18421. * @param target - the target
  18422. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18423. * @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)
  18424. */
  18425. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18426. /**
  18427. * Stops and removes all animations that have been applied to the scene
  18428. */
  18429. stopAllAnimations(): void;
  18430. }
  18431. interface Bone {
  18432. /**
  18433. * Copy an animation range from another bone
  18434. * @param source defines the source bone
  18435. * @param rangeName defines the range name to copy
  18436. * @param frameOffset defines the frame offset
  18437. * @param rescaleAsRequired defines if rescaling must be applied if required
  18438. * @param skelDimensionsRatio defines the scaling ratio
  18439. * @returns true if operation was successful
  18440. */
  18441. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18442. }
  18443. }
  18444. declare module BABYLON {
  18445. /**
  18446. * Class used to handle skinning animations
  18447. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18448. */
  18449. export class Skeleton implements IAnimatable {
  18450. /** defines the skeleton name */
  18451. name: string;
  18452. /** defines the skeleton Id */
  18453. id: string;
  18454. /**
  18455. * Defines the list of child bones
  18456. */
  18457. bones: Bone[];
  18458. /**
  18459. * Defines an estimate of the dimension of the skeleton at rest
  18460. */
  18461. dimensionsAtRest: Vector3;
  18462. /**
  18463. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18464. */
  18465. needInitialSkinMatrix: boolean;
  18466. /**
  18467. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18468. */
  18469. overrideMesh: Nullable<AbstractMesh>;
  18470. /**
  18471. * Gets the list of animations attached to this skeleton
  18472. */
  18473. animations: Array<Animation>;
  18474. private _scene;
  18475. private _isDirty;
  18476. private _transformMatrices;
  18477. private _transformMatrixTexture;
  18478. private _meshesWithPoseMatrix;
  18479. private _animatables;
  18480. private _identity;
  18481. private _synchronizedWithMesh;
  18482. private _ranges;
  18483. private _lastAbsoluteTransformsUpdateId;
  18484. private _canUseTextureForBones;
  18485. private _uniqueId;
  18486. /** @hidden */ numBonesWithLinkedTransformNode: number;
  18487. /**
  18488. * Specifies if the skeleton should be serialized
  18489. */
  18490. doNotSerialize: boolean;
  18491. private _useTextureToStoreBoneMatrices;
  18492. /**
  18493. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18494. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18495. */
  18496. useTextureToStoreBoneMatrices: boolean;
  18497. private _animationPropertiesOverride;
  18498. /**
  18499. * Gets or sets the animation properties override
  18500. */
  18501. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18502. /**
  18503. * List of inspectable custom properties (used by the Inspector)
  18504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18505. */
  18506. inspectableCustomProperties: IInspectable[];
  18507. /**
  18508. * An observable triggered before computing the skeleton's matrices
  18509. */
  18510. onBeforeComputeObservable: Observable<Skeleton>;
  18511. /**
  18512. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18513. */
  18514. readonly isUsingTextureForMatrices: boolean;
  18515. /**
  18516. * Gets the unique ID of this skeleton
  18517. */
  18518. readonly uniqueId: number;
  18519. /**
  18520. * Creates a new skeleton
  18521. * @param name defines the skeleton name
  18522. * @param id defines the skeleton Id
  18523. * @param scene defines the hosting scene
  18524. */
  18525. constructor(
  18526. /** defines the skeleton name */
  18527. name: string,
  18528. /** defines the skeleton Id */
  18529. id: string, scene: Scene);
  18530. /**
  18531. * Gets the current object class name.
  18532. * @return the class name
  18533. */
  18534. getClassName(): string;
  18535. /**
  18536. * Returns an array containing the root bones
  18537. * @returns an array containing the root bones
  18538. */
  18539. getChildren(): Array<Bone>;
  18540. /**
  18541. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18542. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18543. * @returns a Float32Array containing matrices data
  18544. */
  18545. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18546. /**
  18547. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18548. * @returns a raw texture containing the data
  18549. */
  18550. getTransformMatrixTexture(): Nullable<RawTexture>;
  18551. /**
  18552. * Gets the current hosting scene
  18553. * @returns a scene object
  18554. */
  18555. getScene(): Scene;
  18556. /**
  18557. * Gets a string representing the current skeleton data
  18558. * @param fullDetails defines a boolean indicating if we want a verbose version
  18559. * @returns a string representing the current skeleton data
  18560. */
  18561. toString(fullDetails?: boolean): string;
  18562. /**
  18563. * Get bone's index searching by name
  18564. * @param name defines bone's name to search for
  18565. * @return the indice of the bone. Returns -1 if not found
  18566. */
  18567. getBoneIndexByName(name: string): number;
  18568. /**
  18569. * Creater a new animation range
  18570. * @param name defines the name of the range
  18571. * @param from defines the start key
  18572. * @param to defines the end key
  18573. */
  18574. createAnimationRange(name: string, from: number, to: number): void;
  18575. /**
  18576. * Delete a specific animation range
  18577. * @param name defines the name of the range
  18578. * @param deleteFrames defines if frames must be removed as well
  18579. */
  18580. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18581. /**
  18582. * Gets a specific animation range
  18583. * @param name defines the name of the range to look for
  18584. * @returns the requested animation range or null if not found
  18585. */
  18586. getAnimationRange(name: string): Nullable<AnimationRange>;
  18587. /**
  18588. * Gets the list of all animation ranges defined on this skeleton
  18589. * @returns an array
  18590. */
  18591. getAnimationRanges(): Nullable<AnimationRange>[];
  18592. /**
  18593. * Copy animation range from a source skeleton.
  18594. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18595. * @param source defines the source skeleton
  18596. * @param name defines the name of the range to copy
  18597. * @param rescaleAsRequired defines if rescaling must be applied if required
  18598. * @returns true if operation was successful
  18599. */
  18600. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18601. /**
  18602. * Forces the skeleton to go to rest pose
  18603. */
  18604. returnToRest(): void;
  18605. private _getHighestAnimationFrame;
  18606. /**
  18607. * Begin a specific animation range
  18608. * @param name defines the name of the range to start
  18609. * @param loop defines if looping must be turned on (false by default)
  18610. * @param speedRatio defines the speed ratio to apply (1 by default)
  18611. * @param onAnimationEnd defines a callback which will be called when animation will end
  18612. * @returns a new animatable
  18613. */
  18614. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18615. /** @hidden */ markAsDirty(): void;
  18616. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18617. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18618. private _computeTransformMatrices;
  18619. /**
  18620. * Build all resources required to render a skeleton
  18621. */
  18622. prepare(): void;
  18623. /**
  18624. * Gets the list of animatables currently running for this skeleton
  18625. * @returns an array of animatables
  18626. */
  18627. getAnimatables(): IAnimatable[];
  18628. /**
  18629. * Clone the current skeleton
  18630. * @param name defines the name of the new skeleton
  18631. * @param id defines the id of the new skeleton
  18632. * @returns the new skeleton
  18633. */
  18634. clone(name: string, id: string): Skeleton;
  18635. /**
  18636. * Enable animation blending for this skeleton
  18637. * @param blendingSpeed defines the blending speed to apply
  18638. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18639. */
  18640. enableBlending(blendingSpeed?: number): void;
  18641. /**
  18642. * Releases all resources associated with the current skeleton
  18643. */
  18644. dispose(): void;
  18645. /**
  18646. * Serialize the skeleton in a JSON object
  18647. * @returns a JSON object
  18648. */
  18649. serialize(): any;
  18650. /**
  18651. * Creates a new skeleton from serialized data
  18652. * @param parsedSkeleton defines the serialized data
  18653. * @param scene defines the hosting scene
  18654. * @returns a new skeleton
  18655. */
  18656. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18657. /**
  18658. * Compute all node absolute transforms
  18659. * @param forceUpdate defines if computation must be done even if cache is up to date
  18660. */
  18661. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18662. /**
  18663. * Gets the root pose matrix
  18664. * @returns a matrix
  18665. */
  18666. getPoseMatrix(): Nullable<Matrix>;
  18667. /**
  18668. * Sorts bones per internal index
  18669. */
  18670. sortBones(): void;
  18671. private _sortBones;
  18672. }
  18673. }
  18674. declare module BABYLON {
  18675. /**
  18676. * Defines a target to use with MorphTargetManager
  18677. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18678. */
  18679. export class MorphTarget implements IAnimatable {
  18680. /** defines the name of the target */
  18681. name: string;
  18682. /**
  18683. * Gets or sets the list of animations
  18684. */
  18685. animations: Animation[];
  18686. private _scene;
  18687. private _positions;
  18688. private _normals;
  18689. private _tangents;
  18690. private _influence;
  18691. /**
  18692. * Observable raised when the influence changes
  18693. */
  18694. onInfluenceChanged: Observable<boolean>;
  18695. /** @hidden */ onDataLayoutChanged: Observable<void>;
  18696. /**
  18697. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18698. */
  18699. influence: number;
  18700. /**
  18701. * Gets or sets the id of the morph Target
  18702. */
  18703. id: string;
  18704. private _animationPropertiesOverride;
  18705. /**
  18706. * Gets or sets the animation properties override
  18707. */
  18708. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18709. /**
  18710. * Creates a new MorphTarget
  18711. * @param name defines the name of the target
  18712. * @param influence defines the influence to use
  18713. * @param scene defines the scene the morphtarget belongs to
  18714. */
  18715. constructor(
  18716. /** defines the name of the target */
  18717. name: string, influence?: number, scene?: Nullable<Scene>);
  18718. /**
  18719. * Gets a boolean defining if the target contains position data
  18720. */
  18721. readonly hasPositions: boolean;
  18722. /**
  18723. * Gets a boolean defining if the target contains normal data
  18724. */
  18725. readonly hasNormals: boolean;
  18726. /**
  18727. * Gets a boolean defining if the target contains tangent data
  18728. */
  18729. readonly hasTangents: boolean;
  18730. /**
  18731. * Affects position data to this target
  18732. * @param data defines the position data to use
  18733. */
  18734. setPositions(data: Nullable<FloatArray>): void;
  18735. /**
  18736. * Gets the position data stored in this target
  18737. * @returns a FloatArray containing the position data (or null if not present)
  18738. */
  18739. getPositions(): Nullable<FloatArray>;
  18740. /**
  18741. * Affects normal data to this target
  18742. * @param data defines the normal data to use
  18743. */
  18744. setNormals(data: Nullable<FloatArray>): void;
  18745. /**
  18746. * Gets the normal data stored in this target
  18747. * @returns a FloatArray containing the normal data (or null if not present)
  18748. */
  18749. getNormals(): Nullable<FloatArray>;
  18750. /**
  18751. * Affects tangent data to this target
  18752. * @param data defines the tangent data to use
  18753. */
  18754. setTangents(data: Nullable<FloatArray>): void;
  18755. /**
  18756. * Gets the tangent data stored in this target
  18757. * @returns a FloatArray containing the tangent data (or null if not present)
  18758. */
  18759. getTangents(): Nullable<FloatArray>;
  18760. /**
  18761. * Serializes the current target into a Serialization object
  18762. * @returns the serialized object
  18763. */
  18764. serialize(): any;
  18765. /**
  18766. * Returns the string "MorphTarget"
  18767. * @returns "MorphTarget"
  18768. */
  18769. getClassName(): string;
  18770. /**
  18771. * Creates a new target from serialized data
  18772. * @param serializationObject defines the serialized data to use
  18773. * @returns a new MorphTarget
  18774. */
  18775. static Parse(serializationObject: any): MorphTarget;
  18776. /**
  18777. * Creates a MorphTarget from mesh data
  18778. * @param mesh defines the source mesh
  18779. * @param name defines the name to use for the new target
  18780. * @param influence defines the influence to attach to the target
  18781. * @returns a new MorphTarget
  18782. */
  18783. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18784. }
  18785. }
  18786. declare module BABYLON {
  18787. /**
  18788. * This class is used to deform meshes using morphing between different targets
  18789. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18790. */
  18791. export class MorphTargetManager {
  18792. private _targets;
  18793. private _targetInfluenceChangedObservers;
  18794. private _targetDataLayoutChangedObservers;
  18795. private _activeTargets;
  18796. private _scene;
  18797. private _influences;
  18798. private _supportsNormals;
  18799. private _supportsTangents;
  18800. private _vertexCount;
  18801. private _uniqueId;
  18802. private _tempInfluences;
  18803. /**
  18804. * Creates a new MorphTargetManager
  18805. * @param scene defines the current scene
  18806. */
  18807. constructor(scene?: Nullable<Scene>);
  18808. /**
  18809. * Gets the unique ID of this manager
  18810. */
  18811. readonly uniqueId: number;
  18812. /**
  18813. * Gets the number of vertices handled by this manager
  18814. */
  18815. readonly vertexCount: number;
  18816. /**
  18817. * Gets a boolean indicating if this manager supports morphing of normals
  18818. */
  18819. readonly supportsNormals: boolean;
  18820. /**
  18821. * Gets a boolean indicating if this manager supports morphing of tangents
  18822. */
  18823. readonly supportsTangents: boolean;
  18824. /**
  18825. * Gets the number of targets stored in this manager
  18826. */
  18827. readonly numTargets: number;
  18828. /**
  18829. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18830. */
  18831. readonly numInfluencers: number;
  18832. /**
  18833. * Gets the list of influences (one per target)
  18834. */
  18835. readonly influences: Float32Array;
  18836. /**
  18837. * Gets the active target at specified index. An active target is a target with an influence > 0
  18838. * @param index defines the index to check
  18839. * @returns the requested target
  18840. */
  18841. getActiveTarget(index: number): MorphTarget;
  18842. /**
  18843. * Gets the target at specified index
  18844. * @param index defines the index to check
  18845. * @returns the requested target
  18846. */
  18847. getTarget(index: number): MorphTarget;
  18848. /**
  18849. * Add a new target to this manager
  18850. * @param target defines the target to add
  18851. */
  18852. addTarget(target: MorphTarget): void;
  18853. /**
  18854. * Removes a target from the manager
  18855. * @param target defines the target to remove
  18856. */
  18857. removeTarget(target: MorphTarget): void;
  18858. /**
  18859. * Serializes the current manager into a Serialization object
  18860. * @returns the serialized object
  18861. */
  18862. serialize(): any;
  18863. private _syncActiveTargets;
  18864. /**
  18865. * Syncrhonize the targets with all the meshes using this morph target manager
  18866. */
  18867. synchronize(): void;
  18868. /**
  18869. * Creates a new MorphTargetManager from serialized data
  18870. * @param serializationObject defines the serialized data
  18871. * @param scene defines the hosting scene
  18872. * @returns the new MorphTargetManager
  18873. */
  18874. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18875. }
  18876. }
  18877. declare module BABYLON {
  18878. /**
  18879. * Mesh representing the gorund
  18880. */
  18881. export class GroundMesh extends Mesh {
  18882. /** If octree should be generated */
  18883. generateOctree: boolean;
  18884. private _heightQuads;
  18885. /** @hidden */ subdivisionsX: number;
  18886. /** @hidden */ subdivisionsY: number;
  18887. /** @hidden */ width: number;
  18888. /** @hidden */ height: number;
  18889. /** @hidden */ minX: number;
  18890. /** @hidden */ maxX: number;
  18891. /** @hidden */ minZ: number;
  18892. /** @hidden */ maxZ: number;
  18893. constructor(name: string, scene: Scene);
  18894. /**
  18895. * "GroundMesh"
  18896. * @returns "GroundMesh"
  18897. */
  18898. getClassName(): string;
  18899. /**
  18900. * The minimum of x and y subdivisions
  18901. */
  18902. readonly subdivisions: number;
  18903. /**
  18904. * X subdivisions
  18905. */
  18906. readonly subdivisionsX: number;
  18907. /**
  18908. * Y subdivisions
  18909. */
  18910. readonly subdivisionsY: number;
  18911. /**
  18912. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18913. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18914. * @param chunksCount the number of subdivisions for x and y
  18915. * @param octreeBlocksSize (Default: 32)
  18916. */
  18917. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18918. /**
  18919. * Returns a height (y) value in the Worl system :
  18920. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18921. * @param x x coordinate
  18922. * @param z z coordinate
  18923. * @returns the ground y position if (x, z) are outside the ground surface.
  18924. */
  18925. getHeightAtCoordinates(x: number, z: number): number;
  18926. /**
  18927. * Returns a normalized vector (Vector3) orthogonal to the ground
  18928. * at the ground coordinates (x, z) expressed in the World system.
  18929. * @param x x coordinate
  18930. * @param z z coordinate
  18931. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18932. */
  18933. getNormalAtCoordinates(x: number, z: number): Vector3;
  18934. /**
  18935. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18936. * at the ground coordinates (x, z) expressed in the World system.
  18937. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18938. * @param x x coordinate
  18939. * @param z z coordinate
  18940. * @param ref vector to store the result
  18941. * @returns the GroundMesh.
  18942. */
  18943. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18944. /**
  18945. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18946. * if the ground has been updated.
  18947. * This can be used in the render loop.
  18948. * @returns the GroundMesh.
  18949. */
  18950. updateCoordinateHeights(): GroundMesh;
  18951. private _getFacetAt;
  18952. private _initHeightQuads;
  18953. private _computeHeightQuads;
  18954. /**
  18955. * Serializes this ground mesh
  18956. * @param serializationObject object to write serialization to
  18957. */
  18958. serialize(serializationObject: any): void;
  18959. /**
  18960. * Parses a serialized ground mesh
  18961. * @param parsedMesh the serialized mesh
  18962. * @param scene the scene to create the ground mesh in
  18963. * @returns the created ground mesh
  18964. */
  18965. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18966. }
  18967. }
  18968. declare module BABYLON {
  18969. /**
  18970. * Interface for Physics-Joint data
  18971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18972. */
  18973. export interface PhysicsJointData {
  18974. /**
  18975. * The main pivot of the joint
  18976. */
  18977. mainPivot?: Vector3;
  18978. /**
  18979. * The connected pivot of the joint
  18980. */
  18981. connectedPivot?: Vector3;
  18982. /**
  18983. * The main axis of the joint
  18984. */
  18985. mainAxis?: Vector3;
  18986. /**
  18987. * The connected axis of the joint
  18988. */
  18989. connectedAxis?: Vector3;
  18990. /**
  18991. * The collision of the joint
  18992. */
  18993. collision?: boolean;
  18994. /**
  18995. * Native Oimo/Cannon/Energy data
  18996. */
  18997. nativeParams?: any;
  18998. }
  18999. /**
  19000. * This is a holder class for the physics joint created by the physics plugin
  19001. * It holds a set of functions to control the underlying joint
  19002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19003. */
  19004. export class PhysicsJoint {
  19005. /**
  19006. * The type of the physics joint
  19007. */
  19008. type: number;
  19009. /**
  19010. * The data for the physics joint
  19011. */
  19012. jointData: PhysicsJointData;
  19013. private _physicsJoint;
  19014. protected _physicsPlugin: IPhysicsEnginePlugin;
  19015. /**
  19016. * Initializes the physics joint
  19017. * @param type The type of the physics joint
  19018. * @param jointData The data for the physics joint
  19019. */
  19020. constructor(
  19021. /**
  19022. * The type of the physics joint
  19023. */
  19024. type: number,
  19025. /**
  19026. * The data for the physics joint
  19027. */
  19028. jointData: PhysicsJointData);
  19029. /**
  19030. * Gets the physics joint
  19031. */
  19032. /**
  19033. * Sets the physics joint
  19034. */
  19035. physicsJoint: any;
  19036. /**
  19037. * Sets the physics plugin
  19038. */
  19039. physicsPlugin: IPhysicsEnginePlugin;
  19040. /**
  19041. * Execute a function that is physics-plugin specific.
  19042. * @param {Function} func the function that will be executed.
  19043. * It accepts two parameters: the physics world and the physics joint
  19044. */
  19045. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19046. /**
  19047. * Distance-Joint type
  19048. */
  19049. static DistanceJoint: number;
  19050. /**
  19051. * Hinge-Joint type
  19052. */
  19053. static HingeJoint: number;
  19054. /**
  19055. * Ball-and-Socket joint type
  19056. */
  19057. static BallAndSocketJoint: number;
  19058. /**
  19059. * Wheel-Joint type
  19060. */
  19061. static WheelJoint: number;
  19062. /**
  19063. * Slider-Joint type
  19064. */
  19065. static SliderJoint: number;
  19066. /**
  19067. * Prismatic-Joint type
  19068. */
  19069. static PrismaticJoint: number;
  19070. /**
  19071. * Universal-Joint type
  19072. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19073. */
  19074. static UniversalJoint: number;
  19075. /**
  19076. * Hinge-Joint 2 type
  19077. */
  19078. static Hinge2Joint: number;
  19079. /**
  19080. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19081. */
  19082. static PointToPointJoint: number;
  19083. /**
  19084. * Spring-Joint type
  19085. */
  19086. static SpringJoint: number;
  19087. /**
  19088. * Lock-Joint type
  19089. */
  19090. static LockJoint: number;
  19091. }
  19092. /**
  19093. * A class representing a physics distance joint
  19094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19095. */
  19096. export class DistanceJoint extends PhysicsJoint {
  19097. /**
  19098. *
  19099. * @param jointData The data for the Distance-Joint
  19100. */
  19101. constructor(jointData: DistanceJointData);
  19102. /**
  19103. * Update the predefined distance.
  19104. * @param maxDistance The maximum preferred distance
  19105. * @param minDistance The minimum preferred distance
  19106. */
  19107. updateDistance(maxDistance: number, minDistance?: number): void;
  19108. }
  19109. /**
  19110. * Represents a Motor-Enabled Joint
  19111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19112. */
  19113. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19114. /**
  19115. * Initializes the Motor-Enabled Joint
  19116. * @param type The type of the joint
  19117. * @param jointData The physica joint data for the joint
  19118. */
  19119. constructor(type: number, jointData: PhysicsJointData);
  19120. /**
  19121. * Set the motor values.
  19122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19123. * @param force the force to apply
  19124. * @param maxForce max force for this motor.
  19125. */
  19126. setMotor(force?: number, maxForce?: number): void;
  19127. /**
  19128. * Set the motor's limits.
  19129. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19130. * @param upperLimit The upper limit of the motor
  19131. * @param lowerLimit The lower limit of the motor
  19132. */
  19133. setLimit(upperLimit: number, lowerLimit?: number): void;
  19134. }
  19135. /**
  19136. * This class represents a single physics Hinge-Joint
  19137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19138. */
  19139. export class HingeJoint extends MotorEnabledJoint {
  19140. /**
  19141. * Initializes the Hinge-Joint
  19142. * @param jointData The joint data for the Hinge-Joint
  19143. */
  19144. constructor(jointData: PhysicsJointData);
  19145. /**
  19146. * Set the motor values.
  19147. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19148. * @param {number} force the force to apply
  19149. * @param {number} maxForce max force for this motor.
  19150. */
  19151. setMotor(force?: number, maxForce?: number): void;
  19152. /**
  19153. * Set the motor's limits.
  19154. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19155. * @param upperLimit The upper limit of the motor
  19156. * @param lowerLimit The lower limit of the motor
  19157. */
  19158. setLimit(upperLimit: number, lowerLimit?: number): void;
  19159. }
  19160. /**
  19161. * This class represents a dual hinge physics joint (same as wheel joint)
  19162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19163. */
  19164. export class Hinge2Joint extends MotorEnabledJoint {
  19165. /**
  19166. * Initializes the Hinge2-Joint
  19167. * @param jointData The joint data for the Hinge2-Joint
  19168. */
  19169. constructor(jointData: PhysicsJointData);
  19170. /**
  19171. * Set the motor values.
  19172. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19173. * @param {number} targetSpeed the speed the motor is to reach
  19174. * @param {number} maxForce max force for this motor.
  19175. * @param {motorIndex} the motor's index, 0 or 1.
  19176. */
  19177. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19178. /**
  19179. * Set the motor limits.
  19180. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19181. * @param {number} upperLimit the upper limit
  19182. * @param {number} lowerLimit lower limit
  19183. * @param {motorIndex} the motor's index, 0 or 1.
  19184. */
  19185. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19186. }
  19187. /**
  19188. * Interface for a motor enabled joint
  19189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19190. */
  19191. export interface IMotorEnabledJoint {
  19192. /**
  19193. * Physics joint
  19194. */
  19195. physicsJoint: any;
  19196. /**
  19197. * Sets the motor of the motor-enabled joint
  19198. * @param force The force of the motor
  19199. * @param maxForce The maximum force of the motor
  19200. * @param motorIndex The index of the motor
  19201. */
  19202. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19203. /**
  19204. * Sets the limit of the motor
  19205. * @param upperLimit The upper limit of the motor
  19206. * @param lowerLimit The lower limit of the motor
  19207. * @param motorIndex The index of the motor
  19208. */
  19209. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19210. }
  19211. /**
  19212. * Joint data for a Distance-Joint
  19213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19214. */
  19215. export interface DistanceJointData extends PhysicsJointData {
  19216. /**
  19217. * Max distance the 2 joint objects can be apart
  19218. */
  19219. maxDistance: number;
  19220. }
  19221. /**
  19222. * Joint data from a spring joint
  19223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19224. */
  19225. export interface SpringJointData extends PhysicsJointData {
  19226. /**
  19227. * Length of the spring
  19228. */
  19229. length: number;
  19230. /**
  19231. * Stiffness of the spring
  19232. */
  19233. stiffness: number;
  19234. /**
  19235. * Damping of the spring
  19236. */
  19237. damping: number;
  19238. /** this callback will be called when applying the force to the impostors. */
  19239. forceApplicationCallback: () => void;
  19240. }
  19241. }
  19242. declare module BABYLON {
  19243. /**
  19244. * Holds the data for the raycast result
  19245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19246. */
  19247. export class PhysicsRaycastResult {
  19248. private _hasHit;
  19249. private _hitDistance;
  19250. private _hitNormalWorld;
  19251. private _hitPointWorld;
  19252. private _rayFromWorld;
  19253. private _rayToWorld;
  19254. /**
  19255. * Gets if there was a hit
  19256. */
  19257. readonly hasHit: boolean;
  19258. /**
  19259. * Gets the distance from the hit
  19260. */
  19261. readonly hitDistance: number;
  19262. /**
  19263. * Gets the hit normal/direction in the world
  19264. */
  19265. readonly hitNormalWorld: Vector3;
  19266. /**
  19267. * Gets the hit point in the world
  19268. */
  19269. readonly hitPointWorld: Vector3;
  19270. /**
  19271. * Gets the ray "start point" of the ray in the world
  19272. */
  19273. readonly rayFromWorld: Vector3;
  19274. /**
  19275. * Gets the ray "end point" of the ray in the world
  19276. */
  19277. readonly rayToWorld: Vector3;
  19278. /**
  19279. * Sets the hit data (normal & point in world space)
  19280. * @param hitNormalWorld defines the normal in world space
  19281. * @param hitPointWorld defines the point in world space
  19282. */
  19283. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19284. /**
  19285. * Sets the distance from the start point to the hit point
  19286. * @param distance
  19287. */
  19288. setHitDistance(distance: number): void;
  19289. /**
  19290. * Calculates the distance manually
  19291. */
  19292. calculateHitDistance(): void;
  19293. /**
  19294. * Resets all the values to default
  19295. * @param from The from point on world space
  19296. * @param to The to point on world space
  19297. */
  19298. reset(from?: Vector3, to?: Vector3): void;
  19299. }
  19300. /**
  19301. * Interface for the size containing width and height
  19302. */
  19303. interface IXYZ {
  19304. /**
  19305. * X
  19306. */
  19307. x: number;
  19308. /**
  19309. * Y
  19310. */
  19311. y: number;
  19312. /**
  19313. * Z
  19314. */
  19315. z: number;
  19316. }
  19317. }
  19318. declare module BABYLON {
  19319. /**
  19320. * Interface used to describe a physics joint
  19321. */
  19322. export interface PhysicsImpostorJoint {
  19323. /** Defines the main impostor to which the joint is linked */
  19324. mainImpostor: PhysicsImpostor;
  19325. /** Defines the impostor that is connected to the main impostor using this joint */
  19326. connectedImpostor: PhysicsImpostor;
  19327. /** Defines the joint itself */
  19328. joint: PhysicsJoint;
  19329. }
  19330. /** @hidden */
  19331. export interface IPhysicsEnginePlugin {
  19332. world: any;
  19333. name: string;
  19334. setGravity(gravity: Vector3): void;
  19335. setTimeStep(timeStep: number): void;
  19336. getTimeStep(): number;
  19337. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19338. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19339. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19340. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19341. removePhysicsBody(impostor: PhysicsImpostor): void;
  19342. generateJoint(joint: PhysicsImpostorJoint): void;
  19343. removeJoint(joint: PhysicsImpostorJoint): void;
  19344. isSupported(): boolean;
  19345. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19346. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19347. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19348. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19349. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19350. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19351. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19352. getBodyMass(impostor: PhysicsImpostor): number;
  19353. getBodyFriction(impostor: PhysicsImpostor): number;
  19354. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19355. getBodyRestitution(impostor: PhysicsImpostor): number;
  19356. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19357. getBodyPressure?(impostor: PhysicsImpostor): number;
  19358. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19359. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19360. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19361. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19362. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19363. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19364. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19365. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19366. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19367. sleepBody(impostor: PhysicsImpostor): void;
  19368. wakeUpBody(impostor: PhysicsImpostor): void;
  19369. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19370. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19371. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19372. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19373. getRadius(impostor: PhysicsImpostor): number;
  19374. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19375. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19376. dispose(): void;
  19377. }
  19378. /**
  19379. * Interface used to define a physics engine
  19380. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19381. */
  19382. export interface IPhysicsEngine {
  19383. /**
  19384. * Gets the gravity vector used by the simulation
  19385. */
  19386. gravity: Vector3;
  19387. /**
  19388. * Sets the gravity vector used by the simulation
  19389. * @param gravity defines the gravity vector to use
  19390. */
  19391. setGravity(gravity: Vector3): void;
  19392. /**
  19393. * Set the time step of the physics engine.
  19394. * Default is 1/60.
  19395. * To slow it down, enter 1/600 for example.
  19396. * To speed it up, 1/30
  19397. * @param newTimeStep the new timestep to apply to this world.
  19398. */
  19399. setTimeStep(newTimeStep: number): void;
  19400. /**
  19401. * Get the time step of the physics engine.
  19402. * @returns the current time step
  19403. */
  19404. getTimeStep(): number;
  19405. /**
  19406. * Release all resources
  19407. */
  19408. dispose(): void;
  19409. /**
  19410. * Gets the name of the current physics plugin
  19411. * @returns the name of the plugin
  19412. */
  19413. getPhysicsPluginName(): string;
  19414. /**
  19415. * Adding a new impostor for the impostor tracking.
  19416. * This will be done by the impostor itself.
  19417. * @param impostor the impostor to add
  19418. */
  19419. addImpostor(impostor: PhysicsImpostor): void;
  19420. /**
  19421. * Remove an impostor from the engine.
  19422. * This impostor and its mesh will not longer be updated by the physics engine.
  19423. * @param impostor the impostor to remove
  19424. */
  19425. removeImpostor(impostor: PhysicsImpostor): void;
  19426. /**
  19427. * Add a joint to the physics engine
  19428. * @param mainImpostor defines the main impostor to which the joint is added.
  19429. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19430. * @param joint defines the joint that will connect both impostors.
  19431. */
  19432. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19433. /**
  19434. * Removes a joint from the simulation
  19435. * @param mainImpostor defines the impostor used with the joint
  19436. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19437. * @param joint defines the joint to remove
  19438. */
  19439. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19440. /**
  19441. * Gets the current plugin used to run the simulation
  19442. * @returns current plugin
  19443. */
  19444. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19445. /**
  19446. * Gets the list of physic impostors
  19447. * @returns an array of PhysicsImpostor
  19448. */
  19449. getImpostors(): Array<PhysicsImpostor>;
  19450. /**
  19451. * Gets the impostor for a physics enabled object
  19452. * @param object defines the object impersonated by the impostor
  19453. * @returns the PhysicsImpostor or null if not found
  19454. */
  19455. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19456. /**
  19457. * Gets the impostor for a physics body object
  19458. * @param body defines physics body used by the impostor
  19459. * @returns the PhysicsImpostor or null if not found
  19460. */
  19461. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19462. /**
  19463. * Does a raycast in the physics world
  19464. * @param from when should the ray start?
  19465. * @param to when should the ray end?
  19466. * @returns PhysicsRaycastResult
  19467. */
  19468. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19469. /**
  19470. * Called by the scene. No need to call it.
  19471. * @param delta defines the timespam between frames
  19472. */ step(delta: number): void;
  19473. }
  19474. }
  19475. declare module BABYLON {
  19476. /**
  19477. * The interface for the physics imposter parameters
  19478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19479. */
  19480. export interface PhysicsImpostorParameters {
  19481. /**
  19482. * The mass of the physics imposter
  19483. */
  19484. mass: number;
  19485. /**
  19486. * The friction of the physics imposter
  19487. */
  19488. friction?: number;
  19489. /**
  19490. * The coefficient of restitution of the physics imposter
  19491. */
  19492. restitution?: number;
  19493. /**
  19494. * The native options of the physics imposter
  19495. */
  19496. nativeOptions?: any;
  19497. /**
  19498. * Specifies if the parent should be ignored
  19499. */
  19500. ignoreParent?: boolean;
  19501. /**
  19502. * Specifies if bi-directional transformations should be disabled
  19503. */
  19504. disableBidirectionalTransformation?: boolean;
  19505. /**
  19506. * The pressure inside the physics imposter, soft object only
  19507. */
  19508. pressure?: number;
  19509. /**
  19510. * The stiffness the physics imposter, soft object only
  19511. */
  19512. stiffness?: number;
  19513. /**
  19514. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19515. */
  19516. velocityIterations?: number;
  19517. /**
  19518. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19519. */
  19520. positionIterations?: number;
  19521. /**
  19522. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19523. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19524. * Add to fix multiple points
  19525. */
  19526. fixedPoints?: number;
  19527. /**
  19528. * The collision margin around a soft object
  19529. */
  19530. margin?: number;
  19531. /**
  19532. * The collision margin around a soft object
  19533. */
  19534. damping?: number;
  19535. /**
  19536. * The path for a rope based on an extrusion
  19537. */
  19538. path?: any;
  19539. /**
  19540. * The shape of an extrusion used for a rope based on an extrusion
  19541. */
  19542. shape?: any;
  19543. }
  19544. /**
  19545. * Interface for a physics-enabled object
  19546. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19547. */
  19548. export interface IPhysicsEnabledObject {
  19549. /**
  19550. * The position of the physics-enabled object
  19551. */
  19552. position: Vector3;
  19553. /**
  19554. * The rotation of the physics-enabled object
  19555. */
  19556. rotationQuaternion: Nullable<Quaternion>;
  19557. /**
  19558. * The scale of the physics-enabled object
  19559. */
  19560. scaling: Vector3;
  19561. /**
  19562. * The rotation of the physics-enabled object
  19563. */
  19564. rotation?: Vector3;
  19565. /**
  19566. * The parent of the physics-enabled object
  19567. */
  19568. parent?: any;
  19569. /**
  19570. * The bounding info of the physics-enabled object
  19571. * @returns The bounding info of the physics-enabled object
  19572. */
  19573. getBoundingInfo(): BoundingInfo;
  19574. /**
  19575. * Computes the world matrix
  19576. * @param force Specifies if the world matrix should be computed by force
  19577. * @returns A world matrix
  19578. */
  19579. computeWorldMatrix(force: boolean): Matrix;
  19580. /**
  19581. * Gets the world matrix
  19582. * @returns A world matrix
  19583. */
  19584. getWorldMatrix?(): Matrix;
  19585. /**
  19586. * Gets the child meshes
  19587. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19588. * @returns An array of abstract meshes
  19589. */
  19590. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19591. /**
  19592. * Gets the vertex data
  19593. * @param kind The type of vertex data
  19594. * @returns A nullable array of numbers, or a float32 array
  19595. */
  19596. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19597. /**
  19598. * Gets the indices from the mesh
  19599. * @returns A nullable array of index arrays
  19600. */
  19601. getIndices?(): Nullable<IndicesArray>;
  19602. /**
  19603. * Gets the scene from the mesh
  19604. * @returns the indices array or null
  19605. */
  19606. getScene?(): Scene;
  19607. /**
  19608. * Gets the absolute position from the mesh
  19609. * @returns the absolute position
  19610. */
  19611. getAbsolutePosition(): Vector3;
  19612. /**
  19613. * Gets the absolute pivot point from the mesh
  19614. * @returns the absolute pivot point
  19615. */
  19616. getAbsolutePivotPoint(): Vector3;
  19617. /**
  19618. * Rotates the mesh
  19619. * @param axis The axis of rotation
  19620. * @param amount The amount of rotation
  19621. * @param space The space of the rotation
  19622. * @returns The rotation transform node
  19623. */
  19624. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19625. /**
  19626. * Translates the mesh
  19627. * @param axis The axis of translation
  19628. * @param distance The distance of translation
  19629. * @param space The space of the translation
  19630. * @returns The transform node
  19631. */
  19632. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19633. /**
  19634. * Sets the absolute position of the mesh
  19635. * @param absolutePosition The absolute position of the mesh
  19636. * @returns The transform node
  19637. */
  19638. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19639. /**
  19640. * Gets the class name of the mesh
  19641. * @returns The class name
  19642. */
  19643. getClassName(): string;
  19644. }
  19645. /**
  19646. * Represents a physics imposter
  19647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19648. */
  19649. export class PhysicsImpostor {
  19650. /**
  19651. * The physics-enabled object used as the physics imposter
  19652. */
  19653. object: IPhysicsEnabledObject;
  19654. /**
  19655. * The type of the physics imposter
  19656. */
  19657. type: number;
  19658. private _options;
  19659. private _scene?;
  19660. /**
  19661. * The default object size of the imposter
  19662. */
  19663. static DEFAULT_OBJECT_SIZE: Vector3;
  19664. /**
  19665. * The identity quaternion of the imposter
  19666. */
  19667. static IDENTITY_QUATERNION: Quaternion;
  19668. /** @hidden */ pluginData: any;
  19669. private _physicsEngine;
  19670. private _physicsBody;
  19671. private _bodyUpdateRequired;
  19672. private _onBeforePhysicsStepCallbacks;
  19673. private _onAfterPhysicsStepCallbacks;
  19674. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  19675. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19676. otherImpostors: Array<PhysicsImpostor>;
  19677. }>;
  19678. private _deltaPosition;
  19679. private _deltaRotation;
  19680. private _deltaRotationConjugated;
  19681. /** hidden */ isFromLine: boolean;
  19682. private _parent;
  19683. private _isDisposed;
  19684. private static _tmpVecs;
  19685. private static _tmpQuat;
  19686. /**
  19687. * Specifies if the physics imposter is disposed
  19688. */
  19689. readonly isDisposed: boolean;
  19690. /**
  19691. * Gets the mass of the physics imposter
  19692. */
  19693. mass: number;
  19694. /**
  19695. * Gets the coefficient of friction
  19696. */
  19697. /**
  19698. * Sets the coefficient of friction
  19699. */
  19700. friction: number;
  19701. /**
  19702. * Gets the coefficient of restitution
  19703. */
  19704. /**
  19705. * Sets the coefficient of restitution
  19706. */
  19707. restitution: number;
  19708. /**
  19709. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  19710. */
  19711. /**
  19712. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  19713. */
  19714. pressure: number;
  19715. /**
  19716. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  19717. */
  19718. /**
  19719. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  19720. */
  19721. stiffness: number;
  19722. /**
  19723. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  19724. */
  19725. /**
  19726. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  19727. */
  19728. velocityIterations: number;
  19729. /**
  19730. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  19731. */
  19732. /**
  19733. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  19734. */
  19735. positionIterations: number;
  19736. /**
  19737. * The unique id of the physics imposter
  19738. * set by the physics engine when adding this impostor to the array
  19739. */
  19740. uniqueId: number;
  19741. /**
  19742. * @hidden
  19743. */
  19744. soft: boolean;
  19745. /**
  19746. * @hidden
  19747. */
  19748. segments: number;
  19749. private _joints;
  19750. /**
  19751. * Initializes the physics imposter
  19752. * @param object The physics-enabled object used as the physics imposter
  19753. * @param type The type of the physics imposter
  19754. * @param _options The options for the physics imposter
  19755. * @param _scene The Babylon scene
  19756. */
  19757. constructor(
  19758. /**
  19759. * The physics-enabled object used as the physics imposter
  19760. */
  19761. object: IPhysicsEnabledObject,
  19762. /**
  19763. * The type of the physics imposter
  19764. */
  19765. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19766. /**
  19767. * This function will completly initialize this impostor.
  19768. * It will create a new body - but only if this mesh has no parent.
  19769. * If it has, this impostor will not be used other than to define the impostor
  19770. * of the child mesh.
  19771. * @hidden
  19772. */ init(): void;
  19773. private _getPhysicsParent;
  19774. /**
  19775. * Should a new body be generated.
  19776. * @returns boolean specifying if body initialization is required
  19777. */
  19778. isBodyInitRequired(): boolean;
  19779. /**
  19780. * Sets the updated scaling
  19781. * @param updated Specifies if the scaling is updated
  19782. */
  19783. setScalingUpdated(): void;
  19784. /**
  19785. * Force a regeneration of this or the parent's impostor's body.
  19786. * Use under cautious - This will remove all joints already implemented.
  19787. */
  19788. forceUpdate(): void;
  19789. /**
  19790. * Gets the body that holds this impostor. Either its own, or its parent.
  19791. */
  19792. /**
  19793. * Set the physics body. Used mainly by the physics engine/plugin
  19794. */
  19795. physicsBody: any;
  19796. /**
  19797. * Get the parent of the physics imposter
  19798. * @returns Physics imposter or null
  19799. */
  19800. /**
  19801. * Sets the parent of the physics imposter
  19802. */
  19803. parent: Nullable<PhysicsImpostor>;
  19804. /**
  19805. * Resets the update flags
  19806. */
  19807. resetUpdateFlags(): void;
  19808. /**
  19809. * Gets the object extend size
  19810. * @returns the object extend size
  19811. */
  19812. getObjectExtendSize(): Vector3;
  19813. /**
  19814. * Gets the object center
  19815. * @returns The object center
  19816. */
  19817. getObjectCenter(): Vector3;
  19818. /**
  19819. * Get a specific parametes from the options parameter
  19820. * @param paramName The object parameter name
  19821. * @returns The object parameter
  19822. */
  19823. getParam(paramName: string): any;
  19824. /**
  19825. * Sets a specific parameter in the options given to the physics plugin
  19826. * @param paramName The parameter name
  19827. * @param value The value of the parameter
  19828. */
  19829. setParam(paramName: string, value: number): void;
  19830. /**
  19831. * Specifically change the body's mass option. Won't recreate the physics body object
  19832. * @param mass The mass of the physics imposter
  19833. */
  19834. setMass(mass: number): void;
  19835. /**
  19836. * Gets the linear velocity
  19837. * @returns linear velocity or null
  19838. */
  19839. getLinearVelocity(): Nullable<Vector3>;
  19840. /**
  19841. * Sets the linear velocity
  19842. * @param velocity linear velocity or null
  19843. */
  19844. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19845. /**
  19846. * Gets the angular velocity
  19847. * @returns angular velocity or null
  19848. */
  19849. getAngularVelocity(): Nullable<Vector3>;
  19850. /**
  19851. * Sets the angular velocity
  19852. * @param velocity The velocity or null
  19853. */
  19854. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19855. /**
  19856. * Execute a function with the physics plugin native code
  19857. * Provide a function the will have two variables - the world object and the physics body object
  19858. * @param func The function to execute with the physics plugin native code
  19859. */
  19860. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19861. /**
  19862. * Register a function that will be executed before the physics world is stepping forward
  19863. * @param func The function to execute before the physics world is stepped forward
  19864. */
  19865. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19866. /**
  19867. * Unregister a function that will be executed before the physics world is stepping forward
  19868. * @param func The function to execute before the physics world is stepped forward
  19869. */
  19870. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19871. /**
  19872. * Register a function that will be executed after the physics step
  19873. * @param func The function to execute after physics step
  19874. */
  19875. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19876. /**
  19877. * Unregisters a function that will be executed after the physics step
  19878. * @param func The function to execute after physics step
  19879. */
  19880. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19881. /**
  19882. * register a function that will be executed when this impostor collides against a different body
  19883. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19884. * @param func Callback that is executed on collision
  19885. */
  19886. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19887. /**
  19888. * Unregisters the physics imposter on contact
  19889. * @param collideAgainst The physics object to collide against
  19890. * @param func Callback to execute on collision
  19891. */
  19892. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19893. private _tmpQuat;
  19894. private _tmpQuat2;
  19895. /**
  19896. * Get the parent rotation
  19897. * @returns The parent rotation
  19898. */
  19899. getParentsRotation(): Quaternion;
  19900. /**
  19901. * this function is executed by the physics engine.
  19902. */
  19903. beforeStep: () => void;
  19904. /**
  19905. * this function is executed by the physics engine
  19906. */
  19907. afterStep: () => void;
  19908. /**
  19909. * Legacy collision detection event support
  19910. */
  19911. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19912. /**
  19913. * event and body object due to cannon's event-based architecture.
  19914. */
  19915. onCollide: (e: {
  19916. body: any;
  19917. }) => void;
  19918. /**
  19919. * Apply a force
  19920. * @param force The force to apply
  19921. * @param contactPoint The contact point for the force
  19922. * @returns The physics imposter
  19923. */
  19924. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19925. /**
  19926. * Apply an impulse
  19927. * @param force The impulse force
  19928. * @param contactPoint The contact point for the impulse force
  19929. * @returns The physics imposter
  19930. */
  19931. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19932. /**
  19933. * A help function to create a joint
  19934. * @param otherImpostor A physics imposter used to create a joint
  19935. * @param jointType The type of joint
  19936. * @param jointData The data for the joint
  19937. * @returns The physics imposter
  19938. */
  19939. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19940. /**
  19941. * Add a joint to this impostor with a different impostor
  19942. * @param otherImpostor A physics imposter used to add a joint
  19943. * @param joint The joint to add
  19944. * @returns The physics imposter
  19945. */
  19946. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19947. /**
  19948. * Add an anchor to a cloth impostor
  19949. * @param otherImpostor rigid impostor to anchor to
  19950. * @param width ratio across width from 0 to 1
  19951. * @param height ratio up height from 0 to 1
  19952. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  19953. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  19954. * @returns impostor the soft imposter
  19955. */
  19956. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  19957. /**
  19958. * Add a hook to a rope impostor
  19959. * @param otherImpostor rigid impostor to anchor to
  19960. * @param length ratio across rope from 0 to 1
  19961. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  19962. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  19963. * @returns impostor the rope imposter
  19964. */
  19965. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  19966. /**
  19967. * Will keep this body still, in a sleep mode.
  19968. * @returns the physics imposter
  19969. */
  19970. sleep(): PhysicsImpostor;
  19971. /**
  19972. * Wake the body up.
  19973. * @returns The physics imposter
  19974. */
  19975. wakeUp(): PhysicsImpostor;
  19976. /**
  19977. * Clones the physics imposter
  19978. * @param newObject The physics imposter clones to this physics-enabled object
  19979. * @returns A nullable physics imposter
  19980. */
  19981. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19982. /**
  19983. * Disposes the physics imposter
  19984. */
  19985. dispose(): void;
  19986. /**
  19987. * Sets the delta position
  19988. * @param position The delta position amount
  19989. */
  19990. setDeltaPosition(position: Vector3): void;
  19991. /**
  19992. * Sets the delta rotation
  19993. * @param rotation The delta rotation amount
  19994. */
  19995. setDeltaRotation(rotation: Quaternion): void;
  19996. /**
  19997. * Gets the box size of the physics imposter and stores the result in the input parameter
  19998. * @param result Stores the box size
  19999. * @returns The physics imposter
  20000. */
  20001. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20002. /**
  20003. * Gets the radius of the physics imposter
  20004. * @returns Radius of the physics imposter
  20005. */
  20006. getRadius(): number;
  20007. /**
  20008. * Sync a bone with this impostor
  20009. * @param bone The bone to sync to the impostor.
  20010. * @param boneMesh The mesh that the bone is influencing.
  20011. * @param jointPivot The pivot of the joint / bone in local space.
  20012. * @param distToJoint Optional distance from the impostor to the joint.
  20013. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20014. */
  20015. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20016. /**
  20017. * Sync impostor to a bone
  20018. * @param bone The bone that the impostor will be synced to.
  20019. * @param boneMesh The mesh that the bone is influencing.
  20020. * @param jointPivot The pivot of the joint / bone in local space.
  20021. * @param distToJoint Optional distance from the impostor to the joint.
  20022. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20023. * @param boneAxis Optional vector3 axis the bone is aligned with
  20024. */
  20025. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20026. /**
  20027. * No-Imposter type
  20028. */
  20029. static NoImpostor: number;
  20030. /**
  20031. * Sphere-Imposter type
  20032. */
  20033. static SphereImpostor: number;
  20034. /**
  20035. * Box-Imposter type
  20036. */
  20037. static BoxImpostor: number;
  20038. /**
  20039. * Plane-Imposter type
  20040. */
  20041. static PlaneImpostor: number;
  20042. /**
  20043. * Mesh-imposter type
  20044. */
  20045. static MeshImpostor: number;
  20046. /**
  20047. * Cylinder-Imposter type
  20048. */
  20049. static CylinderImpostor: number;
  20050. /**
  20051. * Particle-Imposter type
  20052. */
  20053. static ParticleImpostor: number;
  20054. /**
  20055. * Heightmap-Imposter type
  20056. */
  20057. static HeightmapImpostor: number;
  20058. /**
  20059. * ConvexHull-Impostor type (Ammo.js plugin only)
  20060. */
  20061. static ConvexHullImpostor: number;
  20062. /**
  20063. * Rope-Imposter type
  20064. */
  20065. static RopeImpostor: number;
  20066. /**
  20067. * Cloth-Imposter type
  20068. */
  20069. static ClothImpostor: number;
  20070. /**
  20071. * Softbody-Imposter type
  20072. */
  20073. static SoftbodyImpostor: number;
  20074. }
  20075. }
  20076. declare module BABYLON {
  20077. /**
  20078. * Class used to represent a specific level of detail of a mesh
  20079. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20080. */
  20081. export class MeshLODLevel {
  20082. /** Defines the distance where this level should star being displayed */
  20083. distance: number;
  20084. /** Defines the mesh to use to render this level */
  20085. mesh: Nullable<Mesh>;
  20086. /**
  20087. * Creates a new LOD level
  20088. * @param distance defines the distance where this level should star being displayed
  20089. * @param mesh defines the mesh to use to render this level
  20090. */
  20091. constructor(
  20092. /** Defines the distance where this level should star being displayed */
  20093. distance: number,
  20094. /** Defines the mesh to use to render this level */
  20095. mesh: Nullable<Mesh>);
  20096. }
  20097. /**
  20098. * @hidden
  20099. **/
  20100. export class _CreationDataStorage {
  20101. closePath?: boolean;
  20102. closeArray?: boolean;
  20103. idx: number[];
  20104. dashSize: number;
  20105. gapSize: number;
  20106. path3D: Path3D;
  20107. pathArray: Vector3[][];
  20108. arc: number;
  20109. radius: number;
  20110. cap: number;
  20111. tessellation: number;
  20112. }
  20113. /**
  20114. * @hidden
  20115. **/ private class _InstanceDataStorage {
  20116. visibleInstances: any;
  20117. batchCache: _InstancesBatch;
  20118. instancesBufferSize: number;
  20119. instancesBuffer: Nullable<Buffer>;
  20120. instancesData: Float32Array;
  20121. overridenInstanceCount: number;
  20122. isFrozen: boolean;
  20123. previousBatch: _InstancesBatch;
  20124. hardwareInstancedRendering: boolean;
  20125. sideOrientation: number;
  20126. }
  20127. /**
  20128. * @hidden
  20129. **/
  20130. export class _InstancesBatch {
  20131. mustReturn: boolean;
  20132. visibleInstances: Nullable<InstancedMesh[]>[];
  20133. renderSelf: boolean[];
  20134. hardwareInstancedRendering: boolean[];
  20135. }
  20136. /**
  20137. * Class used to represent renderable models
  20138. */
  20139. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20140. /**
  20141. * Mesh side orientation : usually the external or front surface
  20142. */
  20143. static readonly FRONTSIDE: number;
  20144. /**
  20145. * Mesh side orientation : usually the internal or back surface
  20146. */
  20147. static readonly BACKSIDE: number;
  20148. /**
  20149. * Mesh side orientation : both internal and external or front and back surfaces
  20150. */
  20151. static readonly DOUBLESIDE: number;
  20152. /**
  20153. * Mesh side orientation : by default, `FRONTSIDE`
  20154. */
  20155. static readonly DEFAULTSIDE: number;
  20156. /**
  20157. * Mesh cap setting : no cap
  20158. */
  20159. static readonly NO_CAP: number;
  20160. /**
  20161. * Mesh cap setting : one cap at the beginning of the mesh
  20162. */
  20163. static readonly CAP_START: number;
  20164. /**
  20165. * Mesh cap setting : one cap at the end of the mesh
  20166. */
  20167. static readonly CAP_END: number;
  20168. /**
  20169. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20170. */
  20171. static readonly CAP_ALL: number;
  20172. /**
  20173. * Gets the default side orientation.
  20174. * @param orientation the orientation to value to attempt to get
  20175. * @returns the default orientation
  20176. * @hidden
  20177. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  20178. private _onBeforeRenderObservable;
  20179. private _onBeforeBindObservable;
  20180. private _onAfterRenderObservable;
  20181. private _onBeforeDrawObservable;
  20182. /**
  20183. * An event triggered before rendering the mesh
  20184. */
  20185. readonly onBeforeRenderObservable: Observable<Mesh>;
  20186. /**
  20187. * An event triggered before binding the mesh
  20188. */
  20189. readonly onBeforeBindObservable: Observable<Mesh>;
  20190. /**
  20191. * An event triggered after rendering the mesh
  20192. */
  20193. readonly onAfterRenderObservable: Observable<Mesh>;
  20194. /**
  20195. * An event triggered before drawing the mesh
  20196. */
  20197. readonly onBeforeDrawObservable: Observable<Mesh>;
  20198. private _onBeforeDrawObserver;
  20199. /**
  20200. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20201. */
  20202. onBeforeDraw: () => void;
  20203. /**
  20204. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20205. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20206. */
  20207. delayLoadState: number;
  20208. /**
  20209. * Gets the list of instances created from this mesh
  20210. * it is not supposed to be modified manually.
  20211. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20212. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20213. */
  20214. instances: InstancedMesh[];
  20215. /**
  20216. * Gets the file containing delay loading data for this mesh
  20217. */
  20218. delayLoadingFile: string;
  20219. /** @hidden */ binaryInfo: any;
  20220. private _LODLevels;
  20221. /**
  20222. * User defined function used to change how LOD level selection is done
  20223. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20224. */
  20225. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20226. private _morphTargetManager;
  20227. /**
  20228. * Gets or sets the morph target manager
  20229. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20230. */
  20231. morphTargetManager: Nullable<MorphTargetManager>;
  20232. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  20233. /** @hidden */ geometry: Nullable<Geometry>;
  20234. /** @hidden */ delayInfo: Array<string>;
  20235. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20236. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  20237. private _effectiveMaterial;
  20238. /** @hidden */ shouldGenerateFlatShading: boolean;
  20239. private _preActivateId;
  20240. /** @hidden */ originalBuilderSideOrientation: number;
  20241. /**
  20242. * Use this property to change the original side orientation defined at construction time
  20243. */
  20244. overrideMaterialSideOrientation: Nullable<number>;
  20245. private _areNormalsFrozen;
  20246. private _sourcePositions;
  20247. private _sourceNormals;
  20248. private _source;
  20249. private meshMap;
  20250. /**
  20251. * Gets the source mesh (the one used to clone this one from)
  20252. */
  20253. readonly source: Nullable<Mesh>;
  20254. /**
  20255. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20256. */
  20257. isUnIndexed: boolean;
  20258. /**
  20259. * @constructor
  20260. * @param name The value used by scene.getMeshByName() to do a lookup.
  20261. * @param scene The scene to add this mesh to.
  20262. * @param parent The parent of this mesh, if it has one
  20263. * @param source An optional Mesh from which geometry is shared, cloned.
  20264. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20265. * When false, achieved by calling a clone(), also passing False.
  20266. * This will make creation of children, recursive.
  20267. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20268. */
  20269. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20270. /**
  20271. * Gets the class name
  20272. * @returns the string "Mesh".
  20273. */
  20274. getClassName(): string;
  20275. /** @hidden */ protected readonly _isMesh: boolean;
  20276. /**
  20277. * Returns a description of this mesh
  20278. * @param fullDetails define if full details about this mesh must be used
  20279. * @returns a descriptive string representing this mesh
  20280. */
  20281. toString(fullDetails?: boolean): string;
  20282. /** @hidden */ unBindEffect(): void;
  20283. /**
  20284. * Gets a boolean indicating if this mesh has LOD
  20285. */
  20286. readonly hasLODLevels: boolean;
  20287. /**
  20288. * Gets the list of MeshLODLevel associated with the current mesh
  20289. * @returns an array of MeshLODLevel
  20290. */
  20291. getLODLevels(): MeshLODLevel[];
  20292. private _sortLODLevels;
  20293. /**
  20294. * Add a mesh as LOD level triggered at the given distance.
  20295. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20296. * @param distance The distance from the center of the object to show this level
  20297. * @param mesh The mesh to be added as LOD level (can be null)
  20298. * @return This mesh (for chaining)
  20299. */
  20300. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20301. /**
  20302. * Returns the LOD level mesh at the passed distance or null if not found.
  20303. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20304. * @param distance The distance from the center of the object to show this level
  20305. * @returns a Mesh or `null`
  20306. */
  20307. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20308. /**
  20309. * Remove a mesh from the LOD array
  20310. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20311. * @param mesh defines the mesh to be removed
  20312. * @return This mesh (for chaining)
  20313. */
  20314. removeLODLevel(mesh: Mesh): Mesh;
  20315. /**
  20316. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20317. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20318. * @param camera defines the camera to use to compute distance
  20319. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20320. * @return This mesh (for chaining)
  20321. */
  20322. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20323. /**
  20324. * Gets the mesh internal Geometry object
  20325. */
  20326. readonly geometry: Nullable<Geometry>;
  20327. /**
  20328. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20329. * @returns the total number of vertices
  20330. */
  20331. getTotalVertices(): number;
  20332. /**
  20333. * Returns the content of an associated vertex buffer
  20334. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20335. * - VertexBuffer.PositionKind
  20336. * - VertexBuffer.UVKind
  20337. * - VertexBuffer.UV2Kind
  20338. * - VertexBuffer.UV3Kind
  20339. * - VertexBuffer.UV4Kind
  20340. * - VertexBuffer.UV5Kind
  20341. * - VertexBuffer.UV6Kind
  20342. * - VertexBuffer.ColorKind
  20343. * - VertexBuffer.MatricesIndicesKind
  20344. * - VertexBuffer.MatricesIndicesExtraKind
  20345. * - VertexBuffer.MatricesWeightsKind
  20346. * - VertexBuffer.MatricesWeightsExtraKind
  20347. * @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
  20348. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20349. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20350. */
  20351. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20352. /**
  20353. * Returns the mesh VertexBuffer object from the requested `kind`
  20354. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20355. * - VertexBuffer.PositionKind
  20356. * - VertexBuffer.UVKind
  20357. * - VertexBuffer.UV2Kind
  20358. * - VertexBuffer.UV3Kind
  20359. * - VertexBuffer.UV4Kind
  20360. * - VertexBuffer.UV5Kind
  20361. * - VertexBuffer.UV6Kind
  20362. * - VertexBuffer.ColorKind
  20363. * - VertexBuffer.MatricesIndicesKind
  20364. * - VertexBuffer.MatricesIndicesExtraKind
  20365. * - VertexBuffer.MatricesWeightsKind
  20366. * - VertexBuffer.MatricesWeightsExtraKind
  20367. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20368. */
  20369. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20370. /**
  20371. * Tests if a specific vertex buffer is associated with this mesh
  20372. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20373. * - VertexBuffer.PositionKind
  20374. * - VertexBuffer.UVKind
  20375. * - VertexBuffer.UV2Kind
  20376. * - VertexBuffer.UV3Kind
  20377. * - VertexBuffer.UV4Kind
  20378. * - VertexBuffer.UV5Kind
  20379. * - VertexBuffer.UV6Kind
  20380. * - VertexBuffer.ColorKind
  20381. * - VertexBuffer.MatricesIndicesKind
  20382. * - VertexBuffer.MatricesIndicesExtraKind
  20383. * - VertexBuffer.MatricesWeightsKind
  20384. * - VertexBuffer.MatricesWeightsExtraKind
  20385. * @returns a boolean
  20386. */
  20387. isVerticesDataPresent(kind: string): boolean;
  20388. /**
  20389. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20390. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20391. * - VertexBuffer.PositionKind
  20392. * - VertexBuffer.UVKind
  20393. * - VertexBuffer.UV2Kind
  20394. * - VertexBuffer.UV3Kind
  20395. * - VertexBuffer.UV4Kind
  20396. * - VertexBuffer.UV5Kind
  20397. * - VertexBuffer.UV6Kind
  20398. * - VertexBuffer.ColorKind
  20399. * - VertexBuffer.MatricesIndicesKind
  20400. * - VertexBuffer.MatricesIndicesExtraKind
  20401. * - VertexBuffer.MatricesWeightsKind
  20402. * - VertexBuffer.MatricesWeightsExtraKind
  20403. * @returns a boolean
  20404. */
  20405. isVertexBufferUpdatable(kind: string): boolean;
  20406. /**
  20407. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20408. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20409. * - VertexBuffer.PositionKind
  20410. * - VertexBuffer.UVKind
  20411. * - VertexBuffer.UV2Kind
  20412. * - VertexBuffer.UV3Kind
  20413. * - VertexBuffer.UV4Kind
  20414. * - VertexBuffer.UV5Kind
  20415. * - VertexBuffer.UV6Kind
  20416. * - VertexBuffer.ColorKind
  20417. * - VertexBuffer.MatricesIndicesKind
  20418. * - VertexBuffer.MatricesIndicesExtraKind
  20419. * - VertexBuffer.MatricesWeightsKind
  20420. * - VertexBuffer.MatricesWeightsExtraKind
  20421. * @returns an array of strings
  20422. */
  20423. getVerticesDataKinds(): string[];
  20424. /**
  20425. * Returns a positive integer : the total number of indices in this mesh geometry.
  20426. * @returns the numner of indices or zero if the mesh has no geometry.
  20427. */
  20428. getTotalIndices(): number;
  20429. /**
  20430. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20431. * @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.
  20432. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20433. * @returns the indices array or an empty array if the mesh has no geometry
  20434. */
  20435. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20436. readonly isBlocked: boolean;
  20437. /**
  20438. * Determine if the current mesh is ready to be rendered
  20439. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20440. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20441. * @returns true if all associated assets are ready (material, textures, shaders)
  20442. */
  20443. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20444. /**
  20445. * 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.
  20446. */
  20447. readonly areNormalsFrozen: boolean;
  20448. /**
  20449. * 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.
  20450. * @returns the current mesh
  20451. */
  20452. freezeNormals(): Mesh;
  20453. /**
  20454. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  20455. * @returns the current mesh
  20456. */
  20457. unfreezeNormals(): Mesh;
  20458. /**
  20459. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20460. */
  20461. overridenInstanceCount: number;
  20462. /** @hidden */ preActivate(): Mesh;
  20463. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  20464. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20465. /**
  20466. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20467. * This means the mesh underlying bounding box and sphere are recomputed.
  20468. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20469. * @returns the current mesh
  20470. */
  20471. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20472. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20473. /**
  20474. * This function will subdivide the mesh into multiple submeshes
  20475. * @param count defines the expected number of submeshes
  20476. */
  20477. subdivide(count: number): void;
  20478. /**
  20479. * Copy a FloatArray into a specific associated vertex buffer
  20480. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20481. * - VertexBuffer.PositionKind
  20482. * - VertexBuffer.UVKind
  20483. * - VertexBuffer.UV2Kind
  20484. * - VertexBuffer.UV3Kind
  20485. * - VertexBuffer.UV4Kind
  20486. * - VertexBuffer.UV5Kind
  20487. * - VertexBuffer.UV6Kind
  20488. * - VertexBuffer.ColorKind
  20489. * - VertexBuffer.MatricesIndicesKind
  20490. * - VertexBuffer.MatricesIndicesExtraKind
  20491. * - VertexBuffer.MatricesWeightsKind
  20492. * - VertexBuffer.MatricesWeightsExtraKind
  20493. * @param data defines the data source
  20494. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20495. * @param stride defines the data stride size (can be null)
  20496. * @returns the current mesh
  20497. */
  20498. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20499. /**
  20500. * Flags an associated vertex buffer as updatable
  20501. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20502. * - VertexBuffer.PositionKind
  20503. * - VertexBuffer.UVKind
  20504. * - VertexBuffer.UV2Kind
  20505. * - VertexBuffer.UV3Kind
  20506. * - VertexBuffer.UV4Kind
  20507. * - VertexBuffer.UV5Kind
  20508. * - VertexBuffer.UV6Kind
  20509. * - VertexBuffer.ColorKind
  20510. * - VertexBuffer.MatricesIndicesKind
  20511. * - VertexBuffer.MatricesIndicesExtraKind
  20512. * - VertexBuffer.MatricesWeightsKind
  20513. * - VertexBuffer.MatricesWeightsExtraKind
  20514. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20515. */
  20516. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20517. /**
  20518. * Sets the mesh global Vertex Buffer
  20519. * @param buffer defines the buffer to use
  20520. * @returns the current mesh
  20521. */
  20522. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20523. /**
  20524. * Update a specific associated vertex buffer
  20525. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20526. * - VertexBuffer.PositionKind
  20527. * - VertexBuffer.UVKind
  20528. * - VertexBuffer.UV2Kind
  20529. * - VertexBuffer.UV3Kind
  20530. * - VertexBuffer.UV4Kind
  20531. * - VertexBuffer.UV5Kind
  20532. * - VertexBuffer.UV6Kind
  20533. * - VertexBuffer.ColorKind
  20534. * - VertexBuffer.MatricesIndicesKind
  20535. * - VertexBuffer.MatricesIndicesExtraKind
  20536. * - VertexBuffer.MatricesWeightsKind
  20537. * - VertexBuffer.MatricesWeightsExtraKind
  20538. * @param data defines the data source
  20539. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20540. * @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)
  20541. * @returns the current mesh
  20542. */
  20543. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20544. /**
  20545. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20546. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20547. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20548. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20549. * @returns the current mesh
  20550. */
  20551. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20552. /**
  20553. * Creates a un-shared specific occurence of the geometry for the mesh.
  20554. * @returns the current mesh
  20555. */
  20556. makeGeometryUnique(): Mesh;
  20557. /**
  20558. * Set the index buffer of this mesh
  20559. * @param indices defines the source data
  20560. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20561. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20562. * @returns the current mesh
  20563. */
  20564. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20565. /**
  20566. * Update the current index buffer
  20567. * @param indices defines the source data
  20568. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20569. * @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)
  20570. * @returns the current mesh
  20571. */
  20572. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20573. /**
  20574. * Invert the geometry to move from a right handed system to a left handed one.
  20575. * @returns the current mesh
  20576. */
  20577. toLeftHanded(): Mesh;
  20578. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20579. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20580. /**
  20581. * Registers for this mesh a javascript function called just before the rendering process
  20582. * @param func defines the function to call before rendering this mesh
  20583. * @returns the current mesh
  20584. */
  20585. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20586. /**
  20587. * Disposes a previously registered javascript function called before the rendering
  20588. * @param func defines the function to remove
  20589. * @returns the current mesh
  20590. */
  20591. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20592. /**
  20593. * Registers for this mesh a javascript function called just after the rendering is complete
  20594. * @param func defines the function to call after rendering this mesh
  20595. * @returns the current mesh
  20596. */
  20597. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20598. /**
  20599. * Disposes a previously registered javascript function called after the rendering.
  20600. * @param func defines the function to remove
  20601. * @returns the current mesh
  20602. */
  20603. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20604. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20605. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20606. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20607. /** @hidden */ freeze(): void;
  20608. /** @hidden */ unFreeze(): void;
  20609. /**
  20610. * 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
  20611. * @param subMesh defines the subMesh to render
  20612. * @param enableAlphaMode defines if alpha mode can be changed
  20613. * @returns the current mesh
  20614. */
  20615. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20616. private _onBeforeDraw;
  20617. /**
  20618. * Renormalize the mesh and patch it up if there are no weights
  20619. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20620. * However in the case of zero weights then we set just a single influence to 1.
  20621. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20622. */
  20623. cleanMatrixWeights(): void;
  20624. private normalizeSkinFourWeights;
  20625. private normalizeSkinWeightsAndExtra;
  20626. /**
  20627. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20628. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20629. * the user know there was an issue with importing the mesh
  20630. * @returns a validation object with skinned, valid and report string
  20631. */
  20632. validateSkinning(): {
  20633. skinned: boolean;
  20634. valid: boolean;
  20635. report: string;
  20636. };
  20637. /** @hidden */ checkDelayState(): Mesh;
  20638. private _queueLoad;
  20639. /**
  20640. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20641. * A mesh is in the frustum if its bounding box intersects the frustum
  20642. * @param frustumPlanes defines the frustum to test
  20643. * @returns true if the mesh is in the frustum planes
  20644. */
  20645. isInFrustum(frustumPlanes: Plane[]): boolean;
  20646. /**
  20647. * Sets the mesh material by the material or multiMaterial `id` property
  20648. * @param id is a string identifying the material or the multiMaterial
  20649. * @returns the current mesh
  20650. */
  20651. setMaterialByID(id: string): Mesh;
  20652. /**
  20653. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20654. * @returns an array of IAnimatable
  20655. */
  20656. getAnimatables(): IAnimatable[];
  20657. /**
  20658. * Modifies the mesh geometry according to the passed transformation matrix.
  20659. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20660. * The mesh normals are modified using the same transformation.
  20661. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20662. * @param transform defines the transform matrix to use
  20663. * @see http://doc.babylonjs.com/resources/baking_transformations
  20664. * @returns the current mesh
  20665. */
  20666. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20667. /**
  20668. * Modifies the mesh geometry according to its own current World Matrix.
  20669. * The mesh World Matrix is then reset.
  20670. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20671. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20672. * @see http://doc.babylonjs.com/resources/baking_transformations
  20673. * @returns the current mesh
  20674. */
  20675. bakeCurrentTransformIntoVertices(): Mesh;
  20676. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  20677. /** @hidden */ resetPointsArrayCache(): Mesh;
  20678. /** @hidden */ generatePointsArray(): boolean;
  20679. /**
  20680. * Returns a new Mesh object generated from the current mesh properties.
  20681. * This method must not get confused with createInstance()
  20682. * @param name is a string, the name given to the new mesh
  20683. * @param newParent can be any Node object (default `null`)
  20684. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20685. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20686. * @returns a new mesh
  20687. */
  20688. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20689. /**
  20690. * Releases resources associated with this mesh.
  20691. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20692. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20693. */
  20694. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20695. /**
  20696. * Modifies the mesh geometry according to a displacement map.
  20697. * 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.
  20698. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20699. * @param url is a string, the URL from the image file is to be downloaded.
  20700. * @param minHeight is the lower limit of the displacement.
  20701. * @param maxHeight is the upper limit of the displacement.
  20702. * @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.
  20703. * @param uvOffset is an optional vector2 used to offset UV.
  20704. * @param uvScale is an optional vector2 used to scale UV.
  20705. * @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.
  20706. * @returns the Mesh.
  20707. */
  20708. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20709. /**
  20710. * Modifies the mesh geometry according to a displacementMap buffer.
  20711. * 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.
  20712. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20713. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20714. * @param heightMapWidth is the width of the buffer image.
  20715. * @param heightMapHeight is the height of the buffer image.
  20716. * @param minHeight is the lower limit of the displacement.
  20717. * @param maxHeight is the upper limit of the displacement.
  20718. * @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.
  20719. * @param uvOffset is an optional vector2 used to offset UV.
  20720. * @param uvScale is an optional vector2 used to scale UV.
  20721. * @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.
  20722. * @returns the Mesh.
  20723. */
  20724. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20725. /**
  20726. * Modify the mesh to get a flat shading rendering.
  20727. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20728. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20729. * @returns current mesh
  20730. */
  20731. convertToFlatShadedMesh(): Mesh;
  20732. /**
  20733. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20734. * In other words, more vertices, no more indices and a single bigger VBO.
  20735. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20736. * @returns current mesh
  20737. */
  20738. convertToUnIndexedMesh(): Mesh;
  20739. /**
  20740. * Inverses facet orientations.
  20741. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20742. * @param flipNormals will also inverts the normals
  20743. * @returns current mesh
  20744. */
  20745. flipFaces(flipNormals?: boolean): Mesh;
  20746. /**
  20747. * Increase the number of facets and hence vertices in a mesh
  20748. * Vertex normals are interpolated from existing vertex normals
  20749. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20750. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  20751. */
  20752. increaseVertices(numberPerEdge: number): void;
  20753. /**
  20754. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  20755. * This will undo any application of covertToFlatShadedMesh
  20756. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20757. */
  20758. forceSharedVertices(): void;
  20759. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20760. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20761. /**
  20762. * Creates a new InstancedMesh object from the mesh model.
  20763. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20764. * @param name defines the name of the new instance
  20765. * @returns a new InstancedMesh
  20766. */
  20767. createInstance(name: string): InstancedMesh;
  20768. /**
  20769. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20770. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20771. * @returns the current mesh
  20772. */
  20773. synchronizeInstances(): Mesh;
  20774. /**
  20775. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20776. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20777. * This should be used together with the simplification to avoid disappearing triangles.
  20778. * @param successCallback an optional success callback to be called after the optimization finished.
  20779. * @returns the current mesh
  20780. */
  20781. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20782. /**
  20783. * Serialize current mesh
  20784. * @param serializationObject defines the object which will receive the serialization data
  20785. */
  20786. serialize(serializationObject: any): void;
  20787. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  20788. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20789. /**
  20790. * Returns a new Mesh object parsed from the source provided.
  20791. * @param parsedMesh is the source
  20792. * @param scene defines the hosting scene
  20793. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20794. * @returns a new Mesh
  20795. */
  20796. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20797. /**
  20798. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20799. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20800. * @param name defines the name of the mesh to create
  20801. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20802. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20803. * @param closePath creates a seam between the first and the last points of each path of the path array
  20804. * @param offset is taken in account only if the `pathArray` is containing a single path
  20805. * @param scene defines the hosting scene
  20806. * @param updatable defines if the mesh must be flagged as updatable
  20807. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20808. * @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)
  20809. * @returns a new Mesh
  20810. */
  20811. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20812. /**
  20813. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20814. * @param name defines the name of the mesh to create
  20815. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20816. * @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
  20817. * @param scene defines the hosting scene
  20818. * @param updatable defines if the mesh must be flagged as updatable
  20819. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20820. * @returns a new Mesh
  20821. */
  20822. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20823. /**
  20824. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20825. * @param name defines the name of the mesh to create
  20826. * @param size sets the size (float) of each box side (default 1)
  20827. * @param scene defines the hosting scene
  20828. * @param updatable defines if the mesh must be flagged as updatable
  20829. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20830. * @returns a new Mesh
  20831. */
  20832. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20833. /**
  20834. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20835. * @param name defines the name of the mesh to create
  20836. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20837. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20838. * @param scene defines the hosting scene
  20839. * @param updatable defines if the mesh must be flagged as updatable
  20840. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20841. * @returns a new Mesh
  20842. */
  20843. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20844. /**
  20845. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  20846. * @param name defines the name of the mesh to create
  20847. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20848. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20849. * @param scene defines the hosting scene
  20850. * @returns a new Mesh
  20851. */
  20852. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  20853. /**
  20854. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  20855. * @param name defines the name of the mesh to create
  20856. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  20857. * @param diameterTop set the top cap diameter (floats, default 1)
  20858. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20859. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20860. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20861. * @param scene defines the hosting scene
  20862. * @param updatable defines if the mesh must be flagged as updatable
  20863. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20864. * @returns a new Mesh
  20865. */
  20866. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20867. /**
  20868. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20869. * @param name defines the name of the mesh to create
  20870. * @param diameter sets the diameter size (float) of the torus (default 1)
  20871. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20872. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20873. * @param scene defines the hosting scene
  20874. * @param updatable defines if the mesh must be flagged as updatable
  20875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20876. * @returns a new Mesh
  20877. */
  20878. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20879. /**
  20880. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20881. * @param name defines the name of the mesh to create
  20882. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20883. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20884. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20885. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20886. * @param p the number of windings on X axis (positive integers, default 2)
  20887. * @param q the number of windings on Y axis (positive integers, default 3)
  20888. * @param scene defines the hosting scene
  20889. * @param updatable defines if the mesh must be flagged as updatable
  20890. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20891. * @returns a new Mesh
  20892. */
  20893. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20894. /**
  20895. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20896. * @param name defines the name of the mesh to create
  20897. * @param points is an array successive Vector3
  20898. * @param scene defines the hosting scene
  20899. * @param updatable defines if the mesh must be flagged as updatable
  20900. * @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).
  20901. * @returns a new Mesh
  20902. */
  20903. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20904. /**
  20905. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20906. * @param name defines the name of the mesh to create
  20907. * @param points is an array successive Vector3
  20908. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20909. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20910. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20911. * @param scene defines the hosting scene
  20912. * @param updatable defines if the mesh must be flagged as updatable
  20913. * @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)
  20914. * @returns a new Mesh
  20915. */
  20916. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20917. /**
  20918. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20919. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20920. * 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.
  20921. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20922. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20923. * Remember you can only change the shape positions, not their number when updating a polygon.
  20924. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20925. * @param name defines the name of the mesh to create
  20926. * @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
  20927. * @param scene defines the hosting scene
  20928. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20929. * @param updatable defines if the mesh must be flagged as updatable
  20930. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20931. * @param earcutInjection can be used to inject your own earcut reference
  20932. * @returns a new Mesh
  20933. */
  20934. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20935. /**
  20936. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20937. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20938. * @param name defines the name of the mesh to create
  20939. * @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
  20940. * @param depth defines the height of extrusion
  20941. * @param scene defines the hosting scene
  20942. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20943. * @param updatable defines if the mesh must be flagged as updatable
  20944. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20945. * @param earcutInjection can be used to inject your own earcut reference
  20946. * @returns a new Mesh
  20947. */
  20948. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20949. /**
  20950. * Creates an extruded shape mesh.
  20951. * 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
  20952. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20953. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20954. * @param name defines the name of the mesh to create
  20955. * @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
  20956. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20957. * @param scale is the value to scale the shape
  20958. * @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
  20959. * @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
  20960. * @param scene defines the hosting scene
  20961. * @param updatable defines if the mesh must be flagged as updatable
  20962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20963. * @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)
  20964. * @returns a new Mesh
  20965. */
  20966. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20967. /**
  20968. * Creates an custom extruded shape mesh.
  20969. * The custom extrusion is a parametric shape.
  20970. * It has no predefined shape. Its final shape will depend on the input parameters.
  20971. * Please consider using the same method from the MeshBuilder class instead
  20972. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20973. * @param name defines the name of the mesh to create
  20974. * @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
  20975. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20976. * @param scaleFunction is a custom Javascript function called on each path point
  20977. * @param rotationFunction is a custom Javascript function called on each path point
  20978. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20979. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20980. * @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
  20981. * @param scene defines the hosting scene
  20982. * @param updatable defines if the mesh must be flagged as updatable
  20983. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20984. * @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)
  20985. * @returns a new Mesh
  20986. */
  20987. 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;
  20988. /**
  20989. * Creates lathe mesh.
  20990. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20991. * Please consider using the same method from the MeshBuilder class instead
  20992. * @param name defines the name of the mesh to create
  20993. * @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
  20994. * @param radius is the radius value of the lathe
  20995. * @param tessellation is the side number of the lathe.
  20996. * @param scene defines the hosting scene
  20997. * @param updatable defines if the mesh must be flagged as updatable
  20998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20999. * @returns a new Mesh
  21000. */
  21001. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21002. /**
  21003. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21004. * @param name defines the name of the mesh to create
  21005. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21006. * @param scene defines the hosting scene
  21007. * @param updatable defines if the mesh must be flagged as updatable
  21008. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21009. * @returns a new Mesh
  21010. */
  21011. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21012. /**
  21013. * Creates a ground mesh.
  21014. * Please consider using the same method from the MeshBuilder class instead
  21015. * @param name defines the name of the mesh to create
  21016. * @param width set the width of the ground
  21017. * @param height set the height of the ground
  21018. * @param subdivisions sets the number of subdivisions per side
  21019. * @param scene defines the hosting scene
  21020. * @param updatable defines if the mesh must be flagged as updatable
  21021. * @returns a new Mesh
  21022. */
  21023. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21024. /**
  21025. * Creates a tiled ground mesh.
  21026. * Please consider using the same method from the MeshBuilder class instead
  21027. * @param name defines the name of the mesh to create
  21028. * @param xmin set the ground minimum X coordinate
  21029. * @param zmin set the ground minimum Y coordinate
  21030. * @param xmax set the ground maximum X coordinate
  21031. * @param zmax set the ground maximum Z coordinate
  21032. * @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
  21033. * @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
  21034. * @param scene defines the hosting scene
  21035. * @param updatable defines if the mesh must be flagged as updatable
  21036. * @returns a new Mesh
  21037. */
  21038. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21039. w: number;
  21040. h: number;
  21041. }, precision: {
  21042. w: number;
  21043. h: number;
  21044. }, scene: Scene, updatable?: boolean): Mesh;
  21045. /**
  21046. * Creates a ground mesh from a height map.
  21047. * Please consider using the same method from the MeshBuilder class instead
  21048. * @see http://doc.babylonjs.com/babylon101/height_map
  21049. * @param name defines the name of the mesh to create
  21050. * @param url sets the URL of the height map image resource
  21051. * @param width set the ground width size
  21052. * @param height set the ground height size
  21053. * @param subdivisions sets the number of subdivision per side
  21054. * @param minHeight is the minimum altitude on the ground
  21055. * @param maxHeight is the maximum altitude on the ground
  21056. * @param scene defines the hosting scene
  21057. * @param updatable defines if the mesh must be flagged as updatable
  21058. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21059. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21060. * @returns a new Mesh
  21061. */
  21062. 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;
  21063. /**
  21064. * Creates a tube mesh.
  21065. * The tube is a parametric shape.
  21066. * It has no predefined shape. Its final shape will depend on the input parameters.
  21067. * Please consider using the same method from the MeshBuilder class instead
  21068. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21069. * @param name defines the name of the mesh to create
  21070. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21071. * @param radius sets the tube radius size
  21072. * @param tessellation is the number of sides on the tubular surface
  21073. * @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
  21074. * @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
  21075. * @param scene defines the hosting scene
  21076. * @param updatable defines if the mesh must be flagged as updatable
  21077. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21078. * @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)
  21079. * @returns a new Mesh
  21080. */
  21081. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21082. (i: number, distance: number): number;
  21083. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21084. /**
  21085. * Creates a polyhedron mesh.
  21086. * Please consider using the same method from the MeshBuilder class instead.
  21087. * * 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
  21088. * * The parameter `size` (positive float, default 1) sets the polygon size
  21089. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21090. * * 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`
  21091. * * 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
  21092. * * 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)`)
  21093. * * 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
  21094. * * 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
  21095. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21096. * * If you create a double-sided mesh, you can choose what parts of 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
  21097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21098. * @param name defines the name of the mesh to create
  21099. * @param options defines the options used to create the mesh
  21100. * @param scene defines the hosting scene
  21101. * @returns a new Mesh
  21102. */
  21103. static CreatePolyhedron(name: string, options: {
  21104. type?: number;
  21105. size?: number;
  21106. sizeX?: number;
  21107. sizeY?: number;
  21108. sizeZ?: number;
  21109. custom?: any;
  21110. faceUV?: Vector4[];
  21111. faceColors?: Color4[];
  21112. updatable?: boolean;
  21113. sideOrientation?: number;
  21114. }, scene: Scene): Mesh;
  21115. /**
  21116. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21117. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21118. * * 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`)
  21119. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21120. * * 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
  21121. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21122. * * If you create a double-sided mesh, you can choose what parts of 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
  21123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21124. * @param name defines the name of the mesh
  21125. * @param options defines the options used to create the mesh
  21126. * @param scene defines the hosting scene
  21127. * @returns a new Mesh
  21128. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21129. */
  21130. static CreateIcoSphere(name: string, options: {
  21131. radius?: number;
  21132. flat?: boolean;
  21133. subdivisions?: number;
  21134. sideOrientation?: number;
  21135. updatable?: boolean;
  21136. }, scene: Scene): Mesh;
  21137. /**
  21138. * Creates a decal mesh.
  21139. * Please consider using the same method from the MeshBuilder class instead.
  21140. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21141. * @param name defines the name of the mesh
  21142. * @param sourceMesh defines the mesh receiving the decal
  21143. * @param position sets the position of the decal in world coordinates
  21144. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21145. * @param size sets the decal scaling
  21146. * @param angle sets the angle to rotate the decal
  21147. * @returns a new Mesh
  21148. */
  21149. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21150. /**
  21151. * Prepare internal position array for software CPU skinning
  21152. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21153. */
  21154. setPositionsForCPUSkinning(): Float32Array;
  21155. /**
  21156. * Prepare internal normal array for software CPU skinning
  21157. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21158. */
  21159. setNormalsForCPUSkinning(): Float32Array;
  21160. /**
  21161. * Updates the vertex buffer by applying transformation from the bones
  21162. * @param skeleton defines the skeleton to apply to current mesh
  21163. * @returns the current mesh
  21164. */
  21165. applySkeleton(skeleton: Skeleton): Mesh;
  21166. /**
  21167. * 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
  21168. * @param meshes defines the list of meshes to scan
  21169. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21170. */
  21171. static MinMax(meshes: AbstractMesh[]): {
  21172. min: Vector3;
  21173. max: Vector3;
  21174. };
  21175. /**
  21176. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21177. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21178. * @returns a vector3
  21179. */
  21180. static Center(meshesOrMinMaxVector: {
  21181. min: Vector3;
  21182. max: Vector3;
  21183. } | AbstractMesh[]): Vector3;
  21184. /**
  21185. * Merge the array of meshes into a single mesh for performance reasons.
  21186. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21187. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21188. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21189. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21190. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21191. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21192. * @returns a new mesh
  21193. */
  21194. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21195. /** @hidden */
  21196. addInstance(instance: InstancedMesh): void;
  21197. /** @hidden */
  21198. removeInstance(instance: InstancedMesh): void;
  21199. }
  21200. }
  21201. declare module BABYLON {
  21202. /**
  21203. * Base class for the main features of a material in Babylon.js
  21204. */
  21205. export class Material implements IAnimatable {
  21206. /**
  21207. * Returns the triangle fill mode
  21208. */
  21209. static readonly TriangleFillMode: number;
  21210. /**
  21211. * Returns the wireframe mode
  21212. */
  21213. static readonly WireFrameFillMode: number;
  21214. /**
  21215. * Returns the point fill mode
  21216. */
  21217. static readonly PointFillMode: number;
  21218. /**
  21219. * Returns the point list draw mode
  21220. */
  21221. static readonly PointListDrawMode: number;
  21222. /**
  21223. * Returns the line list draw mode
  21224. */
  21225. static readonly LineListDrawMode: number;
  21226. /**
  21227. * Returns the line loop draw mode
  21228. */
  21229. static readonly LineLoopDrawMode: number;
  21230. /**
  21231. * Returns the line strip draw mode
  21232. */
  21233. static readonly LineStripDrawMode: number;
  21234. /**
  21235. * Returns the triangle strip draw mode
  21236. */
  21237. static readonly TriangleStripDrawMode: number;
  21238. /**
  21239. * Returns the triangle fan draw mode
  21240. */
  21241. static readonly TriangleFanDrawMode: number;
  21242. /**
  21243. * Stores the clock-wise side orientation
  21244. */
  21245. static readonly ClockWiseSideOrientation: number;
  21246. /**
  21247. * Stores the counter clock-wise side orientation
  21248. */
  21249. static readonly CounterClockWiseSideOrientation: number;
  21250. /**
  21251. * The dirty texture flag value
  21252. */
  21253. static readonly TextureDirtyFlag: number;
  21254. /**
  21255. * The dirty light flag value
  21256. */
  21257. static readonly LightDirtyFlag: number;
  21258. /**
  21259. * The dirty fresnel flag value
  21260. */
  21261. static readonly FresnelDirtyFlag: number;
  21262. /**
  21263. * The dirty attribute flag value
  21264. */
  21265. static readonly AttributesDirtyFlag: number;
  21266. /**
  21267. * The dirty misc flag value
  21268. */
  21269. static readonly MiscDirtyFlag: number;
  21270. /**
  21271. * The all dirty flag value
  21272. */
  21273. static readonly AllDirtyFlag: number;
  21274. /**
  21275. * The ID of the material
  21276. */
  21277. id: string;
  21278. /**
  21279. * Gets or sets the unique id of the material
  21280. */
  21281. uniqueId: number;
  21282. /**
  21283. * The name of the material
  21284. */
  21285. name: string;
  21286. /**
  21287. * Gets or sets user defined metadata
  21288. */
  21289. metadata: any;
  21290. /**
  21291. * For internal use only. Please do not use.
  21292. */
  21293. reservedDataStore: any;
  21294. /**
  21295. * Specifies if the ready state should be checked on each call
  21296. */
  21297. checkReadyOnEveryCall: boolean;
  21298. /**
  21299. * Specifies if the ready state should be checked once
  21300. */
  21301. checkReadyOnlyOnce: boolean;
  21302. /**
  21303. * The state of the material
  21304. */
  21305. state: string;
  21306. /**
  21307. * The alpha value of the material
  21308. */
  21309. protected _alpha: number;
  21310. /**
  21311. * List of inspectable custom properties (used by the Inspector)
  21312. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21313. */
  21314. inspectableCustomProperties: IInspectable[];
  21315. /**
  21316. * Sets the alpha value of the material
  21317. */
  21318. /**
  21319. * Gets the alpha value of the material
  21320. */
  21321. alpha: number;
  21322. /**
  21323. * Specifies if back face culling is enabled
  21324. */
  21325. protected _backFaceCulling: boolean;
  21326. /**
  21327. * Sets the back-face culling state
  21328. */
  21329. /**
  21330. * Gets the back-face culling state
  21331. */
  21332. backFaceCulling: boolean;
  21333. /**
  21334. * Stores the value for side orientation
  21335. */
  21336. sideOrientation: number;
  21337. /**
  21338. * Callback triggered when the material is compiled
  21339. */
  21340. onCompiled: Nullable<(effect: Effect) => void>;
  21341. /**
  21342. * Callback triggered when an error occurs
  21343. */
  21344. onError: Nullable<(effect: Effect, errors: string) => void>;
  21345. /**
  21346. * Callback triggered to get the render target textures
  21347. */
  21348. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21349. /**
  21350. * Gets a boolean indicating that current material needs to register RTT
  21351. */
  21352. readonly hasRenderTargetTextures: boolean;
  21353. /**
  21354. * Specifies if the material should be serialized
  21355. */
  21356. doNotSerialize: boolean;
  21357. /**
  21358. * @hidden
  21359. */ storeEffectOnSubMeshes: boolean;
  21360. /**
  21361. * Stores the animations for the material
  21362. */
  21363. animations: Nullable<Array<Animation>>;
  21364. /**
  21365. * An event triggered when the material is disposed
  21366. */
  21367. onDisposeObservable: Observable<Material>;
  21368. /**
  21369. * An observer which watches for dispose events
  21370. */
  21371. private _onDisposeObserver;
  21372. private _onUnBindObservable;
  21373. /**
  21374. * Called during a dispose event
  21375. */
  21376. onDispose: () => void;
  21377. private _onBindObservable;
  21378. /**
  21379. * An event triggered when the material is bound
  21380. */
  21381. readonly onBindObservable: Observable<AbstractMesh>;
  21382. /**
  21383. * An observer which watches for bind events
  21384. */
  21385. private _onBindObserver;
  21386. /**
  21387. * Called during a bind event
  21388. */
  21389. onBind: (Mesh: AbstractMesh) => void;
  21390. /**
  21391. * An event triggered when the material is unbound
  21392. */
  21393. readonly onUnBindObservable: Observable<Material>;
  21394. /**
  21395. * Stores the value of the alpha mode
  21396. */
  21397. private _alphaMode;
  21398. /**
  21399. * Sets the value of the alpha mode.
  21400. *
  21401. * | Value | Type | Description |
  21402. * | --- | --- | --- |
  21403. * | 0 | ALPHA_DISABLE | |
  21404. * | 1 | ALPHA_ADD | |
  21405. * | 2 | ALPHA_COMBINE | |
  21406. * | 3 | ALPHA_SUBTRACT | |
  21407. * | 4 | ALPHA_MULTIPLY | |
  21408. * | 5 | ALPHA_MAXIMIZED | |
  21409. * | 6 | ALPHA_ONEONE | |
  21410. * | 7 | ALPHA_PREMULTIPLIED | |
  21411. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21412. * | 9 | ALPHA_INTERPOLATE | |
  21413. * | 10 | ALPHA_SCREENMODE | |
  21414. *
  21415. */
  21416. /**
  21417. * Gets the value of the alpha mode
  21418. */
  21419. alphaMode: number;
  21420. /**
  21421. * Stores the state of the need depth pre-pass value
  21422. */
  21423. private _needDepthPrePass;
  21424. /**
  21425. * Sets the need depth pre-pass value
  21426. */
  21427. /**
  21428. * Gets the depth pre-pass value
  21429. */
  21430. needDepthPrePass: boolean;
  21431. /**
  21432. * Specifies if depth writing should be disabled
  21433. */
  21434. disableDepthWrite: boolean;
  21435. /**
  21436. * Specifies if depth writing should be forced
  21437. */
  21438. forceDepthWrite: boolean;
  21439. /**
  21440. * Specifies if there should be a separate pass for culling
  21441. */
  21442. separateCullingPass: boolean;
  21443. /**
  21444. * Stores the state specifing if fog should be enabled
  21445. */
  21446. private _fogEnabled;
  21447. /**
  21448. * Sets the state for enabling fog
  21449. */
  21450. /**
  21451. * Gets the value of the fog enabled state
  21452. */
  21453. fogEnabled: boolean;
  21454. /**
  21455. * Stores the size of points
  21456. */
  21457. pointSize: number;
  21458. /**
  21459. * Stores the z offset value
  21460. */
  21461. zOffset: number;
  21462. /**
  21463. * Gets a value specifying if wireframe mode is enabled
  21464. */
  21465. /**
  21466. * Sets the state of wireframe mode
  21467. */
  21468. wireframe: boolean;
  21469. /**
  21470. * Gets the value specifying if point clouds are enabled
  21471. */
  21472. /**
  21473. * Sets the state of point cloud mode
  21474. */
  21475. pointsCloud: boolean;
  21476. /**
  21477. * Gets the material fill mode
  21478. */
  21479. /**
  21480. * Sets the material fill mode
  21481. */
  21482. fillMode: number;
  21483. /**
  21484. * @hidden
  21485. * Stores the effects for the material
  21486. */ effect: Nullable<Effect>;
  21487. /**
  21488. * @hidden
  21489. * Specifies if the material was previously ready
  21490. */ wasPreviouslyReady: boolean;
  21491. /**
  21492. * Specifies if uniform buffers should be used
  21493. */
  21494. private _useUBO;
  21495. /**
  21496. * Stores a reference to the scene
  21497. */
  21498. private _scene;
  21499. /**
  21500. * Stores the fill mode state
  21501. */
  21502. private _fillMode;
  21503. /**
  21504. * Specifies if the depth write state should be cached
  21505. */
  21506. private _cachedDepthWriteState;
  21507. /**
  21508. * Stores the uniform buffer
  21509. */
  21510. protected _uniformBuffer: UniformBuffer;
  21511. /** @hidden */ indexInSceneMaterialArray: number;
  21512. /** @hidden */
  21513. meshMap: Nullable<{
  21514. [id: string]: AbstractMesh | undefined;
  21515. }>;
  21516. /**
  21517. * Creates a material instance
  21518. * @param name defines the name of the material
  21519. * @param scene defines the scene to reference
  21520. * @param doNotAdd specifies if the material should be added to the scene
  21521. */
  21522. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21523. /**
  21524. * Returns a string representation of the current material
  21525. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21526. * @returns a string with material information
  21527. */
  21528. toString(fullDetails?: boolean): string;
  21529. /**
  21530. * Gets the class name of the material
  21531. * @returns a string with the class name of the material
  21532. */
  21533. getClassName(): string;
  21534. /**
  21535. * Specifies if updates for the material been locked
  21536. */
  21537. readonly isFrozen: boolean;
  21538. /**
  21539. * Locks updates for the material
  21540. */
  21541. freeze(): void;
  21542. /**
  21543. * Unlocks updates for the material
  21544. */
  21545. unfreeze(): void;
  21546. /**
  21547. * Specifies if the material is ready to be used
  21548. * @param mesh defines the mesh to check
  21549. * @param useInstances specifies if instances should be used
  21550. * @returns a boolean indicating if the material is ready to be used
  21551. */
  21552. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21553. /**
  21554. * Specifies that the submesh is ready to be used
  21555. * @param mesh defines the mesh to check
  21556. * @param subMesh defines which submesh to check
  21557. * @param useInstances specifies that instances should be used
  21558. * @returns a boolean indicating that the submesh is ready or not
  21559. */
  21560. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21561. /**
  21562. * Returns the material effect
  21563. * @returns the effect associated with the material
  21564. */
  21565. getEffect(): Nullable<Effect>;
  21566. /**
  21567. * Returns the current scene
  21568. * @returns a Scene
  21569. */
  21570. getScene(): Scene;
  21571. /**
  21572. * Specifies if the material will require alpha blending
  21573. * @returns a boolean specifying if alpha blending is needed
  21574. */
  21575. needAlphaBlending(): boolean;
  21576. /**
  21577. * Specifies if the mesh will require alpha blending
  21578. * @param mesh defines the mesh to check
  21579. * @returns a boolean specifying if alpha blending is needed for the mesh
  21580. */
  21581. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21582. /**
  21583. * Specifies if this material should be rendered in alpha test mode
  21584. * @returns a boolean specifying if an alpha test is needed.
  21585. */
  21586. needAlphaTesting(): boolean;
  21587. /**
  21588. * Gets the texture used for the alpha test
  21589. * @returns the texture to use for alpha testing
  21590. */
  21591. getAlphaTestTexture(): Nullable<BaseTexture>;
  21592. /**
  21593. * Marks the material to indicate that it needs to be re-calculated
  21594. */
  21595. markDirty(): void;
  21596. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21597. /**
  21598. * Binds the material to the mesh
  21599. * @param world defines the world transformation matrix
  21600. * @param mesh defines the mesh to bind the material to
  21601. */
  21602. bind(world: Matrix, mesh?: Mesh): void;
  21603. /**
  21604. * Binds the submesh to the material
  21605. * @param world defines the world transformation matrix
  21606. * @param mesh defines the mesh containing the submesh
  21607. * @param subMesh defines the submesh to bind the material to
  21608. */
  21609. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21610. /**
  21611. * Binds the world matrix to the material
  21612. * @param world defines the world transformation matrix
  21613. */
  21614. bindOnlyWorldMatrix(world: Matrix): void;
  21615. /**
  21616. * Binds the scene's uniform buffer to the effect.
  21617. * @param effect defines the effect to bind to the scene uniform buffer
  21618. * @param sceneUbo defines the uniform buffer storing scene data
  21619. */
  21620. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21621. /**
  21622. * Binds the view matrix to the effect
  21623. * @param effect defines the effect to bind the view matrix to
  21624. */
  21625. bindView(effect: Effect): void;
  21626. /**
  21627. * Binds the view projection matrix to the effect
  21628. * @param effect defines the effect to bind the view projection matrix to
  21629. */
  21630. bindViewProjection(effect: Effect): void;
  21631. /**
  21632. * Specifies if material alpha testing should be turned on for the mesh
  21633. * @param mesh defines the mesh to check
  21634. */
  21635. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21636. /**
  21637. * Processes to execute after binding the material to a mesh
  21638. * @param mesh defines the rendered mesh
  21639. */
  21640. protected _afterBind(mesh?: Mesh): void;
  21641. /**
  21642. * Unbinds the material from the mesh
  21643. */
  21644. unbind(): void;
  21645. /**
  21646. * Gets the active textures from the material
  21647. * @returns an array of textures
  21648. */
  21649. getActiveTextures(): BaseTexture[];
  21650. /**
  21651. * Specifies if the material uses a texture
  21652. * @param texture defines the texture to check against the material
  21653. * @returns a boolean specifying if the material uses the texture
  21654. */
  21655. hasTexture(texture: BaseTexture): boolean;
  21656. /**
  21657. * Makes a duplicate of the material, and gives it a new name
  21658. * @param name defines the new name for the duplicated material
  21659. * @returns the cloned material
  21660. */
  21661. clone(name: string): Nullable<Material>;
  21662. /**
  21663. * Gets the meshes bound to the material
  21664. * @returns an array of meshes bound to the material
  21665. */
  21666. getBindedMeshes(): AbstractMesh[];
  21667. /**
  21668. * Force shader compilation
  21669. * @param mesh defines the mesh associated with this material
  21670. * @param onCompiled defines a function to execute once the material is compiled
  21671. * @param options defines the options to configure the compilation
  21672. */
  21673. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21674. clipPlane: boolean;
  21675. }>): void;
  21676. /**
  21677. * Force shader compilation
  21678. * @param mesh defines the mesh that will use this material
  21679. * @param options defines additional options for compiling the shaders
  21680. * @returns a promise that resolves when the compilation completes
  21681. */
  21682. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21683. clipPlane: boolean;
  21684. }>): Promise<void>;
  21685. private static readonly _ImageProcessingDirtyCallBack;
  21686. private static readonly _TextureDirtyCallBack;
  21687. private static readonly _FresnelDirtyCallBack;
  21688. private static readonly _MiscDirtyCallBack;
  21689. private static readonly _LightsDirtyCallBack;
  21690. private static readonly _AttributeDirtyCallBack;
  21691. private static _FresnelAndMiscDirtyCallBack;
  21692. private static _TextureAndMiscDirtyCallBack;
  21693. private static readonly _DirtyCallbackArray;
  21694. private static readonly _RunDirtyCallBacks;
  21695. /**
  21696. * Marks a define in the material to indicate that it needs to be re-computed
  21697. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21698. */
  21699. markAsDirty(flag: number): void;
  21700. /**
  21701. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21702. * @param func defines a function which checks material defines against the submeshes
  21703. */
  21704. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21705. /**
  21706. * Indicates that image processing needs to be re-calculated for all submeshes
  21707. */
  21708. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21709. /**
  21710. * Indicates that textures need to be re-calculated for all submeshes
  21711. */
  21712. protected _markAllSubMeshesAsTexturesDirty(): void;
  21713. /**
  21714. * Indicates that fresnel needs to be re-calculated for all submeshes
  21715. */
  21716. protected _markAllSubMeshesAsFresnelDirty(): void;
  21717. /**
  21718. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21719. */
  21720. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21721. /**
  21722. * Indicates that lights need to be re-calculated for all submeshes
  21723. */
  21724. protected _markAllSubMeshesAsLightsDirty(): void;
  21725. /**
  21726. * Indicates that attributes need to be re-calculated for all submeshes
  21727. */
  21728. protected _markAllSubMeshesAsAttributesDirty(): void;
  21729. /**
  21730. * Indicates that misc needs to be re-calculated for all submeshes
  21731. */
  21732. protected _markAllSubMeshesAsMiscDirty(): void;
  21733. /**
  21734. * Indicates that textures and misc need to be re-calculated for all submeshes
  21735. */
  21736. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21737. /**
  21738. * Disposes the material
  21739. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21740. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21741. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21742. */
  21743. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21744. /** @hidden */
  21745. private releaseVertexArrayObject;
  21746. /**
  21747. * Serializes this material
  21748. * @returns the serialized material object
  21749. */
  21750. serialize(): any;
  21751. /**
  21752. * Creates a material from parsed material data
  21753. * @param parsedMaterial defines parsed material data
  21754. * @param scene defines the hosting scene
  21755. * @param rootUrl defines the root URL to use to load textures
  21756. * @returns a new material
  21757. */
  21758. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21759. }
  21760. }
  21761. declare module BABYLON {
  21762. /**
  21763. * Base class for submeshes
  21764. */
  21765. export class BaseSubMesh {
  21766. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  21767. /** @hidden */ materialEffect: Nullable<Effect>;
  21768. /**
  21769. * Gets associated effect
  21770. */
  21771. readonly effect: Nullable<Effect>;
  21772. /**
  21773. * Sets associated effect (effect used to render this submesh)
  21774. * @param effect defines the effect to associate with
  21775. * @param defines defines the set of defines used to compile this effect
  21776. */
  21777. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21778. }
  21779. /**
  21780. * Defines a subdivision inside a mesh
  21781. */
  21782. export class SubMesh extends BaseSubMesh implements ICullable {
  21783. /** the material index to use */
  21784. materialIndex: number;
  21785. /** vertex index start */
  21786. verticesStart: number;
  21787. /** vertices count */
  21788. verticesCount: number;
  21789. /** index start */
  21790. indexStart: number;
  21791. /** indices count */
  21792. indexCount: number;
  21793. /** @hidden */ linesIndexCount: number;
  21794. private _mesh;
  21795. private _renderingMesh;
  21796. private _boundingInfo;
  21797. private _linesIndexBuffer;
  21798. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  21799. /** @hidden */ trianglePlanes: Plane[];
  21800. /** @hidden */ lastColliderTransformMatrix: Nullable<Matrix>;
  21801. /** @hidden */ renderId: number;
  21802. /** @hidden */ alphaIndex: number;
  21803. /** @hidden */ distanceToCamera: number;
  21804. /** @hidden */ id: number;
  21805. private _currentMaterial;
  21806. /**
  21807. * Add a new submesh to a mesh
  21808. * @param materialIndex defines the material index to use
  21809. * @param verticesStart defines vertex index start
  21810. * @param verticesCount defines vertices count
  21811. * @param indexStart defines index start
  21812. * @param indexCount defines indices count
  21813. * @param mesh defines the parent mesh
  21814. * @param renderingMesh defines an optional rendering mesh
  21815. * @param createBoundingBox defines if bounding box should be created for this submesh
  21816. * @returns the new submesh
  21817. */
  21818. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21819. /**
  21820. * Creates a new submesh
  21821. * @param materialIndex defines the material index to use
  21822. * @param verticesStart defines vertex index start
  21823. * @param verticesCount defines vertices count
  21824. * @param indexStart defines index start
  21825. * @param indexCount defines indices count
  21826. * @param mesh defines the parent mesh
  21827. * @param renderingMesh defines an optional rendering mesh
  21828. * @param createBoundingBox defines if bounding box should be created for this submesh
  21829. */
  21830. constructor(
  21831. /** the material index to use */
  21832. materialIndex: number,
  21833. /** vertex index start */
  21834. verticesStart: number,
  21835. /** vertices count */
  21836. verticesCount: number,
  21837. /** index start */
  21838. indexStart: number,
  21839. /** indices count */
  21840. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21841. /**
  21842. * Returns true if this submesh covers the entire parent mesh
  21843. * @ignorenaming
  21844. */
  21845. readonly IsGlobal: boolean;
  21846. /**
  21847. * Returns the submesh BoudingInfo object
  21848. * @returns current bounding info (or mesh's one if the submesh is global)
  21849. */
  21850. getBoundingInfo(): BoundingInfo;
  21851. /**
  21852. * Sets the submesh BoundingInfo
  21853. * @param boundingInfo defines the new bounding info to use
  21854. * @returns the SubMesh
  21855. */
  21856. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21857. /**
  21858. * Returns the mesh of the current submesh
  21859. * @return the parent mesh
  21860. */
  21861. getMesh(): AbstractMesh;
  21862. /**
  21863. * Returns the rendering mesh of the submesh
  21864. * @returns the rendering mesh (could be different from parent mesh)
  21865. */
  21866. getRenderingMesh(): Mesh;
  21867. /**
  21868. * Returns the submesh material
  21869. * @returns null or the current material
  21870. */
  21871. getMaterial(): Nullable<Material>;
  21872. /**
  21873. * Sets a new updated BoundingInfo object to the submesh
  21874. * @returns the SubMesh
  21875. */
  21876. refreshBoundingInfo(): SubMesh;
  21877. /** @hidden */ checkCollision(collider: Collider): boolean;
  21878. /**
  21879. * Updates the submesh BoundingInfo
  21880. * @param world defines the world matrix to use to update the bounding info
  21881. * @returns the submesh
  21882. */
  21883. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21884. /**
  21885. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21886. * @param frustumPlanes defines the frustum planes
  21887. * @returns true if the submesh is intersecting with the frustum
  21888. */
  21889. isInFrustum(frustumPlanes: Plane[]): boolean;
  21890. /**
  21891. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21892. * @param frustumPlanes defines the frustum planes
  21893. * @returns true if the submesh is inside the frustum
  21894. */
  21895. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21896. /**
  21897. * Renders the submesh
  21898. * @param enableAlphaMode defines if alpha needs to be used
  21899. * @returns the submesh
  21900. */
  21901. render(enableAlphaMode: boolean): SubMesh;
  21902. /**
  21903. * @hidden
  21904. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21905. /**
  21906. * Checks if the submesh intersects with a ray
  21907. * @param ray defines the ray to test
  21908. * @returns true is the passed ray intersects the submesh bounding box
  21909. */
  21910. canIntersects(ray: Ray): boolean;
  21911. /**
  21912. * Intersects current submesh with a ray
  21913. * @param ray defines the ray to test
  21914. * @param positions defines mesh's positions array
  21915. * @param indices defines mesh's indices array
  21916. * @param fastCheck defines if only bounding info should be used
  21917. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21918. * @returns intersection info or null if no intersection
  21919. */
  21920. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21921. /** @hidden */
  21922. private _intersectLines;
  21923. /** @hidden */
  21924. private _intersectTriangles;
  21925. /** @hidden */ rebuild(): void;
  21926. /**
  21927. * Creates a new submesh from the passed mesh
  21928. * @param newMesh defines the new hosting mesh
  21929. * @param newRenderingMesh defines an optional rendering mesh
  21930. * @returns the new submesh
  21931. */
  21932. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21933. /**
  21934. * Release associated resources
  21935. */
  21936. dispose(): void;
  21937. /**
  21938. * Gets the class name
  21939. * @returns the string "SubMesh".
  21940. */
  21941. getClassName(): string;
  21942. /**
  21943. * Creates a new submesh from indices data
  21944. * @param materialIndex the index of the main mesh material
  21945. * @param startIndex the index where to start the copy in the mesh indices array
  21946. * @param indexCount the number of indices to copy then from the startIndex
  21947. * @param mesh the main mesh to create the submesh from
  21948. * @param renderingMesh the optional rendering mesh
  21949. * @returns a new submesh
  21950. */
  21951. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21952. }
  21953. }
  21954. declare module BABYLON {
  21955. /**
  21956. * Class used to store geometry data (vertex buffers + index buffer)
  21957. */
  21958. export class Geometry implements IGetSetVerticesData {
  21959. /**
  21960. * Gets or sets the ID of the geometry
  21961. */
  21962. id: string;
  21963. /**
  21964. * Gets or sets the unique ID of the geometry
  21965. */
  21966. uniqueId: number;
  21967. /**
  21968. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21969. */
  21970. delayLoadState: number;
  21971. /**
  21972. * Gets the file containing the data to load when running in delay load state
  21973. */
  21974. delayLoadingFile: Nullable<string>;
  21975. /**
  21976. * Callback called when the geometry is updated
  21977. */
  21978. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21979. private _scene;
  21980. private _engine;
  21981. private _meshes;
  21982. private _totalVertices;
  21983. /** @hidden */ indices: IndicesArray;
  21984. /** @hidden */ vertexBuffers: {
  21985. [key: string]: VertexBuffer;
  21986. };
  21987. private _isDisposed;
  21988. private _extend;
  21989. private _boundingBias;
  21990. /** @hidden */ delayInfo: Array<string>;
  21991. private _indexBuffer;
  21992. private _indexBufferIsUpdatable;
  21993. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  21994. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21995. /** @hidden */ softwareSkinningFrameId: number;
  21996. private _vertexArrayObjects;
  21997. private _updatable;
  21998. /** @hidden */ positions: Nullable<Vector3[]>;
  21999. /**
  22000. * 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
  22001. */
  22002. /**
  22003. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  22004. */
  22005. boundingBias: Vector2;
  22006. /**
  22007. * Static function used to attach a new empty geometry to a mesh
  22008. * @param mesh defines the mesh to attach the geometry to
  22009. * @returns the new Geometry
  22010. */
  22011. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22012. /**
  22013. * Creates a new geometry
  22014. * @param id defines the unique ID
  22015. * @param scene defines the hosting scene
  22016. * @param vertexData defines the VertexData used to get geometry data
  22017. * @param updatable defines if geometry must be updatable (false by default)
  22018. * @param mesh defines the mesh that will be associated with the geometry
  22019. */
  22020. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22021. /**
  22022. * Gets the current extend of the geometry
  22023. */
  22024. readonly extend: {
  22025. minimum: Vector3;
  22026. maximum: Vector3;
  22027. };
  22028. /**
  22029. * Gets the hosting scene
  22030. * @returns the hosting Scene
  22031. */
  22032. getScene(): Scene;
  22033. /**
  22034. * Gets the hosting engine
  22035. * @returns the hosting Engine
  22036. */
  22037. getEngine(): Engine;
  22038. /**
  22039. * Defines if the geometry is ready to use
  22040. * @returns true if the geometry is ready to be used
  22041. */
  22042. isReady(): boolean;
  22043. /**
  22044. * Gets a value indicating that the geometry should not be serialized
  22045. */
  22046. readonly doNotSerialize: boolean;
  22047. /** @hidden */ rebuild(): void;
  22048. /**
  22049. * Affects all geometry data in one call
  22050. * @param vertexData defines the geometry data
  22051. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22052. */
  22053. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22054. /**
  22055. * Set specific vertex data
  22056. * @param kind defines the data kind (Position, normal, etc...)
  22057. * @param data defines the vertex data to use
  22058. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22059. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22060. */
  22061. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22062. /**
  22063. * Removes a specific vertex data
  22064. * @param kind defines the data kind (Position, normal, etc...)
  22065. */
  22066. removeVerticesData(kind: string): void;
  22067. /**
  22068. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22069. * @param buffer defines the vertex buffer to use
  22070. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22071. */
  22072. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22073. /**
  22074. * Update a specific vertex buffer
  22075. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22076. * It will do nothing if the buffer is not updatable
  22077. * @param kind defines the data kind (Position, normal, etc...)
  22078. * @param data defines the data to use
  22079. * @param offset defines the offset in the target buffer where to store the data
  22080. * @param useBytes set to true if the offset is in bytes
  22081. */
  22082. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22083. /**
  22084. * Update a specific vertex buffer
  22085. * This function will create a new buffer if the current one is not updatable
  22086. * @param kind defines the data kind (Position, normal, etc...)
  22087. * @param data defines the data to use
  22088. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22089. */
  22090. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22091. private _updateBoundingInfo;
  22092. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22093. /**
  22094. * Gets total number of vertices
  22095. * @returns the total number of vertices
  22096. */
  22097. getTotalVertices(): number;
  22098. /**
  22099. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22100. * @param kind defines the data kind (Position, normal, etc...)
  22101. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22102. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22103. * @returns a float array containing vertex data
  22104. */
  22105. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22106. /**
  22107. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22108. * @param kind defines the data kind (Position, normal, etc...)
  22109. * @returns true if the vertex buffer with the specified kind is updatable
  22110. */
  22111. isVertexBufferUpdatable(kind: string): boolean;
  22112. /**
  22113. * Gets a specific vertex buffer
  22114. * @param kind defines the data kind (Position, normal, etc...)
  22115. * @returns a VertexBuffer
  22116. */
  22117. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22118. /**
  22119. * Returns all vertex buffers
  22120. * @return an object holding all vertex buffers indexed by kind
  22121. */
  22122. getVertexBuffers(): Nullable<{
  22123. [key: string]: VertexBuffer;
  22124. }>;
  22125. /**
  22126. * Gets a boolean indicating if specific vertex buffer is present
  22127. * @param kind defines the data kind (Position, normal, etc...)
  22128. * @returns true if data is present
  22129. */
  22130. isVerticesDataPresent(kind: string): boolean;
  22131. /**
  22132. * Gets a list of all attached data kinds (Position, normal, etc...)
  22133. * @returns a list of string containing all kinds
  22134. */
  22135. getVerticesDataKinds(): string[];
  22136. /**
  22137. * Update index buffer
  22138. * @param indices defines the indices to store in the index buffer
  22139. * @param offset defines the offset in the target buffer where to store the data
  22140. * @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)
  22141. */
  22142. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22143. /**
  22144. * Creates a new index buffer
  22145. * @param indices defines the indices to store in the index buffer
  22146. * @param totalVertices defines the total number of vertices (could be null)
  22147. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22148. */
  22149. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22150. /**
  22151. * Return the total number of indices
  22152. * @returns the total number of indices
  22153. */
  22154. getTotalIndices(): number;
  22155. /**
  22156. * Gets the index buffer array
  22157. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22158. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22159. * @returns the index buffer array
  22160. */
  22161. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22162. /**
  22163. * Gets the index buffer
  22164. * @return the index buffer
  22165. */
  22166. getIndexBuffer(): Nullable<WebGLBuffer>;
  22167. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22168. /**
  22169. * Release the associated resources for a specific mesh
  22170. * @param mesh defines the source mesh
  22171. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22172. */
  22173. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22174. /**
  22175. * Apply current geometry to a given mesh
  22176. * @param mesh defines the mesh to apply geometry to
  22177. */
  22178. applyToMesh(mesh: Mesh): void;
  22179. private _updateExtend;
  22180. private _applyToMesh;
  22181. private notifyUpdate;
  22182. /**
  22183. * Load the geometry if it was flagged as delay loaded
  22184. * @param scene defines the hosting scene
  22185. * @param onLoaded defines a callback called when the geometry is loaded
  22186. */
  22187. load(scene: Scene, onLoaded?: () => void): void;
  22188. private _queueLoad;
  22189. /**
  22190. * Invert the geometry to move from a right handed system to a left handed one.
  22191. */
  22192. toLeftHanded(): void;
  22193. /** @hidden */ resetPointsArrayCache(): void;
  22194. /** @hidden */ generatePointsArray(): boolean;
  22195. /**
  22196. * Gets a value indicating if the geometry is disposed
  22197. * @returns true if the geometry was disposed
  22198. */
  22199. isDisposed(): boolean;
  22200. private _disposeVertexArrayObjects;
  22201. /**
  22202. * Free all associated resources
  22203. */
  22204. dispose(): void;
  22205. /**
  22206. * Clone the current geometry into a new geometry
  22207. * @param id defines the unique ID of the new geometry
  22208. * @returns a new geometry object
  22209. */
  22210. copy(id: string): Geometry;
  22211. /**
  22212. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22213. * @return a JSON representation of the current geometry data (without the vertices data)
  22214. */
  22215. serialize(): any;
  22216. private toNumberArray;
  22217. /**
  22218. * Serialize all vertices data into a JSON oject
  22219. * @returns a JSON representation of the current geometry data
  22220. */
  22221. serializeVerticeData(): any;
  22222. /**
  22223. * Extracts a clone of a mesh geometry
  22224. * @param mesh defines the source mesh
  22225. * @param id defines the unique ID of the new geometry object
  22226. * @returns the new geometry object
  22227. */
  22228. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22229. /**
  22230. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22231. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22232. * Be aware Math.random() could cause collisions, but:
  22233. * "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"
  22234. * @returns a string containing a new GUID
  22235. */
  22236. static RandomId(): string;
  22237. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22238. private static _CleanMatricesWeights;
  22239. /**
  22240. * Create a new geometry from persisted data (Using .babylon file format)
  22241. * @param parsedVertexData defines the persisted data
  22242. * @param scene defines the hosting scene
  22243. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22244. * @returns the new geometry object
  22245. */
  22246. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22247. }
  22248. }
  22249. declare module BABYLON {
  22250. /**
  22251. * Define an interface for all classes that will get and set the data on vertices
  22252. */
  22253. export interface IGetSetVerticesData {
  22254. /**
  22255. * Gets a boolean indicating if specific vertex data is present
  22256. * @param kind defines the vertex data kind to use
  22257. * @returns true is data kind is present
  22258. */
  22259. isVerticesDataPresent(kind: string): boolean;
  22260. /**
  22261. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22262. * @param kind defines the data kind (Position, normal, etc...)
  22263. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22264. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22265. * @returns a float array containing vertex data
  22266. */
  22267. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22268. /**
  22269. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22270. * @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.
  22271. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22272. * @returns the indices array or an empty array if the mesh has no geometry
  22273. */
  22274. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22275. /**
  22276. * Set specific vertex data
  22277. * @param kind defines the data kind (Position, normal, etc...)
  22278. * @param data defines the vertex data to use
  22279. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22280. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22281. */
  22282. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22283. /**
  22284. * Update a specific associated vertex buffer
  22285. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22286. * - VertexBuffer.PositionKind
  22287. * - VertexBuffer.UVKind
  22288. * - VertexBuffer.UV2Kind
  22289. * - VertexBuffer.UV3Kind
  22290. * - VertexBuffer.UV4Kind
  22291. * - VertexBuffer.UV5Kind
  22292. * - VertexBuffer.UV6Kind
  22293. * - VertexBuffer.ColorKind
  22294. * - VertexBuffer.MatricesIndicesKind
  22295. * - VertexBuffer.MatricesIndicesExtraKind
  22296. * - VertexBuffer.MatricesWeightsKind
  22297. * - VertexBuffer.MatricesWeightsExtraKind
  22298. * @param data defines the data source
  22299. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22300. * @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)
  22301. */
  22302. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22303. /**
  22304. * Creates a new index buffer
  22305. * @param indices defines the indices to store in the index buffer
  22306. * @param totalVertices defines the total number of vertices (could be null)
  22307. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22308. */
  22309. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22310. }
  22311. /**
  22312. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22313. */
  22314. export class VertexData {
  22315. /**
  22316. * Mesh side orientation : usually the external or front surface
  22317. */
  22318. static readonly FRONTSIDE: number;
  22319. /**
  22320. * Mesh side orientation : usually the internal or back surface
  22321. */
  22322. static readonly BACKSIDE: number;
  22323. /**
  22324. * Mesh side orientation : both internal and external or front and back surfaces
  22325. */
  22326. static readonly DOUBLESIDE: number;
  22327. /**
  22328. * Mesh side orientation : by default, `FRONTSIDE`
  22329. */
  22330. static readonly DEFAULTSIDE: number;
  22331. /**
  22332. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22333. */
  22334. positions: Nullable<FloatArray>;
  22335. /**
  22336. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22337. */
  22338. normals: Nullable<FloatArray>;
  22339. /**
  22340. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22341. */
  22342. tangents: Nullable<FloatArray>;
  22343. /**
  22344. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22345. */
  22346. uvs: Nullable<FloatArray>;
  22347. /**
  22348. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22349. */
  22350. uvs2: Nullable<FloatArray>;
  22351. /**
  22352. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22353. */
  22354. uvs3: Nullable<FloatArray>;
  22355. /**
  22356. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22357. */
  22358. uvs4: Nullable<FloatArray>;
  22359. /**
  22360. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22361. */
  22362. uvs5: Nullable<FloatArray>;
  22363. /**
  22364. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22365. */
  22366. uvs6: Nullable<FloatArray>;
  22367. /**
  22368. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22369. */
  22370. colors: Nullable<FloatArray>;
  22371. /**
  22372. * 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).
  22373. */
  22374. matricesIndices: Nullable<FloatArray>;
  22375. /**
  22376. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22377. */
  22378. matricesWeights: Nullable<FloatArray>;
  22379. /**
  22380. * An array extending the number of possible indices
  22381. */
  22382. matricesIndicesExtra: Nullable<FloatArray>;
  22383. /**
  22384. * An array extending the number of possible weights when the number of indices is extended
  22385. */
  22386. matricesWeightsExtra: Nullable<FloatArray>;
  22387. /**
  22388. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22389. */
  22390. indices: Nullable<IndicesArray>;
  22391. /**
  22392. * Uses the passed data array to set the set the values for the specified kind of data
  22393. * @param data a linear array of floating numbers
  22394. * @param kind the type of data that is being set, eg positions, colors etc
  22395. */
  22396. set(data: FloatArray, kind: string): void;
  22397. /**
  22398. * Associates the vertexData to the passed Mesh.
  22399. * Sets it as updatable or not (default `false`)
  22400. * @param mesh the mesh the vertexData is applied to
  22401. * @param updatable when used and having the value true allows new data to update the vertexData
  22402. * @returns the VertexData
  22403. */
  22404. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22405. /**
  22406. * Associates the vertexData to the passed Geometry.
  22407. * Sets it as updatable or not (default `false`)
  22408. * @param geometry the geometry the vertexData is applied to
  22409. * @param updatable when used and having the value true allows new data to update the vertexData
  22410. * @returns VertexData
  22411. */
  22412. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22413. /**
  22414. * Updates the associated mesh
  22415. * @param mesh the mesh to be updated
  22416. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22417. * @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
  22418. * @returns VertexData
  22419. */
  22420. updateMesh(mesh: Mesh): VertexData;
  22421. /**
  22422. * Updates the associated geometry
  22423. * @param geometry the geometry to be updated
  22424. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22425. * @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
  22426. * @returns VertexData.
  22427. */
  22428. updateGeometry(geometry: Geometry): VertexData;
  22429. private _applyTo;
  22430. private _update;
  22431. /**
  22432. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22433. * @param matrix the transforming matrix
  22434. * @returns the VertexData
  22435. */
  22436. transform(matrix: Matrix): VertexData;
  22437. /**
  22438. * Merges the passed VertexData into the current one
  22439. * @param other the VertexData to be merged into the current one
  22440. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22441. * @returns the modified VertexData
  22442. */
  22443. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22444. private _mergeElement;
  22445. private _validate;
  22446. /**
  22447. * Serializes the VertexData
  22448. * @returns a serialized object
  22449. */
  22450. serialize(): any;
  22451. /**
  22452. * Extracts the vertexData from a mesh
  22453. * @param mesh the mesh from which to extract the VertexData
  22454. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22455. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22456. * @returns the object VertexData associated to the passed mesh
  22457. */
  22458. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22459. /**
  22460. * Extracts the vertexData from the geometry
  22461. * @param geometry the geometry from which to extract the VertexData
  22462. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22463. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22464. * @returns the object VertexData associated to the passed mesh
  22465. */
  22466. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22467. private static _ExtractFrom;
  22468. /**
  22469. * Creates the VertexData for a Ribbon
  22470. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22471. * * pathArray array of paths, each of which an array of successive Vector3
  22472. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22473. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22474. * * 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
  22475. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22476. * * 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)
  22477. * * 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)
  22478. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22479. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22480. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22481. * @returns the VertexData of the ribbon
  22482. */
  22483. static CreateRibbon(options: {
  22484. pathArray: Vector3[][];
  22485. closeArray?: boolean;
  22486. closePath?: boolean;
  22487. offset?: number;
  22488. sideOrientation?: number;
  22489. frontUVs?: Vector4;
  22490. backUVs?: Vector4;
  22491. invertUV?: boolean;
  22492. uvs?: Vector2[];
  22493. colors?: Color4[];
  22494. }): VertexData;
  22495. /**
  22496. * Creates the VertexData for a box
  22497. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22498. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22499. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22500. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22501. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22502. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22503. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22504. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22505. * * 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)
  22506. * * 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)
  22507. * @returns the VertexData of the box
  22508. */
  22509. static CreateBox(options: {
  22510. size?: number;
  22511. width?: number;
  22512. height?: number;
  22513. depth?: number;
  22514. faceUV?: Vector4[];
  22515. faceColors?: Color4[];
  22516. sideOrientation?: number;
  22517. frontUVs?: Vector4;
  22518. backUVs?: Vector4;
  22519. }): VertexData;
  22520. /**
  22521. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22522. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22523. * * segments sets the number of horizontal strips optional, default 32
  22524. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22525. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22526. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22527. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22528. * * 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
  22529. * * 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
  22530. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22531. * * 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)
  22532. * * 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)
  22533. * @returns the VertexData of the ellipsoid
  22534. */
  22535. static CreateSphere(options: {
  22536. segments?: number;
  22537. diameter?: number;
  22538. diameterX?: number;
  22539. diameterY?: number;
  22540. diameterZ?: number;
  22541. arc?: number;
  22542. slice?: number;
  22543. sideOrientation?: number;
  22544. frontUVs?: Vector4;
  22545. backUVs?: Vector4;
  22546. }): VertexData;
  22547. /**
  22548. * Creates the VertexData for a cylinder, cone or prism
  22549. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22550. * * height sets the height (y direction) of the cylinder, optional, default 2
  22551. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22552. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22553. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22554. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22555. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22556. * * 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
  22557. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22558. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22559. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22560. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22561. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22562. * * 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)
  22563. * * 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)
  22564. * @returns the VertexData of the cylinder, cone or prism
  22565. */
  22566. static CreateCylinder(options: {
  22567. height?: number;
  22568. diameterTop?: number;
  22569. diameterBottom?: number;
  22570. diameter?: number;
  22571. tessellation?: number;
  22572. subdivisions?: number;
  22573. arc?: number;
  22574. faceColors?: Color4[];
  22575. faceUV?: Vector4[];
  22576. hasRings?: boolean;
  22577. enclose?: boolean;
  22578. sideOrientation?: number;
  22579. frontUVs?: Vector4;
  22580. backUVs?: Vector4;
  22581. }): VertexData;
  22582. /**
  22583. * Creates the VertexData for a torus
  22584. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22585. * * diameter the diameter of the torus, optional default 1
  22586. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22587. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22588. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22589. * * 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)
  22590. * * 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)
  22591. * @returns the VertexData of the torus
  22592. */
  22593. static CreateTorus(options: {
  22594. diameter?: number;
  22595. thickness?: number;
  22596. tessellation?: number;
  22597. sideOrientation?: number;
  22598. frontUVs?: Vector4;
  22599. backUVs?: Vector4;
  22600. }): VertexData;
  22601. /**
  22602. * Creates the VertexData of the LineSystem
  22603. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22604. * - lines an array of lines, each line being an array of successive Vector3
  22605. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22606. * @returns the VertexData of the LineSystem
  22607. */
  22608. static CreateLineSystem(options: {
  22609. lines: Vector3[][];
  22610. colors?: Nullable<Color4[][]>;
  22611. }): VertexData;
  22612. /**
  22613. * Create the VertexData for a DashedLines
  22614. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22615. * - points an array successive Vector3
  22616. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22617. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22618. * - dashNb the intended total number of dashes, optional, default 200
  22619. * @returns the VertexData for the DashedLines
  22620. */
  22621. static CreateDashedLines(options: {
  22622. points: Vector3[];
  22623. dashSize?: number;
  22624. gapSize?: number;
  22625. dashNb?: number;
  22626. }): VertexData;
  22627. /**
  22628. * Creates the VertexData for a Ground
  22629. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22630. * - width the width (x direction) of the ground, optional, default 1
  22631. * - height the height (z direction) of the ground, optional, default 1
  22632. * - subdivisions the number of subdivisions per side, optional, default 1
  22633. * @returns the VertexData of the Ground
  22634. */
  22635. static CreateGround(options: {
  22636. width?: number;
  22637. height?: number;
  22638. subdivisions?: number;
  22639. subdivisionsX?: number;
  22640. subdivisionsY?: number;
  22641. }): VertexData;
  22642. /**
  22643. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22644. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22645. * * xmin the ground minimum X coordinate, optional, default -1
  22646. * * zmin the ground minimum Z coordinate, optional, default -1
  22647. * * xmax the ground maximum X coordinate, optional, default 1
  22648. * * zmax the ground maximum Z coordinate, optional, default 1
  22649. * * 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}
  22650. * * 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}
  22651. * @returns the VertexData of the TiledGround
  22652. */
  22653. static CreateTiledGround(options: {
  22654. xmin: number;
  22655. zmin: number;
  22656. xmax: number;
  22657. zmax: number;
  22658. subdivisions?: {
  22659. w: number;
  22660. h: number;
  22661. };
  22662. precision?: {
  22663. w: number;
  22664. h: number;
  22665. };
  22666. }): VertexData;
  22667. /**
  22668. * Creates the VertexData of the Ground designed from a heightmap
  22669. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22670. * * width the width (x direction) of the ground
  22671. * * height the height (z direction) of the ground
  22672. * * subdivisions the number of subdivisions per side
  22673. * * minHeight the minimum altitude on the ground, optional, default 0
  22674. * * maxHeight the maximum altitude on the ground, optional default 1
  22675. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22676. * * buffer the array holding the image color data
  22677. * * bufferWidth the width of image
  22678. * * bufferHeight the height of image
  22679. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22680. * @returns the VertexData of the Ground designed from a heightmap
  22681. */
  22682. static CreateGroundFromHeightMap(options: {
  22683. width: number;
  22684. height: number;
  22685. subdivisions: number;
  22686. minHeight: number;
  22687. maxHeight: number;
  22688. colorFilter: Color3;
  22689. buffer: Uint8Array;
  22690. bufferWidth: number;
  22691. bufferHeight: number;
  22692. alphaFilter: number;
  22693. }): VertexData;
  22694. /**
  22695. * Creates the VertexData for a Plane
  22696. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22697. * * size sets the width and height of the plane to the value of size, optional default 1
  22698. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22699. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22700. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22701. * * 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)
  22702. * * 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)
  22703. * @returns the VertexData of the box
  22704. */
  22705. static CreatePlane(options: {
  22706. size?: number;
  22707. width?: number;
  22708. height?: number;
  22709. sideOrientation?: number;
  22710. frontUVs?: Vector4;
  22711. backUVs?: Vector4;
  22712. }): VertexData;
  22713. /**
  22714. * Creates the VertexData of the Disc or regular Polygon
  22715. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22716. * * radius the radius of the disc, optional default 0.5
  22717. * * tessellation the number of polygon sides, optional, default 64
  22718. * * 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
  22719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22720. * * 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)
  22721. * * 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)
  22722. * @returns the VertexData of the box
  22723. */
  22724. static CreateDisc(options: {
  22725. radius?: number;
  22726. tessellation?: number;
  22727. arc?: number;
  22728. sideOrientation?: number;
  22729. frontUVs?: Vector4;
  22730. backUVs?: Vector4;
  22731. }): VertexData;
  22732. /**
  22733. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22734. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22735. * @param polygon a mesh built from polygonTriangulation.build()
  22736. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22737. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22738. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22739. * @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)
  22740. * @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)
  22741. * @returns the VertexData of the Polygon
  22742. */
  22743. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22744. /**
  22745. * Creates the VertexData of the IcoSphere
  22746. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22747. * * radius the radius of the IcoSphere, optional default 1
  22748. * * radiusX allows stretching in the x direction, optional, default radius
  22749. * * radiusY allows stretching in the y direction, optional, default radius
  22750. * * radiusZ allows stretching in the z direction, optional, default radius
  22751. * * flat when true creates a flat shaded mesh, optional, default true
  22752. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22753. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22754. * * 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)
  22755. * * 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)
  22756. * @returns the VertexData of the IcoSphere
  22757. */
  22758. static CreateIcoSphere(options: {
  22759. radius?: number;
  22760. radiusX?: number;
  22761. radiusY?: number;
  22762. radiusZ?: number;
  22763. flat?: boolean;
  22764. subdivisions?: number;
  22765. sideOrientation?: number;
  22766. frontUVs?: Vector4;
  22767. backUVs?: Vector4;
  22768. }): VertexData;
  22769. /**
  22770. * Creates the VertexData for a Polyhedron
  22771. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22772. * * type provided types are:
  22773. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22774. * * 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)
  22775. * * size the size of the IcoSphere, optional default 1
  22776. * * sizeX allows stretching in the x direction, optional, default size
  22777. * * sizeY allows stretching in the y direction, optional, default size
  22778. * * sizeZ allows stretching in the z direction, optional, default size
  22779. * * 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
  22780. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22781. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22782. * * flat when true creates a flat shaded mesh, optional, default true
  22783. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22784. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22785. * * 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)
  22786. * * 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)
  22787. * @returns the VertexData of the Polyhedron
  22788. */
  22789. static CreatePolyhedron(options: {
  22790. type?: number;
  22791. size?: number;
  22792. sizeX?: number;
  22793. sizeY?: number;
  22794. sizeZ?: number;
  22795. custom?: any;
  22796. faceUV?: Vector4[];
  22797. faceColors?: Color4[];
  22798. flat?: boolean;
  22799. sideOrientation?: number;
  22800. frontUVs?: Vector4;
  22801. backUVs?: Vector4;
  22802. }): VertexData;
  22803. /**
  22804. * Creates the VertexData for a TorusKnot
  22805. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22806. * * radius the radius of the torus knot, optional, default 2
  22807. * * tube the thickness of the tube, optional, default 0.5
  22808. * * radialSegments the number of sides on each tube segments, optional, default 32
  22809. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22810. * * p the number of windings around the z axis, optional, default 2
  22811. * * q the number of windings around the x axis, optional, default 3
  22812. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22813. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22814. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22815. * @returns the VertexData of the Torus Knot
  22816. */
  22817. static CreateTorusKnot(options: {
  22818. radius?: number;
  22819. tube?: number;
  22820. radialSegments?: number;
  22821. tubularSegments?: number;
  22822. p?: number;
  22823. q?: number;
  22824. sideOrientation?: number;
  22825. frontUVs?: Vector4;
  22826. backUVs?: Vector4;
  22827. }): VertexData;
  22828. /**
  22829. * Compute normals for given positions and indices
  22830. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22831. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22832. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22833. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22834. * * facetNormals : optional array of facet normals (vector3)
  22835. * * facetPositions : optional array of facet positions (vector3)
  22836. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22837. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22838. * * bInfo : optional bounding info, required for facetPartitioning computation
  22839. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22840. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22841. * * useRightHandedSystem: optional boolean to for right handed system computation
  22842. * * depthSort : optional boolean to enable the facet depth sort computation
  22843. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22844. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22845. */
  22846. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22847. facetNormals?: any;
  22848. facetPositions?: any;
  22849. facetPartitioning?: any;
  22850. ratio?: number;
  22851. bInfo?: any;
  22852. bbSize?: Vector3;
  22853. subDiv?: any;
  22854. useRightHandedSystem?: boolean;
  22855. depthSort?: boolean;
  22856. distanceTo?: Vector3;
  22857. depthSortedFacets?: any;
  22858. }): void;
  22859. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22860. /**
  22861. * Applies VertexData created from the imported parameters to the geometry
  22862. * @param parsedVertexData the parsed data from an imported file
  22863. * @param geometry the geometry to apply the VertexData to
  22864. */
  22865. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22866. }
  22867. }
  22868. declare module BABYLON {
  22869. /**
  22870. * Class containing static functions to help procedurally build meshes
  22871. */
  22872. export class DiscBuilder {
  22873. /**
  22874. * Creates a plane polygonal mesh. By default, this is a disc
  22875. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22876. * * 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
  22877. * * 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
  22878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22879. * * If you create a double-sided mesh, you can choose what parts of 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
  22880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22881. * @param name defines the name of the mesh
  22882. * @param options defines the options used to create the mesh
  22883. * @param scene defines the hosting scene
  22884. * @returns the plane polygonal mesh
  22885. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22886. */
  22887. static CreateDisc(name: string, options: {
  22888. radius?: number;
  22889. tessellation?: number;
  22890. arc?: number;
  22891. updatable?: boolean;
  22892. sideOrientation?: number;
  22893. frontUVs?: Vector4;
  22894. backUVs?: Vector4;
  22895. }, scene?: Nullable<Scene>): Mesh;
  22896. }
  22897. }
  22898. declare module BABYLON {
  22899. /**
  22900. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  22901. *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.
  22902. * The SPS is also a particle system. It provides some methods to manage the particles.
  22903. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  22904. *
  22905. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  22906. */
  22907. export class SolidParticleSystem implements IDisposable {
  22908. /**
  22909. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  22910. * Example : var p = SPS.particles[i];
  22911. */
  22912. particles: SolidParticle[];
  22913. /**
  22914. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  22915. */
  22916. nbParticles: number;
  22917. /**
  22918. * If the particles must ever face the camera (default false). Useful for planar particles.
  22919. */
  22920. billboard: boolean;
  22921. /**
  22922. * Recompute normals when adding a shape
  22923. */
  22924. recomputeNormals: boolean;
  22925. /**
  22926. * This a counter ofr your own usage. It's not set by any SPS functions.
  22927. */
  22928. counter: number;
  22929. /**
  22930. * The SPS name. This name is also given to the underlying mesh.
  22931. */
  22932. name: string;
  22933. /**
  22934. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  22935. */
  22936. mesh: Mesh;
  22937. /**
  22938. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  22939. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  22940. */
  22941. vars: any;
  22942. /**
  22943. * This array is populated when the SPS is set as 'pickable'.
  22944. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  22945. * Each element of this array is an object `{idx: int, faceId: int}`.
  22946. * `idx` is the picked particle index in the `SPS.particles` array
  22947. * `faceId` is the picked face index counted within this particle.
  22948. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  22949. */
  22950. pickedParticles: {
  22951. idx: number;
  22952. faceId: number;
  22953. }[];
  22954. /**
  22955. * This array is populated when `enableDepthSort` is set to true.
  22956. * Each element of this array is an instance of the class DepthSortedParticle.
  22957. */
  22958. depthSortedParticles: DepthSortedParticle[];
  22959. /**
  22960. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  22961. * @hidden
  22962. */ bSphereOnly: boolean;
  22963. /**
  22964. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  22965. * @hidden
  22966. */ bSphereRadiusFactor: number;
  22967. private _scene;
  22968. private _positions;
  22969. private _indices;
  22970. private _normals;
  22971. private _colors;
  22972. private _uvs;
  22973. private _indices32;
  22974. private _positions32;
  22975. private _normals32;
  22976. private _fixedNormal32;
  22977. private _colors32;
  22978. private _uvs32;
  22979. private _index;
  22980. private _updatable;
  22981. private _pickable;
  22982. private _isVisibilityBoxLocked;
  22983. private _alwaysVisible;
  22984. private _depthSort;
  22985. private _shapeCounter;
  22986. private _copy;
  22987. private _color;
  22988. private _computeParticleColor;
  22989. private _computeParticleTexture;
  22990. private _computeParticleRotation;
  22991. private _computeParticleVertex;
  22992. private _computeBoundingBox;
  22993. private _depthSortParticles;
  22994. private _camera;
  22995. private _mustUnrotateFixedNormals;
  22996. private _particlesIntersect;
  22997. private _needs32Bits;
  22998. /**
  22999. * Creates a SPS (Solid Particle System) object.
  23000. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23001. * @param scene (Scene) is the scene in which the SPS is added.
  23002. * @param options defines the options of the sps e.g.
  23003. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23004. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23005. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23006. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23007. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23008. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23009. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23010. */
  23011. constructor(name: string, scene: Scene, options?: {
  23012. updatable?: boolean;
  23013. isPickable?: boolean;
  23014. enableDepthSort?: boolean;
  23015. particleIntersection?: boolean;
  23016. boundingSphereOnly?: boolean;
  23017. bSphereRadiusFactor?: number;
  23018. });
  23019. /**
  23020. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23021. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23022. * @returns the created mesh
  23023. */
  23024. buildMesh(): Mesh;
  23025. /**
  23026. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23027. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23028. * Thus the particles generated from `digest()` have their property `position` set yet.
  23029. * @param mesh ( Mesh ) is the mesh to be digested
  23030. * @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
  23031. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23032. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23033. * @returns the current SPS
  23034. */
  23035. digest(mesh: Mesh, options?: {
  23036. facetNb?: number;
  23037. number?: number;
  23038. delta?: number;
  23039. }): SolidParticleSystem;
  23040. private _unrotateFixedNormals;
  23041. private _resetCopy;
  23042. private _meshBuilder;
  23043. private _posToShape;
  23044. private _uvsToShapeUV;
  23045. private _addParticle;
  23046. /**
  23047. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23048. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23049. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23050. * @param nb (positive integer) the number of particles to be created from this model
  23051. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23052. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23053. * @returns the number of shapes in the system
  23054. */
  23055. addShape(mesh: Mesh, nb: number, options?: {
  23056. positionFunction?: any;
  23057. vertexFunction?: any;
  23058. }): number;
  23059. private _rebuildParticle;
  23060. /**
  23061. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23062. * @returns the SPS.
  23063. */
  23064. rebuildMesh(): SolidParticleSystem;
  23065. /**
  23066. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23067. * This method calls `updateParticle()` for each particle of the SPS.
  23068. * For an animated SPS, it is usually called within the render loop.
  23069. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23070. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23071. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23072. * @returns the SPS.
  23073. */
  23074. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23075. /**
  23076. * Disposes the SPS.
  23077. */
  23078. dispose(): void;
  23079. /**
  23080. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23081. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23082. * @returns the SPS.
  23083. */
  23084. refreshVisibleSize(): SolidParticleSystem;
  23085. /**
  23086. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23087. * @param size the size (float) of the visibility box
  23088. * note : this doesn't lock the SPS mesh bounding box.
  23089. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23090. */
  23091. setVisibilityBox(size: number): void;
  23092. /**
  23093. * Gets whether the SPS as always visible or not
  23094. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23095. */
  23096. /**
  23097. * Sets the SPS as always visible or not
  23098. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23099. */
  23100. isAlwaysVisible: boolean;
  23101. /**
  23102. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23103. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23104. */
  23105. /**
  23106. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23107. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23108. */
  23109. isVisibilityBoxLocked: boolean;
  23110. /**
  23111. * Tells to `setParticles()` to compute the particle rotations or not.
  23112. * Default value : true. The SPS is faster when it's set to false.
  23113. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23114. */
  23115. /**
  23116. * Gets if `setParticles()` computes the particle rotations or not.
  23117. * Default value : true. The SPS is faster when it's set to false.
  23118. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23119. */
  23120. computeParticleRotation: boolean;
  23121. /**
  23122. * Tells to `setParticles()` to compute the particle colors or not.
  23123. * Default value : true. The SPS is faster when it's set to false.
  23124. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23125. */
  23126. /**
  23127. * Gets if `setParticles()` computes the particle colors or not.
  23128. * Default value : true. The SPS is faster when it's set to false.
  23129. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23130. */
  23131. computeParticleColor: boolean;
  23132. /**
  23133. * Gets if `setParticles()` computes the particle textures or not.
  23134. * Default value : true. The SPS is faster when it's set to false.
  23135. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23136. */
  23137. computeParticleTexture: boolean;
  23138. /**
  23139. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23140. * Default value : false. The SPS is faster when it's set to false.
  23141. * Note : the particle custom vertex positions aren't stored values.
  23142. */
  23143. /**
  23144. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23145. * Default value : false. The SPS is faster when it's set to false.
  23146. * Note : the particle custom vertex positions aren't stored values.
  23147. */
  23148. computeParticleVertex: boolean;
  23149. /**
  23150. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23151. */
  23152. /**
  23153. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23154. */
  23155. computeBoundingBox: boolean;
  23156. /**
  23157. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23158. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23159. * Default : `true`
  23160. */
  23161. /**
  23162. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23163. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23164. * Default : `true`
  23165. */
  23166. depthSortParticles: boolean;
  23167. /**
  23168. * This function does nothing. It may be overwritten to set all the particle first values.
  23169. * The SPS doesn't call this function, you may have to call it by your own.
  23170. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23171. */
  23172. initParticles(): void;
  23173. /**
  23174. * This function does nothing. It may be overwritten to recycle a particle.
  23175. * The SPS doesn't call this function, you may have to call it by your own.
  23176. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23177. * @param particle The particle to recycle
  23178. * @returns the recycled particle
  23179. */
  23180. recycleParticle(particle: SolidParticle): SolidParticle;
  23181. /**
  23182. * Updates a particle : this function should be overwritten by the user.
  23183. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23184. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23185. * @example : just set a particle position or velocity and recycle conditions
  23186. * @param particle The particle to update
  23187. * @returns the updated particle
  23188. */
  23189. updateParticle(particle: SolidParticle): SolidParticle;
  23190. /**
  23191. * Updates a vertex of a particle : it can be overwritten by the user.
  23192. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23193. * @param particle the current particle
  23194. * @param vertex the current index of the current particle
  23195. * @param pt the index of the current vertex in the particle shape
  23196. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23197. * @example : just set a vertex particle position
  23198. * @returns the updated vertex
  23199. */
  23200. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23201. /**
  23202. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23203. * This does nothing and may be overwritten by the user.
  23204. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23205. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23206. * @param update the boolean update value actually passed to setParticles()
  23207. */
  23208. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23209. /**
  23210. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23211. * This will be passed three parameters.
  23212. * This does nothing and may be overwritten by the user.
  23213. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23214. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23215. * @param update the boolean update value actually passed to setParticles()
  23216. */
  23217. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23218. }
  23219. }
  23220. declare module BABYLON {
  23221. /**
  23222. * Represents one particle of a solid particle system.
  23223. */
  23224. export class SolidParticle {
  23225. /**
  23226. * particle global index
  23227. */
  23228. idx: number;
  23229. /**
  23230. * The color of the particle
  23231. */
  23232. color: Nullable<Color4>;
  23233. /**
  23234. * The world space position of the particle.
  23235. */
  23236. position: Vector3;
  23237. /**
  23238. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23239. */
  23240. rotation: Vector3;
  23241. /**
  23242. * The world space rotation quaternion of the particle.
  23243. */
  23244. rotationQuaternion: Nullable<Quaternion>;
  23245. /**
  23246. * The scaling of the particle.
  23247. */
  23248. scaling: Vector3;
  23249. /**
  23250. * The uvs of the particle.
  23251. */
  23252. uvs: Vector4;
  23253. /**
  23254. * The current speed of the particle.
  23255. */
  23256. velocity: Vector3;
  23257. /**
  23258. * The pivot point in the particle local space.
  23259. */
  23260. pivot: Vector3;
  23261. /**
  23262. * Must the particle be translated from its pivot point in its local space ?
  23263. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23264. * Default : false
  23265. */
  23266. translateFromPivot: boolean;
  23267. /**
  23268. * Is the particle active or not ?
  23269. */
  23270. alive: boolean;
  23271. /**
  23272. * Is the particle visible or not ?
  23273. */
  23274. isVisible: boolean;
  23275. /**
  23276. * Index of this particle in the global "positions" array (Internal use)
  23277. * @hidden
  23278. */ pos: number;
  23279. /**
  23280. * @hidden Index of this particle in the global "indices" array (Internal use)
  23281. */ ind: number;
  23282. /**
  23283. * @hidden ModelShape of this particle (Internal use)
  23284. */ model: ModelShape;
  23285. /**
  23286. * ModelShape id of this particle
  23287. */
  23288. shapeId: number;
  23289. /**
  23290. * Index of the particle in its shape id (Internal use)
  23291. */
  23292. idxInShape: number;
  23293. /**
  23294. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23295. */ modelBoundingInfo: BoundingInfo;
  23296. /**
  23297. * @hidden Particle BoundingInfo object (Internal use)
  23298. */ boundingInfo: BoundingInfo;
  23299. /**
  23300. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23301. */ sps: SolidParticleSystem;
  23302. /**
  23303. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23304. */ stillInvisible: boolean;
  23305. /**
  23306. * @hidden Last computed particle rotation matrix
  23307. */ rotationMatrix: number[];
  23308. /**
  23309. * Parent particle Id, if any.
  23310. * Default null.
  23311. */
  23312. parentId: Nullable<number>;
  23313. /**
  23314. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23315. * The possible values are :
  23316. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23317. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23318. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23319. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23320. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23321. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23322. * */
  23323. cullingStrategy: number;
  23324. /**
  23325. * @hidden Internal global position in the SPS.
  23326. */ globalPosition: Vector3;
  23327. /**
  23328. * Creates a Solid Particle object.
  23329. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23330. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23331. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23332. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23333. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23334. * @param shapeId (integer) is the model shape identifier in the SPS.
  23335. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23336. * @param sps defines the sps it is associated to
  23337. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23338. */
  23339. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23340. /**
  23341. * Legacy support, changed scale to scaling
  23342. */
  23343. /**
  23344. * Legacy support, changed scale to scaling
  23345. */
  23346. scale: Vector3;
  23347. /**
  23348. * Legacy support, changed quaternion to rotationQuaternion
  23349. */
  23350. /**
  23351. * Legacy support, changed quaternion to rotationQuaternion
  23352. */
  23353. quaternion: Nullable<Quaternion>;
  23354. /**
  23355. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23356. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23357. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23358. * @returns true if it intersects
  23359. */
  23360. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23361. /**
  23362. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23363. * A particle is in the frustum if its bounding box intersects the frustum
  23364. * @param frustumPlanes defines the frustum to test
  23365. * @returns true if the particle is in the frustum planes
  23366. */
  23367. isInFrustum(frustumPlanes: Plane[]): boolean;
  23368. /**
  23369. * get the rotation matrix of the particle
  23370. * @hidden
  23371. */
  23372. getRotationMatrix(m: Matrix): void;
  23373. }
  23374. /**
  23375. * Represents the shape of the model used by one particle of a solid particle system.
  23376. * SPS internal tool, don't use it manually.
  23377. */
  23378. export class ModelShape {
  23379. /**
  23380. * The shape id
  23381. * @hidden
  23382. */
  23383. shapeID: number;
  23384. /**
  23385. * flat array of model positions (internal use)
  23386. * @hidden
  23387. */ shape: Vector3[];
  23388. /**
  23389. * flat array of model UVs (internal use)
  23390. * @hidden
  23391. */ shapeUV: number[];
  23392. /**
  23393. * length of the shape in the model indices array (internal use)
  23394. * @hidden
  23395. */ indicesLength: number;
  23396. /**
  23397. * Custom position function (internal use)
  23398. * @hidden
  23399. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23400. /**
  23401. * Custom vertex function (internal use)
  23402. * @hidden
  23403. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23404. /**
  23405. * 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.
  23406. * SPS internal tool, don't use it manually.
  23407. * @hidden
  23408. */
  23409. 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>);
  23410. }
  23411. /**
  23412. * Represents a Depth Sorted Particle in the solid particle system.
  23413. */
  23414. export class DepthSortedParticle {
  23415. /**
  23416. * Index of the particle in the "indices" array
  23417. */
  23418. ind: number;
  23419. /**
  23420. * Length of the particle shape in the "indices" array
  23421. */
  23422. indicesLength: number;
  23423. /**
  23424. * Squared distance from the particle to the camera
  23425. */
  23426. sqDistance: number;
  23427. }
  23428. }
  23429. declare module BABYLON {
  23430. /**
  23431. * Class used to store all common mesh properties
  23432. */
  23433. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23434. /** No occlusion */
  23435. static OCCLUSION_TYPE_NONE: number;
  23436. /** Occlusion set to optimisitic */
  23437. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23438. /** Occlusion set to strict */
  23439. static OCCLUSION_TYPE_STRICT: number;
  23440. /** Use an accurante occlusion algorithm */
  23441. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23442. /** Use a conservative occlusion algorithm */
  23443. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23444. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23445. * Test order :
  23446. * Is the bounding sphere outside the frustum ?
  23447. * If not, are the bounding box vertices outside the frustum ?
  23448. * It not, then the cullable object is in the frustum.
  23449. */
  23450. static readonly CULLINGSTRATEGY_STANDARD: number;
  23451. /** Culling strategy : Bounding Sphere Only.
  23452. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23453. * It's also less accurate than the standard because some not visible objects can still be selected.
  23454. * Test : is the bounding sphere outside the frustum ?
  23455. * If not, then the cullable object is in the frustum.
  23456. */
  23457. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23458. /** Culling strategy : Optimistic Inclusion.
  23459. * This in an inclusion test first, then the standard exclusion test.
  23460. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23461. * 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.
  23462. * Anyway, it's as accurate as the standard strategy.
  23463. * Test :
  23464. * Is the cullable object bounding sphere center in the frustum ?
  23465. * If not, apply the default culling strategy.
  23466. */
  23467. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23468. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23469. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23470. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23471. * 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.
  23472. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23473. * Test :
  23474. * Is the cullable object bounding sphere center in the frustum ?
  23475. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23476. */
  23477. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23478. /**
  23479. * No billboard
  23480. */
  23481. static readonly BILLBOARDMODE_NONE: number;
  23482. /** Billboard on X axis */
  23483. static readonly BILLBOARDMODE_X: number;
  23484. /** Billboard on Y axis */
  23485. static readonly BILLBOARDMODE_Y: number;
  23486. /** Billboard on Z axis */
  23487. static readonly BILLBOARDMODE_Z: number;
  23488. /** Billboard on all axes */
  23489. static readonly BILLBOARDMODE_ALL: number;
  23490. private _facetData;
  23491. /**
  23492. * The culling strategy to use to check whether the mesh must be rendered or not.
  23493. * This value can be changed at any time and will be used on the next render mesh selection.
  23494. * The possible values are :
  23495. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23496. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23497. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23498. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23499. * Please read each static variable documentation to get details about the culling process.
  23500. * */
  23501. cullingStrategy: number;
  23502. /**
  23503. * Gets the number of facets in the mesh
  23504. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23505. */
  23506. readonly facetNb: number;
  23507. /**
  23508. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23509. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23510. */
  23511. partitioningSubdivisions: number;
  23512. /**
  23513. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23514. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23515. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23516. */
  23517. partitioningBBoxRatio: number;
  23518. /**
  23519. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23520. * Works only for updatable meshes.
  23521. * Doesn't work with multi-materials
  23522. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23523. */
  23524. mustDepthSortFacets: boolean;
  23525. /**
  23526. * The location (Vector3) where the facet depth sort must be computed from.
  23527. * By default, the active camera position.
  23528. * Used only when facet depth sort is enabled
  23529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23530. */
  23531. facetDepthSortFrom: Vector3;
  23532. /**
  23533. * gets a boolean indicating if facetData is enabled
  23534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23535. */
  23536. readonly isFacetDataEnabled: boolean;
  23537. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  23538. /**
  23539. * An event triggered when this mesh collides with another one
  23540. */
  23541. onCollideObservable: Observable<AbstractMesh>;
  23542. private _onCollideObserver;
  23543. /** Set a function to call when this mesh collides with another one */
  23544. onCollide: () => void;
  23545. /**
  23546. * An event triggered when the collision's position changes
  23547. */
  23548. onCollisionPositionChangeObservable: Observable<Vector3>;
  23549. private _onCollisionPositionChangeObserver;
  23550. /** Set a function to call when the collision's position changes */
  23551. onCollisionPositionChange: () => void;
  23552. /**
  23553. * An event triggered when material is changed
  23554. */
  23555. onMaterialChangedObservable: Observable<AbstractMesh>;
  23556. /**
  23557. * Gets or sets the orientation for POV movement & rotation
  23558. */
  23559. definedFacingForward: boolean;
  23560. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  23561. private _visibility;
  23562. /** @hidden */ isActive: boolean;
  23563. /** @hidden */ renderingGroup: Nullable<RenderingGroup>;
  23564. /**
  23565. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23566. */
  23567. /**
  23568. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23569. */
  23570. visibility: number;
  23571. /** Gets or sets the alpha index used to sort transparent meshes
  23572. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23573. */
  23574. alphaIndex: number;
  23575. /**
  23576. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23577. */
  23578. isVisible: boolean;
  23579. /**
  23580. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23581. */
  23582. isPickable: boolean;
  23583. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23584. showSubMeshesBoundingBox: boolean;
  23585. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23586. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23587. */
  23588. isBlocker: boolean;
  23589. /**
  23590. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23591. */
  23592. enablePointerMoveEvents: boolean;
  23593. /**
  23594. * Specifies the rendering group id for this mesh (0 by default)
  23595. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23596. */
  23597. renderingGroupId: number;
  23598. private _material;
  23599. /** Gets or sets current material */
  23600. material: Nullable<Material>;
  23601. private _receiveShadows;
  23602. /**
  23603. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23604. * @see http://doc.babylonjs.com/babylon101/shadows
  23605. */
  23606. receiveShadows: boolean;
  23607. /** Defines color to use when rendering outline */
  23608. outlineColor: Color3;
  23609. /** Define width to use when rendering outline */
  23610. outlineWidth: number;
  23611. /** Defines color to use when rendering overlay */
  23612. overlayColor: Color3;
  23613. /** Defines alpha to use when rendering overlay */
  23614. overlayAlpha: number;
  23615. private _hasVertexAlpha;
  23616. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23617. hasVertexAlpha: boolean;
  23618. private _useVertexColors;
  23619. /** 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) */
  23620. useVertexColors: boolean;
  23621. private _computeBonesUsingShaders;
  23622. /**
  23623. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23624. */
  23625. computeBonesUsingShaders: boolean;
  23626. private _numBoneInfluencers;
  23627. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23628. numBoneInfluencers: number;
  23629. private _applyFog;
  23630. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23631. applyFog: boolean;
  23632. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23633. useOctreeForRenderingSelection: boolean;
  23634. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23635. useOctreeForPicking: boolean;
  23636. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23637. useOctreeForCollisions: boolean;
  23638. private _layerMask;
  23639. /**
  23640. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23641. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23642. */
  23643. layerMask: number;
  23644. /**
  23645. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23646. */
  23647. alwaysSelectAsActiveMesh: boolean;
  23648. /**
  23649. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  23650. */
  23651. doNotSyncBoundingInfo: boolean;
  23652. /**
  23653. * Gets or sets the current action manager
  23654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23655. */
  23656. actionManager: Nullable<AbstractActionManager>;
  23657. private _checkCollisions;
  23658. private _collisionMask;
  23659. private _collisionGroup;
  23660. /**
  23661. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23662. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23663. */
  23664. ellipsoid: Vector3;
  23665. /**
  23666. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23667. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23668. */
  23669. ellipsoidOffset: Vector3;
  23670. private _collider;
  23671. private _oldPositionForCollisions;
  23672. private _diffPositionForCollisions;
  23673. /**
  23674. * Gets or sets a collision mask used to mask collisions (default is -1).
  23675. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23676. */
  23677. collisionMask: number;
  23678. /**
  23679. * Gets or sets the current collision group mask (-1 by default).
  23680. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23681. */
  23682. collisionGroup: number;
  23683. /**
  23684. * Defines edge width used when edgesRenderer is enabled
  23685. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23686. */
  23687. edgesWidth: number;
  23688. /**
  23689. * Defines edge color used when edgesRenderer is enabled
  23690. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23691. */
  23692. edgesColor: Color4;
  23693. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  23694. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  23695. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  23696. /** @hidden */ renderId: number;
  23697. /**
  23698. * Gets or sets the list of subMeshes
  23699. * @see http://doc.babylonjs.com/how_to/multi_materials
  23700. */
  23701. subMeshes: SubMesh[];
  23702. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  23703. /** @hidden */ unIndexed: boolean;
  23704. /** @hidden */ lightSources: Light[];
  23705. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23706. /** @hidden */ waitingActions: Nullable<any>;
  23707. /** @hidden */ waitingFreezeWorldMatrix: Nullable<boolean>;
  23708. private _skeleton;
  23709. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  23710. /**
  23711. * Gets or sets a skeleton to apply skining transformations
  23712. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23713. */
  23714. skeleton: Nullable<Skeleton>;
  23715. /**
  23716. * An event triggered when the mesh is rebuilt.
  23717. */
  23718. onRebuildObservable: Observable<AbstractMesh>;
  23719. /**
  23720. * Creates a new AbstractMesh
  23721. * @param name defines the name of the mesh
  23722. * @param scene defines the hosting scene
  23723. */
  23724. constructor(name: string, scene?: Nullable<Scene>);
  23725. /**
  23726. * Returns the string "AbstractMesh"
  23727. * @returns "AbstractMesh"
  23728. */
  23729. getClassName(): string;
  23730. /**
  23731. * Gets a string representation of the current mesh
  23732. * @param fullDetails defines a boolean indicating if full details must be included
  23733. * @returns a string representation of the current mesh
  23734. */
  23735. toString(fullDetails?: boolean): string;
  23736. /**
  23737. * @hidden
  23738. */
  23739. protected _getEffectiveParent(): Nullable<Node>;
  23740. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  23741. /** @hidden */ rebuild(): void;
  23742. /** @hidden */ resyncLightSources(): void;
  23743. /** @hidden */ resyncLighSource(light: Light): void;
  23744. /** @hidden */ unBindEffect(): void;
  23745. /** @hidden */ removeLightSource(light: Light): void;
  23746. private _markSubMeshesAsDirty;
  23747. /** @hidden */ markSubMeshesAsLightDirty(): void;
  23748. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  23749. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  23750. /**
  23751. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23752. */
  23753. scaling: Vector3;
  23754. /**
  23755. * Returns true if the mesh is blocked. Implemented by child classes
  23756. */
  23757. readonly isBlocked: boolean;
  23758. /**
  23759. * Returns the mesh itself by default. Implemented by child classes
  23760. * @param camera defines the camera to use to pick the right LOD level
  23761. * @returns the currentAbstractMesh
  23762. */
  23763. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23764. /**
  23765. * Returns 0 by default. Implemented by child classes
  23766. * @returns an integer
  23767. */
  23768. getTotalVertices(): number;
  23769. /**
  23770. * Returns a positive integer : the total number of indices in this mesh geometry.
  23771. * @returns the numner of indices or zero if the mesh has no geometry.
  23772. */
  23773. getTotalIndices(): number;
  23774. /**
  23775. * Returns null by default. Implemented by child classes
  23776. * @returns null
  23777. */
  23778. getIndices(): Nullable<IndicesArray>;
  23779. /**
  23780. * Returns the array of the requested vertex data kind. Implemented by child classes
  23781. * @param kind defines the vertex data kind to use
  23782. * @returns null
  23783. */
  23784. getVerticesData(kind: string): Nullable<FloatArray>;
  23785. /**
  23786. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23787. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23788. * Note that a new underlying VertexBuffer object is created each call.
  23789. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23790. * @param kind defines vertex data kind:
  23791. * * VertexBuffer.PositionKind
  23792. * * VertexBuffer.UVKind
  23793. * * VertexBuffer.UV2Kind
  23794. * * VertexBuffer.UV3Kind
  23795. * * VertexBuffer.UV4Kind
  23796. * * VertexBuffer.UV5Kind
  23797. * * VertexBuffer.UV6Kind
  23798. * * VertexBuffer.ColorKind
  23799. * * VertexBuffer.MatricesIndicesKind
  23800. * * VertexBuffer.MatricesIndicesExtraKind
  23801. * * VertexBuffer.MatricesWeightsKind
  23802. * * VertexBuffer.MatricesWeightsExtraKind
  23803. * @param data defines the data source
  23804. * @param updatable defines if the data must be flagged as updatable (or static)
  23805. * @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
  23806. * @returns the current mesh
  23807. */
  23808. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23809. /**
  23810. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23811. * If the mesh has no geometry, it is simply returned as it is.
  23812. * @param kind defines vertex data kind:
  23813. * * VertexBuffer.PositionKind
  23814. * * VertexBuffer.UVKind
  23815. * * VertexBuffer.UV2Kind
  23816. * * VertexBuffer.UV3Kind
  23817. * * VertexBuffer.UV4Kind
  23818. * * VertexBuffer.UV5Kind
  23819. * * VertexBuffer.UV6Kind
  23820. * * VertexBuffer.ColorKind
  23821. * * VertexBuffer.MatricesIndicesKind
  23822. * * VertexBuffer.MatricesIndicesExtraKind
  23823. * * VertexBuffer.MatricesWeightsKind
  23824. * * VertexBuffer.MatricesWeightsExtraKind
  23825. * @param data defines the data source
  23826. * @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
  23827. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23828. * @returns the current mesh
  23829. */
  23830. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23831. /**
  23832. * Sets the mesh indices,
  23833. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23834. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23835. * @param totalVertices Defines the total number of vertices
  23836. * @returns the current mesh
  23837. */
  23838. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23839. /**
  23840. * Gets a boolean indicating if specific vertex data is present
  23841. * @param kind defines the vertex data kind to use
  23842. * @returns true is data kind is present
  23843. */
  23844. isVerticesDataPresent(kind: string): boolean;
  23845. /**
  23846. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23847. * @returns a BoundingInfo
  23848. */
  23849. getBoundingInfo(): BoundingInfo;
  23850. /**
  23851. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23852. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  23853. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  23854. * @returns the current mesh
  23855. */
  23856. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  23857. /**
  23858. * Overwrite the current bounding info
  23859. * @param boundingInfo defines the new bounding info
  23860. * @returns the current mesh
  23861. */
  23862. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23863. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23864. readonly useBones: boolean;
  23865. /** @hidden */ preActivate(): void;
  23866. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  23867. /** @hidden */ activate(renderId: number): boolean;
  23868. /** @hidden */ freeze(): void;
  23869. /** @hidden */ unFreeze(): void;
  23870. /**
  23871. * Gets the current world matrix
  23872. * @returns a Matrix
  23873. */
  23874. getWorldMatrix(): Matrix;
  23875. /** @hidden */ getWorldMatrixDeterminant(): number;
  23876. /**
  23877. * Perform relative position change from the point of view of behind the front of the mesh.
  23878. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23879. * Supports definition of mesh facing forward or backward
  23880. * @param amountRight defines the distance on the right axis
  23881. * @param amountUp defines the distance on the up axis
  23882. * @param amountForward defines the distance on the forward axis
  23883. * @returns the current mesh
  23884. */
  23885. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23886. /**
  23887. * Calculate relative position change from the point of view of behind the front of the mesh.
  23888. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23889. * Supports definition of mesh facing forward or backward
  23890. * @param amountRight defines the distance on the right axis
  23891. * @param amountUp defines the distance on the up axis
  23892. * @param amountForward defines the distance on the forward axis
  23893. * @returns the new displacement vector
  23894. */
  23895. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23896. /**
  23897. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23898. * Supports definition of mesh facing forward or backward
  23899. * @param flipBack defines the flip
  23900. * @param twirlClockwise defines the twirl
  23901. * @param tiltRight defines the tilt
  23902. * @returns the current mesh
  23903. */
  23904. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23905. /**
  23906. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23907. * Supports definition of mesh facing forward or backward.
  23908. * @param flipBack defines the flip
  23909. * @param twirlClockwise defines the twirl
  23910. * @param tiltRight defines the tilt
  23911. * @returns the new rotation vector
  23912. */
  23913. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23914. /**
  23915. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23916. * This means the mesh underlying bounding box and sphere are recomputed.
  23917. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23918. * @returns the current mesh
  23919. */
  23920. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  23921. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  23922. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  23923. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  23924. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  23925. /** @hidden */
  23926. protected _afterComputeWorldMatrix(): void;
  23927. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  23928. /**
  23929. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23930. * A mesh is in the frustum if its bounding box intersects the frustum
  23931. * @param frustumPlanes defines the frustum to test
  23932. * @returns true if the mesh is in the frustum planes
  23933. */
  23934. isInFrustum(frustumPlanes: Plane[]): boolean;
  23935. /**
  23936. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23937. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23938. * @param frustumPlanes defines the frustum to test
  23939. * @returns true if the mesh is completely in the frustum planes
  23940. */
  23941. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23942. /**
  23943. * True if the mesh intersects another mesh or a SolidParticle object
  23944. * @param mesh defines a target mesh or SolidParticle to test
  23945. * @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)
  23946. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23947. * @returns true if there is an intersection
  23948. */
  23949. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23950. /**
  23951. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23952. * @param point defines the point to test
  23953. * @returns true if there is an intersection
  23954. */
  23955. intersectsPoint(point: Vector3): boolean;
  23956. /**
  23957. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23958. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23959. */
  23960. checkCollisions: boolean;
  23961. /**
  23962. * Gets Collider object used to compute collisions (not physics)
  23963. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23964. */
  23965. readonly collider: Nullable<Collider>;
  23966. /**
  23967. * Move the mesh using collision engine
  23968. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23969. * @param displacement defines the requested displacement vector
  23970. * @returns the current mesh
  23971. */
  23972. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23973. private _onCollisionPositionChange;
  23974. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23975. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23976. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  23977. /** @hidden */ generatePointsArray(): boolean;
  23978. /**
  23979. * Checks if the passed Ray intersects with the mesh
  23980. * @param ray defines the ray to use
  23981. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23982. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23983. * @returns the picking info
  23984. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23985. */
  23986. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  23987. /**
  23988. * Clones the current mesh
  23989. * @param name defines the mesh name
  23990. * @param newParent defines the new mesh parent
  23991. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23992. * @returns the new mesh
  23993. */
  23994. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23995. /**
  23996. * Disposes all the submeshes of the current meshnp
  23997. * @returns the current mesh
  23998. */
  23999. releaseSubMeshes(): AbstractMesh;
  24000. /**
  24001. * Releases resources associated with this abstract mesh.
  24002. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24003. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24004. */
  24005. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24006. /**
  24007. * Adds the passed mesh as a child to the current mesh
  24008. * @param mesh defines the child mesh
  24009. * @returns the current mesh
  24010. */
  24011. addChild(mesh: AbstractMesh): AbstractMesh;
  24012. /**
  24013. * Removes the passed mesh from the current mesh children list
  24014. * @param mesh defines the child mesh
  24015. * @returns the current mesh
  24016. */
  24017. removeChild(mesh: AbstractMesh): AbstractMesh;
  24018. /** @hidden */
  24019. private _initFacetData;
  24020. /**
  24021. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24022. * This method can be called within the render loop.
  24023. * 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
  24024. * @returns the current mesh
  24025. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24026. */
  24027. updateFacetData(): AbstractMesh;
  24028. /**
  24029. * Returns the facetLocalNormals array.
  24030. * The normals are expressed in the mesh local spac
  24031. * @returns an array of Vector3
  24032. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24033. */
  24034. getFacetLocalNormals(): Vector3[];
  24035. /**
  24036. * Returns the facetLocalPositions array.
  24037. * The facet positions are expressed in the mesh local space
  24038. * @returns an array of Vector3
  24039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24040. */
  24041. getFacetLocalPositions(): Vector3[];
  24042. /**
  24043. * Returns the facetLocalPartioning array
  24044. * @returns an array of array of numbers
  24045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24046. */
  24047. getFacetLocalPartitioning(): number[][];
  24048. /**
  24049. * Returns the i-th facet position in the world system.
  24050. * This method allocates a new Vector3 per call
  24051. * @param i defines the facet index
  24052. * @returns a new Vector3
  24053. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24054. */
  24055. getFacetPosition(i: number): Vector3;
  24056. /**
  24057. * Sets the reference Vector3 with the i-th facet position in the world system
  24058. * @param i defines the facet index
  24059. * @param ref defines the target vector
  24060. * @returns the current mesh
  24061. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24062. */
  24063. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24064. /**
  24065. * Returns the i-th facet normal in the world system.
  24066. * This method allocates a new Vector3 per call
  24067. * @param i defines the facet index
  24068. * @returns a new Vector3
  24069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24070. */
  24071. getFacetNormal(i: number): Vector3;
  24072. /**
  24073. * Sets the reference Vector3 with the i-th facet normal in the world system
  24074. * @param i defines the facet index
  24075. * @param ref defines the target vector
  24076. * @returns the current mesh
  24077. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24078. */
  24079. getFacetNormalToRef(i: number, ref: Vector3): this;
  24080. /**
  24081. * 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)
  24082. * @param x defines x coordinate
  24083. * @param y defines y coordinate
  24084. * @param z defines z coordinate
  24085. * @returns the array of facet indexes
  24086. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24087. */
  24088. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24089. /**
  24090. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24091. * @param projected sets as the (x,y,z) world projection on the facet
  24092. * @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
  24093. * @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
  24094. * @param x defines x coordinate
  24095. * @param y defines y coordinate
  24096. * @param z defines z coordinate
  24097. * @returns the face index if found (or null instead)
  24098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24099. */
  24100. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24101. /**
  24102. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24103. * @param projected sets as the (x,y,z) local projection on the facet
  24104. * @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
  24105. * @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
  24106. * @param x defines x coordinate
  24107. * @param y defines y coordinate
  24108. * @param z defines z coordinate
  24109. * @returns the face index if found (or null instead)
  24110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24111. */
  24112. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24113. /**
  24114. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24115. * @returns the parameters
  24116. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24117. */
  24118. getFacetDataParameters(): any;
  24119. /**
  24120. * Disables the feature FacetData and frees the related memory
  24121. * @returns the current mesh
  24122. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24123. */
  24124. disableFacetData(): AbstractMesh;
  24125. /**
  24126. * Updates the AbstractMesh indices array
  24127. * @param indices defines the data source
  24128. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24129. * @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)
  24130. * @returns the current mesh
  24131. */
  24132. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24133. /**
  24134. * Creates new normals data for the mesh
  24135. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24136. * @returns the current mesh
  24137. */
  24138. createNormals(updatable: boolean): AbstractMesh;
  24139. /**
  24140. * Align the mesh with a normal
  24141. * @param normal defines the normal to use
  24142. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24143. * @returns the current mesh
  24144. */
  24145. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24146. /** @hidden */ checkOcclusionQuery(): boolean;
  24147. }
  24148. }
  24149. declare module BABYLON {
  24150. /**
  24151. * Interface used to define ActionEvent
  24152. */
  24153. export interface IActionEvent {
  24154. /** The mesh or sprite that triggered the action */
  24155. source: any;
  24156. /** The X mouse cursor position at the time of the event */
  24157. pointerX: number;
  24158. /** The Y mouse cursor position at the time of the event */
  24159. pointerY: number;
  24160. /** The mesh that is currently pointed at (can be null) */
  24161. meshUnderPointer: Nullable<AbstractMesh>;
  24162. /** the original (browser) event that triggered the ActionEvent */
  24163. sourceEvent?: any;
  24164. /** additional data for the event */
  24165. additionalData?: any;
  24166. }
  24167. /**
  24168. * ActionEvent is the event being sent when an action is triggered.
  24169. */
  24170. export class ActionEvent implements IActionEvent {
  24171. /** The mesh or sprite that triggered the action */
  24172. source: any;
  24173. /** The X mouse cursor position at the time of the event */
  24174. pointerX: number;
  24175. /** The Y mouse cursor position at the time of the event */
  24176. pointerY: number;
  24177. /** The mesh that is currently pointed at (can be null) */
  24178. meshUnderPointer: Nullable<AbstractMesh>;
  24179. /** the original (browser) event that triggered the ActionEvent */
  24180. sourceEvent?: any;
  24181. /** additional data for the event */
  24182. additionalData?: any;
  24183. /**
  24184. * Creates a new ActionEvent
  24185. * @param source The mesh or sprite that triggered the action
  24186. * @param pointerX The X mouse cursor position at the time of the event
  24187. * @param pointerY The Y mouse cursor position at the time of the event
  24188. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24189. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24190. * @param additionalData additional data for the event
  24191. */
  24192. constructor(
  24193. /** The mesh or sprite that triggered the action */
  24194. source: any,
  24195. /** The X mouse cursor position at the time of the event */
  24196. pointerX: number,
  24197. /** The Y mouse cursor position at the time of the event */
  24198. pointerY: number,
  24199. /** The mesh that is currently pointed at (can be null) */
  24200. meshUnderPointer: Nullable<AbstractMesh>,
  24201. /** the original (browser) event that triggered the ActionEvent */
  24202. sourceEvent?: any,
  24203. /** additional data for the event */
  24204. additionalData?: any);
  24205. /**
  24206. * Helper function to auto-create an ActionEvent from a source mesh.
  24207. * @param source The source mesh that triggered the event
  24208. * @param evt The original (browser) event
  24209. * @param additionalData additional data for the event
  24210. * @returns the new ActionEvent
  24211. */
  24212. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24213. /**
  24214. * Helper function to auto-create an ActionEvent from a source sprite
  24215. * @param source The source sprite that triggered the event
  24216. * @param scene Scene associated with the sprite
  24217. * @param evt The original (browser) event
  24218. * @param additionalData additional data for the event
  24219. * @returns the new ActionEvent
  24220. */
  24221. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24222. /**
  24223. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24224. * @param scene the scene where the event occurred
  24225. * @param evt The original (browser) event
  24226. * @returns the new ActionEvent
  24227. */
  24228. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24229. /**
  24230. * Helper function to auto-create an ActionEvent from a primitive
  24231. * @param prim defines the target primitive
  24232. * @param pointerPos defines the pointer position
  24233. * @param evt The original (browser) event
  24234. * @param additionalData additional data for the event
  24235. * @returns the new ActionEvent
  24236. */
  24237. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24238. }
  24239. }
  24240. declare module BABYLON {
  24241. /**
  24242. * Abstract class used to decouple action Manager from scene and meshes.
  24243. * Do not instantiate.
  24244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24245. */
  24246. export abstract class AbstractActionManager implements IDisposable {
  24247. /** Gets the list of active triggers */
  24248. static Triggers: {
  24249. [key: string]: number;
  24250. };
  24251. /** Gets the cursor to use when hovering items */
  24252. hoverCursor: string;
  24253. /** Gets the list of actions */
  24254. actions: IAction[];
  24255. /**
  24256. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24257. */
  24258. isRecursive: boolean;
  24259. /**
  24260. * Releases all associated resources
  24261. */
  24262. abstract dispose(): void;
  24263. /**
  24264. * Does this action manager has pointer triggers
  24265. */
  24266. abstract readonly hasPointerTriggers: boolean;
  24267. /**
  24268. * Does this action manager has pick triggers
  24269. */
  24270. abstract readonly hasPickTriggers: boolean;
  24271. /**
  24272. * Process a specific trigger
  24273. * @param trigger defines the trigger to process
  24274. * @param evt defines the event details to be processed
  24275. */
  24276. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24277. /**
  24278. * Does this action manager handles actions of any of the given triggers
  24279. * @param triggers defines the triggers to be tested
  24280. * @return a boolean indicating whether one (or more) of the triggers is handled
  24281. */
  24282. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24283. /**
  24284. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24285. * speed.
  24286. * @param triggerA defines the trigger to be tested
  24287. * @param triggerB defines the trigger to be tested
  24288. * @return a boolean indicating whether one (or more) of the triggers is handled
  24289. */
  24290. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24291. /**
  24292. * Does this action manager handles actions of a given trigger
  24293. * @param trigger defines the trigger to be tested
  24294. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24295. * @return whether the trigger is handled
  24296. */
  24297. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24298. /**
  24299. * Serialize this manager to a JSON object
  24300. * @param name defines the property name to store this manager
  24301. * @returns a JSON representation of this manager
  24302. */
  24303. abstract serialize(name: string): any;
  24304. /**
  24305. * Registers an action to this action manager
  24306. * @param action defines the action to be registered
  24307. * @return the action amended (prepared) after registration
  24308. */
  24309. abstract registerAction(action: IAction): Nullable<IAction>;
  24310. /**
  24311. * Unregisters an action to this action manager
  24312. * @param action defines the action to be unregistered
  24313. * @return a boolean indicating whether the action has been unregistered
  24314. */
  24315. abstract unregisterAction(action: IAction): Boolean;
  24316. /**
  24317. * Does exist one action manager with at least one trigger
  24318. **/
  24319. static readonly HasTriggers: boolean;
  24320. /**
  24321. * Does exist one action manager with at least one pick trigger
  24322. **/
  24323. static readonly HasPickTriggers: boolean;
  24324. /**
  24325. * Does exist one action manager that handles actions of a given trigger
  24326. * @param trigger defines the trigger to be tested
  24327. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24328. **/
  24329. static HasSpecificTrigger(trigger: number): boolean;
  24330. }
  24331. }
  24332. declare module BABYLON {
  24333. /**
  24334. * Defines how a node can be built from a string name.
  24335. */
  24336. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24337. /**
  24338. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24339. */
  24340. export class Node implements IBehaviorAware<Node> {
  24341. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24342. private static _NodeConstructors;
  24343. /**
  24344. * Add a new node constructor
  24345. * @param type defines the type name of the node to construct
  24346. * @param constructorFunc defines the constructor function
  24347. */
  24348. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24349. /**
  24350. * Returns a node constructor based on type name
  24351. * @param type defines the type name
  24352. * @param name defines the new node name
  24353. * @param scene defines the hosting scene
  24354. * @param options defines optional options to transmit to constructors
  24355. * @returns the new constructor or null
  24356. */
  24357. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24358. /**
  24359. * Gets or sets the name of the node
  24360. */
  24361. name: string;
  24362. /**
  24363. * Gets or sets the id of the node
  24364. */
  24365. id: string;
  24366. /**
  24367. * Gets or sets the unique id of the node
  24368. */
  24369. uniqueId: number;
  24370. /**
  24371. * Gets or sets a string used to store user defined state for the node
  24372. */
  24373. state: string;
  24374. /**
  24375. * Gets or sets an object used to store user defined information for the node
  24376. */
  24377. metadata: any;
  24378. /**
  24379. * For internal use only. Please do not use.
  24380. */
  24381. reservedDataStore: any;
  24382. /**
  24383. * List of inspectable custom properties (used by the Inspector)
  24384. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24385. */
  24386. inspectableCustomProperties: IInspectable[];
  24387. /**
  24388. * Gets or sets a boolean used to define if the node must be serialized
  24389. */
  24390. doNotSerialize: boolean;
  24391. /** @hidden */ isDisposed: boolean;
  24392. /**
  24393. * Gets a list of Animations associated with the node
  24394. */
  24395. animations: Animation[];
  24396. protected _ranges: {
  24397. [name: string]: Nullable<AnimationRange>;
  24398. };
  24399. /**
  24400. * Callback raised when the node is ready to be used
  24401. */
  24402. onReady: Nullable<(node: Node) => void>;
  24403. private _isEnabled;
  24404. private _isParentEnabled;
  24405. private _isReady;
  24406. /** @hidden */ currentRenderId: number;
  24407. private _parentUpdateId;
  24408. /** @hidden */ childUpdateId: number;
  24409. /** @hidden */ waitingParentId: Nullable<string>;
  24410. /** @hidden */ scene: Scene;
  24411. /** @hidden */ cache: any;
  24412. private _parentNode;
  24413. private _children;
  24414. /** @hidden */ worldMatrix: Matrix;
  24415. /** @hidden */ worldMatrixDeterminant: number;
  24416. /** @hidden */ worldMatrixDeterminantIsDirty: boolean;
  24417. /** @hidden */
  24418. private _sceneRootNodesIndex;
  24419. /**
  24420. * Gets a boolean indicating if the node has been disposed
  24421. * @returns true if the node was disposed
  24422. */
  24423. isDisposed(): boolean;
  24424. /**
  24425. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24426. * @see https://doc.babylonjs.com/how_to/parenting
  24427. */
  24428. parent: Nullable<Node>;
  24429. private addToSceneRootNodes;
  24430. private removeFromSceneRootNodes;
  24431. private _animationPropertiesOverride;
  24432. /**
  24433. * Gets or sets the animation properties override
  24434. */
  24435. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24436. /**
  24437. * Gets a string idenfifying the name of the class
  24438. * @returns "Node" string
  24439. */
  24440. getClassName(): string;
  24441. /** @hidden */ protected readonly _isNode: boolean;
  24442. /**
  24443. * An event triggered when the mesh is disposed
  24444. */
  24445. onDisposeObservable: Observable<Node>;
  24446. private _onDisposeObserver;
  24447. /**
  24448. * Sets a callback that will be raised when the node will be disposed
  24449. */
  24450. onDispose: () => void;
  24451. /**
  24452. * Creates a new Node
  24453. * @param name the name and id to be given to this node
  24454. * @param scene the scene this node will be added to
  24455. * @param addToRootNodes the node will be added to scene.rootNodes
  24456. */
  24457. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24458. /**
  24459. * Gets the scene of the node
  24460. * @returns a scene
  24461. */
  24462. getScene(): Scene;
  24463. /**
  24464. * Gets the engine of the node
  24465. * @returns a Engine
  24466. */
  24467. getEngine(): Engine;
  24468. private _behaviors;
  24469. /**
  24470. * Attach a behavior to the node
  24471. * @see http://doc.babylonjs.com/features/behaviour
  24472. * @param behavior defines the behavior to attach
  24473. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24474. * @returns the current Node
  24475. */
  24476. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24477. /**
  24478. * Remove an attached behavior
  24479. * @see http://doc.babylonjs.com/features/behaviour
  24480. * @param behavior defines the behavior to attach
  24481. * @returns the current Node
  24482. */
  24483. removeBehavior(behavior: Behavior<Node>): Node;
  24484. /**
  24485. * Gets the list of attached behaviors
  24486. * @see http://doc.babylonjs.com/features/behaviour
  24487. */
  24488. readonly behaviors: Behavior<Node>[];
  24489. /**
  24490. * Gets an attached behavior by name
  24491. * @param name defines the name of the behavior to look for
  24492. * @see http://doc.babylonjs.com/features/behaviour
  24493. * @returns null if behavior was not found else the requested behavior
  24494. */
  24495. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24496. /**
  24497. * Returns the latest update of the World matrix
  24498. * @returns a Matrix
  24499. */
  24500. getWorldMatrix(): Matrix;
  24501. /** @hidden */ getWorldMatrixDeterminant(): number;
  24502. /**
  24503. * Returns directly the latest state of the mesh World matrix.
  24504. * A Matrix is returned.
  24505. */
  24506. readonly worldMatrixFromCache: Matrix;
  24507. /** @hidden */ initCache(): void;
  24508. /** @hidden */
  24509. updateCache(force?: boolean): void;
  24510. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24511. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  24512. /** @hidden */ isSynchronized(): boolean;
  24513. /** @hidden */ markSyncedWithParent(): void;
  24514. /** @hidden */
  24515. isSynchronizedWithParent(): boolean;
  24516. /** @hidden */
  24517. isSynchronized(): boolean;
  24518. /**
  24519. * Is this node ready to be used/rendered
  24520. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24521. * @return true if the node is ready
  24522. */
  24523. isReady(completeCheck?: boolean): boolean;
  24524. /**
  24525. * Is this node enabled?
  24526. * 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
  24527. * @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
  24528. * @return whether this node (and its parent) is enabled
  24529. */
  24530. isEnabled(checkAncestors?: boolean): boolean;
  24531. /** @hidden */
  24532. protected _syncParentEnabledState(): void;
  24533. /**
  24534. * Set the enabled state of this node
  24535. * @param value defines the new enabled state
  24536. */
  24537. setEnabled(value: boolean): void;
  24538. /**
  24539. * Is this node a descendant of the given node?
  24540. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24541. * @param ancestor defines the parent node to inspect
  24542. * @returns a boolean indicating if this node is a descendant of the given node
  24543. */
  24544. isDescendantOf(ancestor: Node): boolean;
  24545. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24546. /**
  24547. * Will return all nodes that have this node as ascendant
  24548. * @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
  24549. * @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
  24550. * @return all children nodes of all types
  24551. */
  24552. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24553. /**
  24554. * Get all child-meshes of this node
  24555. * @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)
  24556. * @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
  24557. * @returns an array of AbstractMesh
  24558. */
  24559. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24560. /**
  24561. * Get all direct children of this node
  24562. * @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
  24563. * @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)
  24564. * @returns an array of Node
  24565. */
  24566. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24567. /** @hidden */ setReady(state: boolean): void;
  24568. /**
  24569. * Get an animation by name
  24570. * @param name defines the name of the animation to look for
  24571. * @returns null if not found else the requested animation
  24572. */
  24573. getAnimationByName(name: string): Nullable<Animation>;
  24574. /**
  24575. * Creates an animation range for this node
  24576. * @param name defines the name of the range
  24577. * @param from defines the starting key
  24578. * @param to defines the end key
  24579. */
  24580. createAnimationRange(name: string, from: number, to: number): void;
  24581. /**
  24582. * Delete a specific animation range
  24583. * @param name defines the name of the range to delete
  24584. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24585. */
  24586. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24587. /**
  24588. * Get an animation range by name
  24589. * @param name defines the name of the animation range to look for
  24590. * @returns null if not found else the requested animation range
  24591. */
  24592. getAnimationRange(name: string): Nullable<AnimationRange>;
  24593. /**
  24594. * Gets the list of all animation ranges defined on this node
  24595. * @returns an array
  24596. */
  24597. getAnimationRanges(): Nullable<AnimationRange>[];
  24598. /**
  24599. * Will start the animation sequence
  24600. * @param name defines the range frames for animation sequence
  24601. * @param loop defines if the animation should loop (false by default)
  24602. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24603. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24604. * @returns the object created for this animation. If range does not exist, it will return null
  24605. */
  24606. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24607. /**
  24608. * Serialize animation ranges into a JSON compatible object
  24609. * @returns serialization object
  24610. */
  24611. serializeAnimationRanges(): any;
  24612. /**
  24613. * Computes the world matrix of the node
  24614. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24615. * @returns the world matrix
  24616. */
  24617. computeWorldMatrix(force?: boolean): Matrix;
  24618. /**
  24619. * Releases resources associated with this node.
  24620. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24621. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24622. */
  24623. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24624. /**
  24625. * Parse animation range data from a serialization object and store them into a given node
  24626. * @param node defines where to store the animation ranges
  24627. * @param parsedNode defines the serialization object to read data from
  24628. * @param scene defines the hosting scene
  24629. */
  24630. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24631. /**
  24632. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  24633. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24634. * @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
  24635. * @returns the new bounding vectors
  24636. */
  24637. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24638. min: Vector3;
  24639. max: Vector3;
  24640. };
  24641. }
  24642. }
  24643. declare module BABYLON {
  24644. /**
  24645. * @hidden
  24646. */
  24647. export class _IAnimationState {
  24648. key: number;
  24649. repeatCount: number;
  24650. workValue?: any;
  24651. loopMode?: number;
  24652. offsetValue?: any;
  24653. highLimitValue?: any;
  24654. }
  24655. /**
  24656. * Class used to store any kind of animation
  24657. */
  24658. export class Animation {
  24659. /**Name of the animation */
  24660. name: string;
  24661. /**Property to animate */
  24662. targetProperty: string;
  24663. /**The frames per second of the animation */
  24664. framePerSecond: number;
  24665. /**The data type of the animation */
  24666. dataType: number;
  24667. /**The loop mode of the animation */
  24668. loopMode?: number | undefined;
  24669. /**Specifies if blending should be enabled */
  24670. enableBlending?: boolean | undefined;
  24671. /**
  24672. * Use matrix interpolation instead of using direct key value when animating matrices
  24673. */
  24674. static AllowMatricesInterpolation: boolean;
  24675. /**
  24676. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24677. */
  24678. static AllowMatrixDecomposeForInterpolation: boolean;
  24679. /**
  24680. * Stores the key frames of the animation
  24681. */
  24682. private _keys;
  24683. /**
  24684. * Stores the easing function of the animation
  24685. */
  24686. private _easingFunction;
  24687. /**
  24688. * @hidden Internal use only
  24689. */ runtimeAnimations: RuntimeAnimation[];
  24690. /**
  24691. * The set of event that will be linked to this animation
  24692. */
  24693. private _events;
  24694. /**
  24695. * Stores an array of target property paths
  24696. */
  24697. targetPropertyPath: string[];
  24698. /**
  24699. * Stores the blending speed of the animation
  24700. */
  24701. blendingSpeed: number;
  24702. /**
  24703. * Stores the animation ranges for the animation
  24704. */
  24705. private _ranges;
  24706. /**
  24707. * @hidden Internal use
  24708. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24709. /**
  24710. * Sets up an animation
  24711. * @param property The property to animate
  24712. * @param animationType The animation type to apply
  24713. * @param framePerSecond The frames per second of the animation
  24714. * @param easingFunction The easing function used in the animation
  24715. * @returns The created animation
  24716. */
  24717. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24718. /**
  24719. * Create and start an animation on a node
  24720. * @param name defines the name of the global animation that will be run on all nodes
  24721. * @param node defines the root node where the animation will take place
  24722. * @param targetProperty defines property to animate
  24723. * @param framePerSecond defines the number of frame per second yo use
  24724. * @param totalFrame defines the number of frames in total
  24725. * @param from defines the initial value
  24726. * @param to defines the final value
  24727. * @param loopMode defines which loop mode you want to use (off by default)
  24728. * @param easingFunction defines the easing function to use (linear by default)
  24729. * @param onAnimationEnd defines the callback to call when animation end
  24730. * @returns the animatable created for this animation
  24731. */
  24732. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24733. /**
  24734. * Create and start an animation on a node and its descendants
  24735. * @param name defines the name of the global animation that will be run on all nodes
  24736. * @param node defines the root node where the animation will take place
  24737. * @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
  24738. * @param targetProperty defines property to animate
  24739. * @param framePerSecond defines the number of frame per second to use
  24740. * @param totalFrame defines the number of frames in total
  24741. * @param from defines the initial value
  24742. * @param to defines the final value
  24743. * @param loopMode defines which loop mode you want to use (off by default)
  24744. * @param easingFunction defines the easing function to use (linear by default)
  24745. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24746. * @returns the list of animatables created for all nodes
  24747. * @example https://www.babylonjs-playground.com/#MH0VLI
  24748. */
  24749. 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[]>;
  24750. /**
  24751. * Creates a new animation, merges it with the existing animations and starts it
  24752. * @param name Name of the animation
  24753. * @param node Node which contains the scene that begins the animations
  24754. * @param targetProperty Specifies which property to animate
  24755. * @param framePerSecond The frames per second of the animation
  24756. * @param totalFrame The total number of frames
  24757. * @param from The frame at the beginning of the animation
  24758. * @param to The frame at the end of the animation
  24759. * @param loopMode Specifies the loop mode of the animation
  24760. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  24761. * @param onAnimationEnd Callback to run once the animation is complete
  24762. * @returns Nullable animation
  24763. */
  24764. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24765. /**
  24766. * Transition property of an host to the target Value
  24767. * @param property The property to transition
  24768. * @param targetValue The target Value of the property
  24769. * @param host The object where the property to animate belongs
  24770. * @param scene Scene used to run the animation
  24771. * @param frameRate Framerate (in frame/s) to use
  24772. * @param transition The transition type we want to use
  24773. * @param duration The duration of the animation, in milliseconds
  24774. * @param onAnimationEnd Callback trigger at the end of the animation
  24775. * @returns Nullable animation
  24776. */
  24777. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  24778. /**
  24779. * Return the array of runtime animations currently using this animation
  24780. */
  24781. readonly runtimeAnimations: RuntimeAnimation[];
  24782. /**
  24783. * Specifies if any of the runtime animations are currently running
  24784. */
  24785. readonly hasRunningRuntimeAnimations: boolean;
  24786. /**
  24787. * Initializes the animation
  24788. * @param name Name of the animation
  24789. * @param targetProperty Property to animate
  24790. * @param framePerSecond The frames per second of the animation
  24791. * @param dataType The data type of the animation
  24792. * @param loopMode The loop mode of the animation
  24793. * @param enableBlending Specifies if blending should be enabled
  24794. */
  24795. constructor(
  24796. /**Name of the animation */
  24797. name: string,
  24798. /**Property to animate */
  24799. targetProperty: string,
  24800. /**The frames per second of the animation */
  24801. framePerSecond: number,
  24802. /**The data type of the animation */
  24803. dataType: number,
  24804. /**The loop mode of the animation */
  24805. loopMode?: number | undefined,
  24806. /**Specifies if blending should be enabled */
  24807. enableBlending?: boolean | undefined);
  24808. /**
  24809. * Converts the animation to a string
  24810. * @param fullDetails support for multiple levels of logging within scene loading
  24811. * @returns String form of the animation
  24812. */
  24813. toString(fullDetails?: boolean): string;
  24814. /**
  24815. * Add an event to this animation
  24816. * @param event Event to add
  24817. */
  24818. addEvent(event: AnimationEvent): void;
  24819. /**
  24820. * Remove all events found at the given frame
  24821. * @param frame The frame to remove events from
  24822. */
  24823. removeEvents(frame: number): void;
  24824. /**
  24825. * Retrieves all the events from the animation
  24826. * @returns Events from the animation
  24827. */
  24828. getEvents(): AnimationEvent[];
  24829. /**
  24830. * Creates an animation range
  24831. * @param name Name of the animation range
  24832. * @param from Starting frame of the animation range
  24833. * @param to Ending frame of the animation
  24834. */
  24835. createRange(name: string, from: number, to: number): void;
  24836. /**
  24837. * Deletes an animation range by name
  24838. * @param name Name of the animation range to delete
  24839. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  24840. */
  24841. deleteRange(name: string, deleteFrames?: boolean): void;
  24842. /**
  24843. * Gets the animation range by name, or null if not defined
  24844. * @param name Name of the animation range
  24845. * @returns Nullable animation range
  24846. */
  24847. getRange(name: string): Nullable<AnimationRange>;
  24848. /**
  24849. * Gets the key frames from the animation
  24850. * @returns The key frames of the animation
  24851. */
  24852. getKeys(): Array<IAnimationKey>;
  24853. /**
  24854. * Gets the highest frame rate of the animation
  24855. * @returns Highest frame rate of the animation
  24856. */
  24857. getHighestFrame(): number;
  24858. /**
  24859. * Gets the easing function of the animation
  24860. * @returns Easing function of the animation
  24861. */
  24862. getEasingFunction(): IEasingFunction;
  24863. /**
  24864. * Sets the easing function of the animation
  24865. * @param easingFunction A custom mathematical formula for animation
  24866. */
  24867. setEasingFunction(easingFunction: EasingFunction): void;
  24868. /**
  24869. * Interpolates a scalar linearly
  24870. * @param startValue Start value of the animation curve
  24871. * @param endValue End value of the animation curve
  24872. * @param gradient Scalar amount to interpolate
  24873. * @returns Interpolated scalar value
  24874. */
  24875. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  24876. /**
  24877. * Interpolates a scalar cubically
  24878. * @param startValue Start value of the animation curve
  24879. * @param outTangent End tangent of the animation
  24880. * @param endValue End value of the animation curve
  24881. * @param inTangent Start tangent of the animation curve
  24882. * @param gradient Scalar amount to interpolate
  24883. * @returns Interpolated scalar value
  24884. */
  24885. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  24886. /**
  24887. * Interpolates a quaternion using a spherical linear interpolation
  24888. * @param startValue Start value of the animation curve
  24889. * @param endValue End value of the animation curve
  24890. * @param gradient Scalar amount to interpolate
  24891. * @returns Interpolated quaternion value
  24892. */
  24893. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  24894. /**
  24895. * Interpolates a quaternion cubically
  24896. * @param startValue Start value of the animation curve
  24897. * @param outTangent End tangent of the animation curve
  24898. * @param endValue End value of the animation curve
  24899. * @param inTangent Start tangent of the animation curve
  24900. * @param gradient Scalar amount to interpolate
  24901. * @returns Interpolated quaternion value
  24902. */
  24903. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  24904. /**
  24905. * Interpolates a Vector3 linearl
  24906. * @param startValue Start value of the animation curve
  24907. * @param endValue End value of the animation curve
  24908. * @param gradient Scalar amount to interpolate
  24909. * @returns Interpolated scalar value
  24910. */
  24911. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  24912. /**
  24913. * Interpolates a Vector3 cubically
  24914. * @param startValue Start value of the animation curve
  24915. * @param outTangent End tangent of the animation
  24916. * @param endValue End value of the animation curve
  24917. * @param inTangent Start tangent of the animation curve
  24918. * @param gradient Scalar amount to interpolate
  24919. * @returns InterpolatedVector3 value
  24920. */
  24921. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  24922. /**
  24923. * Interpolates a Vector2 linearly
  24924. * @param startValue Start value of the animation curve
  24925. * @param endValue End value of the animation curve
  24926. * @param gradient Scalar amount to interpolate
  24927. * @returns Interpolated Vector2 value
  24928. */
  24929. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  24930. /**
  24931. * Interpolates a Vector2 cubically
  24932. * @param startValue Start value of the animation curve
  24933. * @param outTangent End tangent of the animation
  24934. * @param endValue End value of the animation curve
  24935. * @param inTangent Start tangent of the animation curve
  24936. * @param gradient Scalar amount to interpolate
  24937. * @returns Interpolated Vector2 value
  24938. */
  24939. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  24940. /**
  24941. * Interpolates a size linearly
  24942. * @param startValue Start value of the animation curve
  24943. * @param endValue End value of the animation curve
  24944. * @param gradient Scalar amount to interpolate
  24945. * @returns Interpolated Size value
  24946. */
  24947. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  24948. /**
  24949. * Interpolates a Color3 linearly
  24950. * @param startValue Start value of the animation curve
  24951. * @param endValue End value of the animation curve
  24952. * @param gradient Scalar amount to interpolate
  24953. * @returns Interpolated Color3 value
  24954. */
  24955. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  24956. /**
  24957. * @hidden Internal use only
  24958. */ getKeyValue(value: any): any;
  24959. /**
  24960. * @hidden Internal use only
  24961. */ interpolate(currentFrame: number, state: _IAnimationState): any;
  24962. /**
  24963. * Defines the function to use to interpolate matrices
  24964. * @param startValue defines the start matrix
  24965. * @param endValue defines the end matrix
  24966. * @param gradient defines the gradient between both matrices
  24967. * @param result defines an optional target matrix where to store the interpolation
  24968. * @returns the interpolated matrix
  24969. */
  24970. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  24971. /**
  24972. * Makes a copy of the animation
  24973. * @returns Cloned animation
  24974. */
  24975. clone(): Animation;
  24976. /**
  24977. * Sets the key frames of the animation
  24978. * @param values The animation key frames to set
  24979. */
  24980. setKeys(values: Array<IAnimationKey>): void;
  24981. /**
  24982. * Serializes the animation to an object
  24983. * @returns Serialized object
  24984. */
  24985. serialize(): any;
  24986. /**
  24987. * Float animation type
  24988. */
  24989. private static _ANIMATIONTYPE_FLOAT;
  24990. /**
  24991. * Vector3 animation type
  24992. */
  24993. private static _ANIMATIONTYPE_VECTOR3;
  24994. /**
  24995. * Quaternion animation type
  24996. */
  24997. private static _ANIMATIONTYPE_QUATERNION;
  24998. /**
  24999. * Matrix animation type
  25000. */
  25001. private static _ANIMATIONTYPE_MATRIX;
  25002. /**
  25003. * Color3 animation type
  25004. */
  25005. private static _ANIMATIONTYPE_COLOR3;
  25006. /**
  25007. * Vector2 animation type
  25008. */
  25009. private static _ANIMATIONTYPE_VECTOR2;
  25010. /**
  25011. * Size animation type
  25012. */
  25013. private static _ANIMATIONTYPE_SIZE;
  25014. /**
  25015. * Relative Loop Mode
  25016. */
  25017. private static _ANIMATIONLOOPMODE_RELATIVE;
  25018. /**
  25019. * Cycle Loop Mode
  25020. */
  25021. private static _ANIMATIONLOOPMODE_CYCLE;
  25022. /**
  25023. * Constant Loop Mode
  25024. */
  25025. private static _ANIMATIONLOOPMODE_CONSTANT;
  25026. /**
  25027. * Get the float animation type
  25028. */
  25029. static readonly ANIMATIONTYPE_FLOAT: number;
  25030. /**
  25031. * Get the Vector3 animation type
  25032. */
  25033. static readonly ANIMATIONTYPE_VECTOR3: number;
  25034. /**
  25035. * Get the Vector2 animation type
  25036. */
  25037. static readonly ANIMATIONTYPE_VECTOR2: number;
  25038. /**
  25039. * Get the Size animation type
  25040. */
  25041. static readonly ANIMATIONTYPE_SIZE: number;
  25042. /**
  25043. * Get the Quaternion animation type
  25044. */
  25045. static readonly ANIMATIONTYPE_QUATERNION: number;
  25046. /**
  25047. * Get the Matrix animation type
  25048. */
  25049. static readonly ANIMATIONTYPE_MATRIX: number;
  25050. /**
  25051. * Get the Color3 animation type
  25052. */
  25053. static readonly ANIMATIONTYPE_COLOR3: number;
  25054. /**
  25055. * Get the Relative Loop Mode
  25056. */
  25057. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25058. /**
  25059. * Get the Cycle Loop Mode
  25060. */
  25061. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25062. /**
  25063. * Get the Constant Loop Mode
  25064. */
  25065. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25066. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25067. /**
  25068. * Parses an animation object and creates an animation
  25069. * @param parsedAnimation Parsed animation object
  25070. * @returns Animation object
  25071. */
  25072. static Parse(parsedAnimation: any): Animation;
  25073. /**
  25074. * Appends the serialized animations from the source animations
  25075. * @param source Source containing the animations
  25076. * @param destination Target to store the animations
  25077. */
  25078. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25079. }
  25080. }
  25081. declare module BABYLON {
  25082. /**
  25083. * Base class of all the textures in babylon.
  25084. * It groups all the common properties the materials, post process, lights... might need
  25085. * in order to make a correct use of the texture.
  25086. */
  25087. export class BaseTexture implements IAnimatable {
  25088. /**
  25089. * Default anisotropic filtering level for the application.
  25090. * It is set to 4 as a good tradeoff between perf and quality.
  25091. */
  25092. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25093. /**
  25094. * Gets or sets the unique id of the texture
  25095. */
  25096. uniqueId: number;
  25097. /**
  25098. * Define the name of the texture.
  25099. */
  25100. name: string;
  25101. /**
  25102. * Gets or sets an object used to store user defined information.
  25103. */
  25104. metadata: any;
  25105. /**
  25106. * For internal use only. Please do not use.
  25107. */
  25108. reservedDataStore: any;
  25109. private _hasAlpha;
  25110. /**
  25111. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25112. */
  25113. hasAlpha: boolean;
  25114. /**
  25115. * Defines if the alpha value should be determined via the rgb values.
  25116. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25117. */
  25118. getAlphaFromRGB: boolean;
  25119. /**
  25120. * Intensity or strength of the texture.
  25121. * It is commonly used by materials to fine tune the intensity of the texture
  25122. */
  25123. level: number;
  25124. /**
  25125. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25126. * This is part of the texture as textures usually maps to one uv set.
  25127. */
  25128. coordinatesIndex: number;
  25129. private _coordinatesMode;
  25130. /**
  25131. * How a texture is mapped.
  25132. *
  25133. * | Value | Type | Description |
  25134. * | ----- | ----------------------------------- | ----------- |
  25135. * | 0 | EXPLICIT_MODE | |
  25136. * | 1 | SPHERICAL_MODE | |
  25137. * | 2 | PLANAR_MODE | |
  25138. * | 3 | CUBIC_MODE | |
  25139. * | 4 | PROJECTION_MODE | |
  25140. * | 5 | SKYBOX_MODE | |
  25141. * | 6 | INVCUBIC_MODE | |
  25142. * | 7 | EQUIRECTANGULAR_MODE | |
  25143. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25144. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25145. */
  25146. coordinatesMode: number;
  25147. /**
  25148. * | Value | Type | Description |
  25149. * | ----- | ------------------ | ----------- |
  25150. * | 0 | CLAMP_ADDRESSMODE | |
  25151. * | 1 | WRAP_ADDRESSMODE | |
  25152. * | 2 | MIRROR_ADDRESSMODE | |
  25153. */
  25154. wrapU: number;
  25155. /**
  25156. * | Value | Type | Description |
  25157. * | ----- | ------------------ | ----------- |
  25158. * | 0 | CLAMP_ADDRESSMODE | |
  25159. * | 1 | WRAP_ADDRESSMODE | |
  25160. * | 2 | MIRROR_ADDRESSMODE | |
  25161. */
  25162. wrapV: number;
  25163. /**
  25164. * | Value | Type | Description |
  25165. * | ----- | ------------------ | ----------- |
  25166. * | 0 | CLAMP_ADDRESSMODE | |
  25167. * | 1 | WRAP_ADDRESSMODE | |
  25168. * | 2 | MIRROR_ADDRESSMODE | |
  25169. */
  25170. wrapR: number;
  25171. /**
  25172. * With compliant hardware and browser (supporting anisotropic filtering)
  25173. * this defines the level of anisotropic filtering in the texture.
  25174. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25175. */
  25176. anisotropicFilteringLevel: number;
  25177. /**
  25178. * Define if the texture is a cube texture or if false a 2d texture.
  25179. */
  25180. isCube: boolean;
  25181. /**
  25182. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25183. */
  25184. is3D: boolean;
  25185. /**
  25186. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25187. * HDR texture are usually stored in linear space.
  25188. * This only impacts the PBR and Background materials
  25189. */
  25190. gammaSpace: boolean;
  25191. /**
  25192. * Gets whether or not the texture contains RGBD data.
  25193. */
  25194. readonly isRGBD: boolean;
  25195. /**
  25196. * Is Z inverted in the texture (useful in a cube texture).
  25197. */
  25198. invertZ: boolean;
  25199. /**
  25200. * Are mip maps generated for this texture or not.
  25201. */
  25202. readonly noMipmap: boolean;
  25203. /**
  25204. * @hidden
  25205. */
  25206. lodLevelInAlpha: boolean;
  25207. /**
  25208. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25209. */
  25210. lodGenerationOffset: number;
  25211. /**
  25212. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25213. */
  25214. lodGenerationScale: number;
  25215. /**
  25216. * Define if the texture is a render target.
  25217. */
  25218. isRenderTarget: boolean;
  25219. /**
  25220. * Define the unique id of the texture in the scene.
  25221. */
  25222. readonly uid: string;
  25223. /**
  25224. * Return a string representation of the texture.
  25225. * @returns the texture as a string
  25226. */
  25227. toString(): string;
  25228. /**
  25229. * Get the class name of the texture.
  25230. * @returns "BaseTexture"
  25231. */
  25232. getClassName(): string;
  25233. /**
  25234. * Define the list of animation attached to the texture.
  25235. */
  25236. animations: Animation[];
  25237. /**
  25238. * An event triggered when the texture is disposed.
  25239. */
  25240. onDisposeObservable: Observable<BaseTexture>;
  25241. private _onDisposeObserver;
  25242. /**
  25243. * Callback triggered when the texture has been disposed.
  25244. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25245. */
  25246. onDispose: () => void;
  25247. /**
  25248. * Define the current state of the loading sequence when in delayed load mode.
  25249. */
  25250. delayLoadState: number;
  25251. private _scene;
  25252. /** @hidden */ texture: Nullable<InternalTexture>;
  25253. private _uid;
  25254. /**
  25255. * Define if the texture is preventinga material to render or not.
  25256. * If not and the texture is not ready, the engine will use a default black texture instead.
  25257. */
  25258. readonly isBlocking: boolean;
  25259. /**
  25260. * Instantiates a new BaseTexture.
  25261. * Base class of all the textures in babylon.
  25262. * It groups all the common properties the materials, post process, lights... might need
  25263. * in order to make a correct use of the texture.
  25264. * @param scene Define the scene the texture blongs to
  25265. */
  25266. constructor(scene: Nullable<Scene>);
  25267. /**
  25268. * Get the scene the texture belongs to.
  25269. * @returns the scene or null if undefined
  25270. */
  25271. getScene(): Nullable<Scene>;
  25272. /**
  25273. * Get the texture transform matrix used to offset tile the texture for istance.
  25274. * @returns the transformation matrix
  25275. */
  25276. getTextureMatrix(): Matrix;
  25277. /**
  25278. * Get the texture reflection matrix used to rotate/transform the reflection.
  25279. * @returns the reflection matrix
  25280. */
  25281. getReflectionTextureMatrix(): Matrix;
  25282. /**
  25283. * Get the underlying lower level texture from Babylon.
  25284. * @returns the insternal texture
  25285. */
  25286. getInternalTexture(): Nullable<InternalTexture>;
  25287. /**
  25288. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25289. * @returns true if ready or not blocking
  25290. */
  25291. isReadyOrNotBlocking(): boolean;
  25292. /**
  25293. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25294. * @returns true if fully ready
  25295. */
  25296. isReady(): boolean;
  25297. private _cachedSize;
  25298. /**
  25299. * Get the size of the texture.
  25300. * @returns the texture size.
  25301. */
  25302. getSize(): ISize;
  25303. /**
  25304. * Get the base size of the texture.
  25305. * It can be different from the size if the texture has been resized for POT for instance
  25306. * @returns the base size
  25307. */
  25308. getBaseSize(): ISize;
  25309. /**
  25310. * Update the sampling mode of the texture.
  25311. * Default is Trilinear mode.
  25312. *
  25313. * | Value | Type | Description |
  25314. * | ----- | ------------------ | ----------- |
  25315. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25316. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25317. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25318. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25319. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25320. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25321. * | 7 | NEAREST_LINEAR | |
  25322. * | 8 | NEAREST_NEAREST | |
  25323. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25324. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25325. * | 11 | LINEAR_LINEAR | |
  25326. * | 12 | LINEAR_NEAREST | |
  25327. *
  25328. * > _mag_: magnification filter (close to the viewer)
  25329. * > _min_: minification filter (far from the viewer)
  25330. * > _mip_: filter used between mip map levels
  25331. *@param samplingMode Define the new sampling mode of the texture
  25332. */
  25333. updateSamplingMode(samplingMode: number): void;
  25334. /**
  25335. * Scales the texture if is `canRescale()`
  25336. * @param ratio the resize factor we want to use to rescale
  25337. */
  25338. scale(ratio: number): void;
  25339. /**
  25340. * Get if the texture can rescale.
  25341. */
  25342. readonly canRescale: boolean;
  25343. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25344. /** @hidden */ rebuild(): void;
  25345. /**
  25346. * Triggers the load sequence in delayed load mode.
  25347. */
  25348. delayLoad(): void;
  25349. /**
  25350. * Clones the texture.
  25351. * @returns the cloned texture
  25352. */
  25353. clone(): Nullable<BaseTexture>;
  25354. /**
  25355. * Get the texture underlying type (INT, FLOAT...)
  25356. */
  25357. readonly textureType: number;
  25358. /**
  25359. * Get the texture underlying format (RGB, RGBA...)
  25360. */
  25361. readonly textureFormat: number;
  25362. /**
  25363. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25364. * This will returns an RGBA array buffer containing either in values (0-255) or
  25365. * float values (0-1) depending of the underlying buffer type.
  25366. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25367. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25368. * @param buffer defines a user defined buffer to fill with data (can be null)
  25369. * @returns The Array buffer containing the pixels data.
  25370. */
  25371. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25372. /**
  25373. * Release and destroy the underlying lower level texture aka internalTexture.
  25374. */
  25375. releaseInternalTexture(): void;
  25376. /**
  25377. * Get the polynomial representation of the texture data.
  25378. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25379. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25380. */
  25381. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25382. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  25383. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  25384. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  25385. /**
  25386. * Dispose the texture and release its associated resources.
  25387. */
  25388. dispose(): void;
  25389. /**
  25390. * Serialize the texture into a JSON representation that can be parsed later on.
  25391. * @returns the JSON representation of the texture
  25392. */
  25393. serialize(): any;
  25394. /**
  25395. * Helper function to be called back once a list of texture contains only ready textures.
  25396. * @param textures Define the list of textures to wait for
  25397. * @param callback Define the callback triggered once the entire list will be ready
  25398. */
  25399. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25400. }
  25401. }
  25402. declare module BABYLON {
  25403. /**
  25404. * Uniform buffer objects.
  25405. *
  25406. * Handles blocks of uniform on the GPU.
  25407. *
  25408. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25409. *
  25410. * For more information, please refer to :
  25411. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25412. */
  25413. export class UniformBuffer {
  25414. private _engine;
  25415. private _buffer;
  25416. private _data;
  25417. private _bufferData;
  25418. private _dynamic?;
  25419. private _uniformLocations;
  25420. private _uniformSizes;
  25421. private _uniformLocationPointer;
  25422. private _needSync;
  25423. private _noUBO;
  25424. private _currentEffect;
  25425. private static _MAX_UNIFORM_SIZE;
  25426. private static _tempBuffer;
  25427. /**
  25428. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25429. * This is dynamic to allow compat with webgl 1 and 2.
  25430. * You will need to pass the name of the uniform as well as the value.
  25431. */
  25432. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25433. /**
  25434. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25435. * This is dynamic to allow compat with webgl 1 and 2.
  25436. * You will need to pass the name of the uniform as well as the value.
  25437. */
  25438. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25439. /**
  25440. * Lambda to Update a single float in a uniform buffer.
  25441. * This is dynamic to allow compat with webgl 1 and 2.
  25442. * You will need to pass the name of the uniform as well as the value.
  25443. */
  25444. updateFloat: (name: string, x: number) => void;
  25445. /**
  25446. * Lambda to Update a vec2 of float in a uniform buffer.
  25447. * This is dynamic to allow compat with webgl 1 and 2.
  25448. * You will need to pass the name of the uniform as well as the value.
  25449. */
  25450. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25451. /**
  25452. * Lambda to Update a vec3 of float in a uniform buffer.
  25453. * This is dynamic to allow compat with webgl 1 and 2.
  25454. * You will need to pass the name of the uniform as well as the value.
  25455. */
  25456. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25457. /**
  25458. * Lambda to Update a vec4 of float in a uniform buffer.
  25459. * This is dynamic to allow compat with webgl 1 and 2.
  25460. * You will need to pass the name of the uniform as well as the value.
  25461. */
  25462. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25463. /**
  25464. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25465. * This is dynamic to allow compat with webgl 1 and 2.
  25466. * You will need to pass the name of the uniform as well as the value.
  25467. */
  25468. updateMatrix: (name: string, mat: Matrix) => void;
  25469. /**
  25470. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25471. * This is dynamic to allow compat with webgl 1 and 2.
  25472. * You will need to pass the name of the uniform as well as the value.
  25473. */
  25474. updateVector3: (name: string, vector: Vector3) => void;
  25475. /**
  25476. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25477. * This is dynamic to allow compat with webgl 1 and 2.
  25478. * You will need to pass the name of the uniform as well as the value.
  25479. */
  25480. updateVector4: (name: string, vector: Vector4) => void;
  25481. /**
  25482. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25483. * This is dynamic to allow compat with webgl 1 and 2.
  25484. * You will need to pass the name of the uniform as well as the value.
  25485. */
  25486. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25487. /**
  25488. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25489. * This is dynamic to allow compat with webgl 1 and 2.
  25490. * You will need to pass the name of the uniform as well as the value.
  25491. */
  25492. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25493. /**
  25494. * Instantiates a new Uniform buffer objects.
  25495. *
  25496. * Handles blocks of uniform on the GPU.
  25497. *
  25498. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25499. *
  25500. * For more information, please refer to :
  25501. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25502. * @param engine Define the engine the buffer is associated with
  25503. * @param data Define the data contained in the buffer
  25504. * @param dynamic Define if the buffer is updatable
  25505. */
  25506. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25507. /**
  25508. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25509. * or just falling back on setUniformXXX calls.
  25510. */
  25511. readonly useUbo: boolean;
  25512. /**
  25513. * Indicates if the WebGL underlying uniform buffer is in sync
  25514. * with the javascript cache data.
  25515. */
  25516. readonly isSync: boolean;
  25517. /**
  25518. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25519. * Also, a dynamic UniformBuffer will disable cache verification and always
  25520. * update the underlying WebGL uniform buffer to the GPU.
  25521. * @returns if Dynamic, otherwise false
  25522. */
  25523. isDynamic(): boolean;
  25524. /**
  25525. * The data cache on JS side.
  25526. * @returns the underlying data as a float array
  25527. */
  25528. getData(): Float32Array;
  25529. /**
  25530. * The underlying WebGL Uniform buffer.
  25531. * @returns the webgl buffer
  25532. */
  25533. getBuffer(): Nullable<WebGLBuffer>;
  25534. /**
  25535. * std140 layout specifies how to align data within an UBO structure.
  25536. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25537. * for specs.
  25538. */
  25539. private _fillAlignment;
  25540. /**
  25541. * Adds an uniform in the buffer.
  25542. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25543. * for the layout to be correct !
  25544. * @param name Name of the uniform, as used in the uniform block in the shader.
  25545. * @param size Data size, or data directly.
  25546. */
  25547. addUniform(name: string, size: number | number[]): void;
  25548. /**
  25549. * Adds a Matrix 4x4 to the uniform buffer.
  25550. * @param name Name of the uniform, as used in the uniform block in the shader.
  25551. * @param mat A 4x4 matrix.
  25552. */
  25553. addMatrix(name: string, mat: Matrix): void;
  25554. /**
  25555. * Adds a vec2 to the uniform buffer.
  25556. * @param name Name of the uniform, as used in the uniform block in the shader.
  25557. * @param x Define the x component value of the vec2
  25558. * @param y Define the y component value of the vec2
  25559. */
  25560. addFloat2(name: string, x: number, y: number): void;
  25561. /**
  25562. * Adds a vec3 to the uniform buffer.
  25563. * @param name Name of the uniform, as used in the uniform block in the shader.
  25564. * @param x Define the x component value of the vec3
  25565. * @param y Define the y component value of the vec3
  25566. * @param z Define the z component value of the vec3
  25567. */
  25568. addFloat3(name: string, x: number, y: number, z: number): void;
  25569. /**
  25570. * Adds a vec3 to the uniform buffer.
  25571. * @param name Name of the uniform, as used in the uniform block in the shader.
  25572. * @param color Define the vec3 from a Color
  25573. */
  25574. addColor3(name: string, color: Color3): void;
  25575. /**
  25576. * Adds a vec4 to the uniform buffer.
  25577. * @param name Name of the uniform, as used in the uniform block in the shader.
  25578. * @param color Define the rgb components from a Color
  25579. * @param alpha Define the a component of the vec4
  25580. */
  25581. addColor4(name: string, color: Color3, alpha: number): void;
  25582. /**
  25583. * Adds a vec3 to the uniform buffer.
  25584. * @param name Name of the uniform, as used in the uniform block in the shader.
  25585. * @param vector Define the vec3 components from a Vector
  25586. */
  25587. addVector3(name: string, vector: Vector3): void;
  25588. /**
  25589. * Adds a Matrix 3x3 to the uniform buffer.
  25590. * @param name Name of the uniform, as used in the uniform block in the shader.
  25591. */
  25592. addMatrix3x3(name: string): void;
  25593. /**
  25594. * Adds a Matrix 2x2 to the uniform buffer.
  25595. * @param name Name of the uniform, as used in the uniform block in the shader.
  25596. */
  25597. addMatrix2x2(name: string): void;
  25598. /**
  25599. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25600. */
  25601. create(): void;
  25602. /** @hidden */ rebuild(): void;
  25603. /**
  25604. * Updates the WebGL Uniform Buffer on the GPU.
  25605. * If the `dynamic` flag is set to true, no cache comparison is done.
  25606. * Otherwise, the buffer will be updated only if the cache differs.
  25607. */
  25608. update(): void;
  25609. /**
  25610. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25611. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25612. * @param data Define the flattened data
  25613. * @param size Define the size of the data.
  25614. */
  25615. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25616. private _updateMatrix3x3ForUniform;
  25617. private _updateMatrix3x3ForEffect;
  25618. private _updateMatrix2x2ForEffect;
  25619. private _updateMatrix2x2ForUniform;
  25620. private _updateFloatForEffect;
  25621. private _updateFloatForUniform;
  25622. private _updateFloat2ForEffect;
  25623. private _updateFloat2ForUniform;
  25624. private _updateFloat3ForEffect;
  25625. private _updateFloat3ForUniform;
  25626. private _updateFloat4ForEffect;
  25627. private _updateFloat4ForUniform;
  25628. private _updateMatrixForEffect;
  25629. private _updateMatrixForUniform;
  25630. private _updateVector3ForEffect;
  25631. private _updateVector3ForUniform;
  25632. private _updateVector4ForEffect;
  25633. private _updateVector4ForUniform;
  25634. private _updateColor3ForEffect;
  25635. private _updateColor3ForUniform;
  25636. private _updateColor4ForEffect;
  25637. private _updateColor4ForUniform;
  25638. /**
  25639. * Sets a sampler uniform on the effect.
  25640. * @param name Define the name of the sampler.
  25641. * @param texture Define the texture to set in the sampler
  25642. */
  25643. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25644. /**
  25645. * Directly updates the value of the uniform in the cache AND on the GPU.
  25646. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25647. * @param data Define the flattened data
  25648. */
  25649. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25650. /**
  25651. * Binds this uniform buffer to an effect.
  25652. * @param effect Define the effect to bind the buffer to
  25653. * @param name Name of the uniform block in the shader.
  25654. */
  25655. bindToEffect(effect: Effect, name: string): void;
  25656. /**
  25657. * Disposes the uniform buffer.
  25658. */
  25659. dispose(): void;
  25660. }
  25661. }
  25662. declare module BABYLON {
  25663. /**
  25664. * This represents the required contract to create a new type of texture loader.
  25665. */
  25666. export interface IInternalTextureLoader {
  25667. /**
  25668. * Defines wether the loader supports cascade loading the different faces.
  25669. */
  25670. supportCascades: boolean;
  25671. /**
  25672. * This returns if the loader support the current file information.
  25673. * @param extension defines the file extension of the file being loaded
  25674. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25675. * @param fallback defines the fallback internal texture if any
  25676. * @param isBase64 defines whether the texture is encoded as a base64
  25677. * @param isBuffer defines whether the texture data are stored as a buffer
  25678. * @returns true if the loader can load the specified file
  25679. */
  25680. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  25681. /**
  25682. * Transform the url before loading if required.
  25683. * @param rootUrl the url of the texture
  25684. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25685. * @returns the transformed texture
  25686. */
  25687. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  25688. /**
  25689. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  25690. * @param rootUrl the url of the texture
  25691. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25692. * @returns the fallback texture
  25693. */
  25694. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  25695. /**
  25696. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  25697. * @param data contains the texture data
  25698. * @param texture defines the BabylonJS internal texture
  25699. * @param createPolynomials will be true if polynomials have been requested
  25700. * @param onLoad defines the callback to trigger once the texture is ready
  25701. * @param onError defines the callback to trigger in case of error
  25702. */
  25703. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  25704. /**
  25705. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  25706. * @param data contains the texture data
  25707. * @param texture defines the BabylonJS internal texture
  25708. * @param callback defines the method to call once ready to upload
  25709. */
  25710. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  25711. }
  25712. }
  25713. declare module BABYLON {
  25714. /**
  25715. * Creation options of the multi render target texture.
  25716. */
  25717. export interface IMultiRenderTargetOptions {
  25718. /**
  25719. * Define if the texture needs to create mip maps after render.
  25720. */
  25721. generateMipMaps?: boolean;
  25722. /**
  25723. * Define the types of all the draw buffers we want to create
  25724. */
  25725. types?: number[];
  25726. /**
  25727. * Define the sampling modes of all the draw buffers we want to create
  25728. */
  25729. samplingModes?: number[];
  25730. /**
  25731. * Define if a depth buffer is required
  25732. */
  25733. generateDepthBuffer?: boolean;
  25734. /**
  25735. * Define if a stencil buffer is required
  25736. */
  25737. generateStencilBuffer?: boolean;
  25738. /**
  25739. * Define if a depth texture is required instead of a depth buffer
  25740. */
  25741. generateDepthTexture?: boolean;
  25742. /**
  25743. * Define the number of desired draw buffers
  25744. */
  25745. textureCount?: number;
  25746. /**
  25747. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25748. */
  25749. doNotChangeAspectRatio?: boolean;
  25750. /**
  25751. * Define the default type of the buffers we are creating
  25752. */
  25753. defaultType?: number;
  25754. }
  25755. /**
  25756. * A multi render target, like a render target provides the ability to render to a texture.
  25757. * Unlike the render target, it can render to several draw buffers in one draw.
  25758. * This is specially interesting in deferred rendering or for any effects requiring more than
  25759. * just one color from a single pass.
  25760. */
  25761. export class MultiRenderTarget extends RenderTargetTexture {
  25762. private _internalTextures;
  25763. private _textures;
  25764. private _multiRenderTargetOptions;
  25765. /**
  25766. * Get if draw buffers are currently supported by the used hardware and browser.
  25767. */
  25768. readonly isSupported: boolean;
  25769. /**
  25770. * Get the list of textures generated by the multi render target.
  25771. */
  25772. readonly textures: Texture[];
  25773. /**
  25774. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25775. */
  25776. readonly depthTexture: Texture;
  25777. /**
  25778. * Set the wrapping mode on U of all the textures we are rendering to.
  25779. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25780. */
  25781. wrapU: number;
  25782. /**
  25783. * Set the wrapping mode on V of all the textures we are rendering to.
  25784. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25785. */
  25786. wrapV: number;
  25787. /**
  25788. * Instantiate a new multi render target texture.
  25789. * A multi render target, like a render target provides the ability to render to a texture.
  25790. * Unlike the render target, it can render to several draw buffers in one draw.
  25791. * This is specially interesting in deferred rendering or for any effects requiring more than
  25792. * just one color from a single pass.
  25793. * @param name Define the name of the texture
  25794. * @param size Define the size of the buffers to render to
  25795. * @param count Define the number of target we are rendering into
  25796. * @param scene Define the scene the texture belongs to
  25797. * @param options Define the options used to create the multi render target
  25798. */
  25799. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25800. /** @hidden */ rebuild(): void;
  25801. private _createInternalTextures;
  25802. private _createTextures;
  25803. /**
  25804. * Define the number of samples used if MSAA is enabled.
  25805. */
  25806. samples: number;
  25807. /**
  25808. * Resize all the textures in the multi render target.
  25809. * Be carrefull as it will recreate all the data in the new texture.
  25810. * @param size Define the new size
  25811. */
  25812. resize(size: any): void;
  25813. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25814. /**
  25815. * Dispose the render targets and their associated resources
  25816. */
  25817. dispose(): void;
  25818. /**
  25819. * Release all the underlying texture used as draw buffers.
  25820. */
  25821. releaseInternalTextures(): void;
  25822. }
  25823. }
  25824. declare module BABYLON {
  25825. /**
  25826. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25828. */
  25829. export class Analyser {
  25830. /**
  25831. * Gets or sets the smoothing
  25832. * @ignorenaming
  25833. */
  25834. SMOOTHING: number;
  25835. /**
  25836. * Gets or sets the FFT table size
  25837. * @ignorenaming
  25838. */
  25839. FFT_SIZE: number;
  25840. /**
  25841. * Gets or sets the bar graph amplitude
  25842. * @ignorenaming
  25843. */
  25844. BARGRAPHAMPLITUDE: number;
  25845. /**
  25846. * Gets or sets the position of the debug canvas
  25847. * @ignorenaming
  25848. */
  25849. DEBUGCANVASPOS: {
  25850. x: number;
  25851. y: number;
  25852. };
  25853. /**
  25854. * Gets or sets the debug canvas size
  25855. * @ignorenaming
  25856. */
  25857. DEBUGCANVASSIZE: {
  25858. width: number;
  25859. height: number;
  25860. };
  25861. private _byteFreqs;
  25862. private _byteTime;
  25863. private _floatFreqs;
  25864. private _webAudioAnalyser;
  25865. private _debugCanvas;
  25866. private _debugCanvasContext;
  25867. private _scene;
  25868. private _registerFunc;
  25869. private _audioEngine;
  25870. /**
  25871. * Creates a new analyser
  25872. * @param scene defines hosting scene
  25873. */
  25874. constructor(scene: Scene);
  25875. /**
  25876. * Get the number of data values you will have to play with for the visualization
  25877. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  25878. * @returns a number
  25879. */
  25880. getFrequencyBinCount(): number;
  25881. /**
  25882. * Gets the current frequency data as a byte array
  25883. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25884. * @returns a Uint8Array
  25885. */
  25886. getByteFrequencyData(): Uint8Array;
  25887. /**
  25888. * Gets the current waveform as a byte array
  25889. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  25890. * @returns a Uint8Array
  25891. */
  25892. getByteTimeDomainData(): Uint8Array;
  25893. /**
  25894. * Gets the current frequency data as a float array
  25895. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25896. * @returns a Float32Array
  25897. */
  25898. getFloatFrequencyData(): Float32Array;
  25899. /**
  25900. * Renders the debug canvas
  25901. */
  25902. drawDebugCanvas(): void;
  25903. /**
  25904. * Stops rendering the debug canvas and removes it
  25905. */
  25906. stopDebugCanvas(): void;
  25907. /**
  25908. * Connects two audio nodes
  25909. * @param inputAudioNode defines first node to connect
  25910. * @param outputAudioNode defines second node to connect
  25911. */
  25912. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  25913. /**
  25914. * Releases all associated resources
  25915. */
  25916. dispose(): void;
  25917. }
  25918. }
  25919. declare module BABYLON {
  25920. /**
  25921. * This represents an audio engine and it is responsible
  25922. * to play, synchronize and analyse sounds throughout the application.
  25923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25924. */
  25925. export interface IAudioEngine extends IDisposable {
  25926. /**
  25927. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25928. */
  25929. readonly canUseWebAudio: boolean;
  25930. /**
  25931. * Gets the current AudioContext if available.
  25932. */
  25933. readonly audioContext: Nullable<AudioContext>;
  25934. /**
  25935. * The master gain node defines the global audio volume of your audio engine.
  25936. */
  25937. readonly masterGain: GainNode;
  25938. /**
  25939. * Gets whether or not mp3 are supported by your browser.
  25940. */
  25941. readonly isMP3supported: boolean;
  25942. /**
  25943. * Gets whether or not ogg are supported by your browser.
  25944. */
  25945. readonly isOGGsupported: boolean;
  25946. /**
  25947. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25948. * @ignoreNaming
  25949. */
  25950. WarnedWebAudioUnsupported: boolean;
  25951. /**
  25952. * Defines if the audio engine relies on a custom unlocked button.
  25953. * In this case, the embedded button will not be displayed.
  25954. */
  25955. useCustomUnlockedButton: boolean;
  25956. /**
  25957. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  25958. */
  25959. readonly unlocked: boolean;
  25960. /**
  25961. * Event raised when audio has been unlocked on the browser.
  25962. */
  25963. onAudioUnlockedObservable: Observable<AudioEngine>;
  25964. /**
  25965. * Event raised when audio has been locked on the browser.
  25966. */
  25967. onAudioLockedObservable: Observable<AudioEngine>;
  25968. /**
  25969. * Flags the audio engine in Locked state.
  25970. * This happens due to new browser policies preventing audio to autoplay.
  25971. */
  25972. lock(): void;
  25973. /**
  25974. * Unlocks the audio engine once a user action has been done on the dom.
  25975. * This is helpful to resume play once browser policies have been satisfied.
  25976. */
  25977. unlock(): void;
  25978. }
  25979. /**
  25980. * This represents the default audio engine used in babylon.
  25981. * It is responsible to play, synchronize and analyse sounds throughout the application.
  25982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25983. */
  25984. export class AudioEngine implements IAudioEngine {
  25985. private _audioContext;
  25986. private _audioContextInitialized;
  25987. private _muteButton;
  25988. private _hostElement;
  25989. /**
  25990. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25991. */
  25992. canUseWebAudio: boolean;
  25993. /**
  25994. * The master gain node defines the global audio volume of your audio engine.
  25995. */
  25996. masterGain: GainNode;
  25997. /**
  25998. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25999. * @ignoreNaming
  26000. */
  26001. WarnedWebAudioUnsupported: boolean;
  26002. /**
  26003. * Gets whether or not mp3 are supported by your browser.
  26004. */
  26005. isMP3supported: boolean;
  26006. /**
  26007. * Gets whether or not ogg are supported by your browser.
  26008. */
  26009. isOGGsupported: boolean;
  26010. /**
  26011. * Gets whether audio has been unlocked on the device.
  26012. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26013. * a user interaction has happened.
  26014. */
  26015. unlocked: boolean;
  26016. /**
  26017. * Defines if the audio engine relies on a custom unlocked button.
  26018. * In this case, the embedded button will not be displayed.
  26019. */
  26020. useCustomUnlockedButton: boolean;
  26021. /**
  26022. * Event raised when audio has been unlocked on the browser.
  26023. */
  26024. onAudioUnlockedObservable: Observable<AudioEngine>;
  26025. /**
  26026. * Event raised when audio has been locked on the browser.
  26027. */
  26028. onAudioLockedObservable: Observable<AudioEngine>;
  26029. /**
  26030. * Gets the current AudioContext if available.
  26031. */
  26032. readonly audioContext: Nullable<AudioContext>;
  26033. private _connectedAnalyser;
  26034. /**
  26035. * Instantiates a new audio engine.
  26036. *
  26037. * There should be only one per page as some browsers restrict the number
  26038. * of audio contexts you can create.
  26039. * @param hostElement defines the host element where to display the mute icon if necessary
  26040. */
  26041. constructor(hostElement?: Nullable<HTMLElement>);
  26042. /**
  26043. * Flags the audio engine in Locked state.
  26044. * This happens due to new browser policies preventing audio to autoplay.
  26045. */
  26046. lock(): void;
  26047. /**
  26048. * Unlocks the audio engine once a user action has been done on the dom.
  26049. * This is helpful to resume play once browser policies have been satisfied.
  26050. */
  26051. unlock(): void;
  26052. private _resumeAudioContext;
  26053. private _initializeAudioContext;
  26054. private _tryToRun;
  26055. private _triggerRunningState;
  26056. private _triggerSuspendedState;
  26057. private _displayMuteButton;
  26058. private _moveButtonToTopLeft;
  26059. private _onResize;
  26060. private _hideMuteButton;
  26061. /**
  26062. * Destroy and release the resources associated with the audio ccontext.
  26063. */
  26064. dispose(): void;
  26065. /**
  26066. * Gets the global volume sets on the master gain.
  26067. * @returns the global volume if set or -1 otherwise
  26068. */
  26069. getGlobalVolume(): number;
  26070. /**
  26071. * Sets the global volume of your experience (sets on the master gain).
  26072. * @param newVolume Defines the new global volume of the application
  26073. */
  26074. setGlobalVolume(newVolume: number): void;
  26075. /**
  26076. * Connect the audio engine to an audio analyser allowing some amazing
  26077. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26079. * @param analyser The analyser to connect to the engine
  26080. */
  26081. connectToAnalyser(analyser: Analyser): void;
  26082. }
  26083. }
  26084. declare module BABYLON {
  26085. /**
  26086. * Interface used to present a loading screen while loading a scene
  26087. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26088. */
  26089. export interface ILoadingScreen {
  26090. /**
  26091. * Function called to display the loading screen
  26092. */
  26093. displayLoadingUI: () => void;
  26094. /**
  26095. * Function called to hide the loading screen
  26096. */
  26097. hideLoadingUI: () => void;
  26098. /**
  26099. * Gets or sets the color to use for the background
  26100. */
  26101. loadingUIBackgroundColor: string;
  26102. /**
  26103. * Gets or sets the text to display while loading
  26104. */
  26105. loadingUIText: string;
  26106. }
  26107. /**
  26108. * Class used for the default loading screen
  26109. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26110. */
  26111. export class DefaultLoadingScreen implements ILoadingScreen {
  26112. private _renderingCanvas;
  26113. private _loadingText;
  26114. private _loadingDivBackgroundColor;
  26115. private _loadingDiv;
  26116. private _loadingTextDiv;
  26117. /**
  26118. * Creates a new default loading screen
  26119. * @param _renderingCanvas defines the canvas used to render the scene
  26120. * @param _loadingText defines the default text to display
  26121. * @param _loadingDivBackgroundColor defines the default background color
  26122. */
  26123. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26124. /**
  26125. * Function called to display the loading screen
  26126. */
  26127. displayLoadingUI(): void;
  26128. /**
  26129. * Function called to hide the loading screen
  26130. */
  26131. hideLoadingUI(): void;
  26132. /**
  26133. * Gets or sets the text to display while loading
  26134. */
  26135. loadingUIText: string;
  26136. /**
  26137. * Gets or sets the color to use for the background
  26138. */
  26139. loadingUIBackgroundColor: string;
  26140. private _resizeLoadingUI;
  26141. }
  26142. }
  26143. declare module BABYLON {
  26144. /**
  26145. * Settings for finer control over video usage
  26146. */
  26147. export interface VideoTextureSettings {
  26148. /**
  26149. * Applies `autoplay` to video, if specified
  26150. */
  26151. autoPlay?: boolean;
  26152. /**
  26153. * Applies `loop` to video, if specified
  26154. */
  26155. loop?: boolean;
  26156. /**
  26157. * Automatically updates internal texture from video at every frame in the render loop
  26158. */
  26159. autoUpdateTexture: boolean;
  26160. /**
  26161. * Image src displayed during the video loading or until the user interacts with the video.
  26162. */
  26163. poster?: string;
  26164. }
  26165. /**
  26166. * If you want to display a video in your scene, this is the special texture for that.
  26167. * This special texture works similar to other textures, with the exception of a few parameters.
  26168. * @see https://doc.babylonjs.com/how_to/video_texture
  26169. */
  26170. export class VideoTexture extends Texture {
  26171. /**
  26172. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26173. */
  26174. readonly autoUpdateTexture: boolean;
  26175. /**
  26176. * The video instance used by the texture internally
  26177. */
  26178. readonly video: HTMLVideoElement;
  26179. private _onUserActionRequestedObservable;
  26180. /**
  26181. * Event triggerd when a dom action is required by the user to play the video.
  26182. * This happens due to recent changes in browser policies preventing video to auto start.
  26183. */
  26184. readonly onUserActionRequestedObservable: Observable<Texture>;
  26185. private _generateMipMaps;
  26186. private _engine;
  26187. private _stillImageCaptured;
  26188. private _displayingPosterTexture;
  26189. private _settings;
  26190. private _createInternalTextureOnEvent;
  26191. /**
  26192. * Creates a video texture.
  26193. * If you want to display a video in your scene, this is the special texture for that.
  26194. * This special texture works similar to other textures, with the exception of a few parameters.
  26195. * @see https://doc.babylonjs.com/how_to/video_texture
  26196. * @param name optional name, will detect from video source, if not defined
  26197. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26198. * @param scene is obviously the current scene.
  26199. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26200. * @param invertY is false by default but can be used to invert video on Y axis
  26201. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26202. * @param settings allows finer control over video usage
  26203. */
  26204. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26205. private _getName;
  26206. private _getVideo;
  26207. private _createInternalTexture;
  26208. private reset;
  26209. /**
  26210. * @hidden Internal method to initiate `update`.
  26211. */ rebuild(): void;
  26212. /**
  26213. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26214. */
  26215. update(): void;
  26216. /**
  26217. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26218. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26219. */
  26220. updateTexture(isVisible: boolean): void;
  26221. protected _updateInternalTexture: () => void;
  26222. /**
  26223. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26224. * @param url New url.
  26225. */
  26226. updateURL(url: string): void;
  26227. /**
  26228. * Dispose the texture and release its associated resources.
  26229. */
  26230. dispose(): void;
  26231. /**
  26232. * Creates a video texture straight from a stream.
  26233. * @param scene Define the scene the texture should be created in
  26234. * @param stream Define the stream the texture should be created from
  26235. * @returns The created video texture as a promise
  26236. */
  26237. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26238. /**
  26239. * Creates a video texture straight from your WebCam video feed.
  26240. * @param scene Define the scene the texture should be created in
  26241. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26242. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26243. * @returns The created video texture as a promise
  26244. */
  26245. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26246. minWidth: number;
  26247. maxWidth: number;
  26248. minHeight: number;
  26249. maxHeight: number;
  26250. deviceId: string;
  26251. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26252. /**
  26253. * Creates a video texture straight from your WebCam video feed.
  26254. * @param scene Define the scene the texture should be created in
  26255. * @param onReady Define a callback to triggered once the texture will be ready
  26256. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26257. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26258. */
  26259. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26260. minWidth: number;
  26261. maxWidth: number;
  26262. minHeight: number;
  26263. maxHeight: number;
  26264. deviceId: string;
  26265. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26266. }
  26267. }
  26268. declare module BABYLON {
  26269. /**
  26270. * Interface for attribute information associated with buffer instanciation
  26271. */
  26272. export class InstancingAttributeInfo {
  26273. /**
  26274. * Index/offset of the attribute in the vertex shader
  26275. */
  26276. index: number;
  26277. /**
  26278. * size of the attribute, 1, 2, 3 or 4
  26279. */
  26280. attributeSize: number;
  26281. /**
  26282. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26283. * default is FLOAT
  26284. */
  26285. attribyteType: number;
  26286. /**
  26287. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26288. */
  26289. normalized: boolean;
  26290. /**
  26291. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26292. */
  26293. offset: number;
  26294. /**
  26295. * Name of the GLSL attribute, for debugging purpose only
  26296. */
  26297. attributeName: string;
  26298. }
  26299. /**
  26300. * Define options used to create a depth texture
  26301. */
  26302. export class DepthTextureCreationOptions {
  26303. /** Specifies whether or not a stencil should be allocated in the texture */
  26304. generateStencil?: boolean;
  26305. /** Specifies whether or not bilinear filtering is enable on the texture */
  26306. bilinearFiltering?: boolean;
  26307. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26308. comparisonFunction?: number;
  26309. /** Specifies if the created texture is a cube texture */
  26310. isCube?: boolean;
  26311. }
  26312. /**
  26313. * Class used to describe the capabilities of the engine relatively to the current browser
  26314. */
  26315. export class EngineCapabilities {
  26316. /** Maximum textures units per fragment shader */
  26317. maxTexturesImageUnits: number;
  26318. /** Maximum texture units per vertex shader */
  26319. maxVertexTextureImageUnits: number;
  26320. /** Maximum textures units in the entire pipeline */
  26321. maxCombinedTexturesImageUnits: number;
  26322. /** Maximum texture size */
  26323. maxTextureSize: number;
  26324. /** Maximum cube texture size */
  26325. maxCubemapTextureSize: number;
  26326. /** Maximum render texture size */
  26327. maxRenderTextureSize: number;
  26328. /** Maximum number of vertex attributes */
  26329. maxVertexAttribs: number;
  26330. /** Maximum number of varyings */
  26331. maxVaryingVectors: number;
  26332. /** Maximum number of uniforms per vertex shader */
  26333. maxVertexUniformVectors: number;
  26334. /** Maximum number of uniforms per fragment shader */
  26335. maxFragmentUniformVectors: number;
  26336. /** Defines if standard derivates (dx/dy) are supported */
  26337. standardDerivatives: boolean;
  26338. /** Defines if s3tc texture compression is supported */
  26339. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26340. /** Defines if pvrtc texture compression is supported */
  26341. pvrtc: any;
  26342. /** Defines if etc1 texture compression is supported */
  26343. etc1: any;
  26344. /** Defines if etc2 texture compression is supported */
  26345. etc2: any;
  26346. /** Defines if astc texture compression is supported */
  26347. astc: any;
  26348. /** Defines if float textures are supported */
  26349. textureFloat: boolean;
  26350. /** Defines if vertex array objects are supported */
  26351. vertexArrayObject: boolean;
  26352. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26353. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26354. /** Gets the maximum level of anisotropy supported */
  26355. maxAnisotropy: number;
  26356. /** Defines if instancing is supported */
  26357. instancedArrays: boolean;
  26358. /** Defines if 32 bits indices are supported */
  26359. uintIndices: boolean;
  26360. /** Defines if high precision shaders are supported */
  26361. highPrecisionShaderSupported: boolean;
  26362. /** Defines if depth reading in the fragment shader is supported */
  26363. fragmentDepthSupported: boolean;
  26364. /** Defines if float texture linear filtering is supported*/
  26365. textureFloatLinearFiltering: boolean;
  26366. /** Defines if rendering to float textures is supported */
  26367. textureFloatRender: boolean;
  26368. /** Defines if half float textures are supported*/
  26369. textureHalfFloat: boolean;
  26370. /** Defines if half float texture linear filtering is supported*/
  26371. textureHalfFloatLinearFiltering: boolean;
  26372. /** Defines if rendering to half float textures is supported */
  26373. textureHalfFloatRender: boolean;
  26374. /** Defines if textureLOD shader command is supported */
  26375. textureLOD: boolean;
  26376. /** Defines if draw buffers extension is supported */
  26377. drawBuffersExtension: boolean;
  26378. /** Defines if depth textures are supported */
  26379. depthTextureExtension: boolean;
  26380. /** Defines if float color buffer are supported */
  26381. colorBufferFloat: boolean;
  26382. /** Gets disjoint timer query extension (null if not supported) */
  26383. timerQuery: EXT_disjoint_timer_query;
  26384. /** Defines if timestamp can be used with timer query */
  26385. canUseTimestampForTimerQuery: boolean;
  26386. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26387. multiview: any;
  26388. /** Function used to let the system compiles shaders in background */
  26389. parallelShaderCompile: {
  26390. COMPLETION_STATUS_KHR: number;
  26391. };
  26392. }
  26393. /** Interface defining initialization parameters for Engine class */
  26394. export interface EngineOptions extends WebGLContextAttributes {
  26395. /**
  26396. * Defines if the engine should no exceed a specified device ratio
  26397. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26398. */
  26399. limitDeviceRatio?: number;
  26400. /**
  26401. * Defines if webvr should be enabled automatically
  26402. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26403. */
  26404. autoEnableWebVR?: boolean;
  26405. /**
  26406. * Defines if webgl2 should be turned off even if supported
  26407. * @see http://doc.babylonjs.com/features/webgl2
  26408. */
  26409. disableWebGL2Support?: boolean;
  26410. /**
  26411. * Defines if webaudio should be initialized as well
  26412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26413. */
  26414. audioEngine?: boolean;
  26415. /**
  26416. * Defines if animations should run using a deterministic lock step
  26417. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26418. */
  26419. deterministicLockstep?: boolean;
  26420. /** Defines the maximum steps to use with deterministic lock step mode */
  26421. lockstepMaxSteps?: number;
  26422. /**
  26423. * Defines that engine should ignore context lost events
  26424. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26425. */
  26426. doNotHandleContextLost?: boolean;
  26427. /**
  26428. * Defines that engine should ignore modifying touch action attribute and style
  26429. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26430. */
  26431. doNotHandleTouchAction?: boolean;
  26432. /**
  26433. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26434. */
  26435. useHighPrecisionFloats?: boolean;
  26436. }
  26437. /**
  26438. * Defines the interface used by display changed events
  26439. */
  26440. export interface IDisplayChangedEventArgs {
  26441. /** Gets the vrDisplay object (if any) */
  26442. vrDisplay: Nullable<any>;
  26443. /** Gets a boolean indicating if webVR is supported */
  26444. vrSupported: boolean;
  26445. }
  26446. /**
  26447. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26448. */
  26449. export class Engine {
  26450. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26451. static ExceptionList: ({
  26452. key: string;
  26453. capture: string;
  26454. captureConstraint: number;
  26455. targets: string[];
  26456. } | {
  26457. key: string;
  26458. capture: null;
  26459. captureConstraint: null;
  26460. targets: string[];
  26461. })[];
  26462. /** Gets the list of created engines */
  26463. static readonly Instances: Engine[];
  26464. /**
  26465. * Gets the latest created engine
  26466. */
  26467. static readonly LastCreatedEngine: Nullable<Engine>;
  26468. /**
  26469. * Gets the latest created scene
  26470. */
  26471. static readonly LastCreatedScene: Nullable<Scene>;
  26472. /**
  26473. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26474. * @param flag defines which part of the materials must be marked as dirty
  26475. * @param predicate defines a predicate used to filter which materials should be affected
  26476. */
  26477. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26478. /**
  26479. * Hidden
  26480. */ private static _TextureLoaders: IInternalTextureLoader[];
  26481. /** Defines that alpha blending is disabled */
  26482. static readonly ALPHA_DISABLE: number;
  26483. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26484. static readonly ALPHA_ADD: number;
  26485. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26486. static readonly ALPHA_COMBINE: number;
  26487. /** Defines that alpha blending to DEST - SRC * DEST */
  26488. static readonly ALPHA_SUBTRACT: number;
  26489. /** Defines that alpha blending to SRC * DEST */
  26490. static readonly ALPHA_MULTIPLY: number;
  26491. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26492. static readonly ALPHA_MAXIMIZED: number;
  26493. /** Defines that alpha blending to SRC + DEST */
  26494. static readonly ALPHA_ONEONE: number;
  26495. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26496. static readonly ALPHA_PREMULTIPLIED: number;
  26497. /**
  26498. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26499. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26500. */
  26501. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26502. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26503. static readonly ALPHA_INTERPOLATE: number;
  26504. /**
  26505. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26506. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26507. */
  26508. static readonly ALPHA_SCREENMODE: number;
  26509. /** Defines that the ressource is not delayed*/
  26510. static readonly DELAYLOADSTATE_NONE: number;
  26511. /** Defines that the ressource was successfully delay loaded */
  26512. static readonly DELAYLOADSTATE_LOADED: number;
  26513. /** Defines that the ressource is currently delay loading */
  26514. static readonly DELAYLOADSTATE_LOADING: number;
  26515. /** Defines that the ressource is delayed and has not started loading */
  26516. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26517. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26518. static readonly NEVER: number;
  26519. /** 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 */
  26520. static readonly ALWAYS: number;
  26521. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26522. static readonly LESS: number;
  26523. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26524. static readonly EQUAL: number;
  26525. /** 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 */
  26526. static readonly LEQUAL: number;
  26527. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26528. static readonly GREATER: number;
  26529. /** 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 */
  26530. static readonly GEQUAL: number;
  26531. /** 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 */
  26532. static readonly NOTEQUAL: number;
  26533. /** Passed to stencilOperation to specify that stencil value must be kept */
  26534. static readonly KEEP: number;
  26535. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26536. static readonly REPLACE: number;
  26537. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26538. static readonly INCR: number;
  26539. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26540. static readonly DECR: number;
  26541. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26542. static readonly INVERT: number;
  26543. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26544. static readonly INCR_WRAP: number;
  26545. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26546. static readonly DECR_WRAP: number;
  26547. /** Texture is not repeating outside of 0..1 UVs */
  26548. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26549. /** Texture is repeating outside of 0..1 UVs */
  26550. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26551. /** Texture is repeating and mirrored */
  26552. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26553. /** ALPHA */
  26554. static readonly TEXTUREFORMAT_ALPHA: number;
  26555. /** LUMINANCE */
  26556. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26557. /** LUMINANCE_ALPHA */
  26558. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26559. /** RGB */
  26560. static readonly TEXTUREFORMAT_RGB: number;
  26561. /** RGBA */
  26562. static readonly TEXTUREFORMAT_RGBA: number;
  26563. /** RED */
  26564. static readonly TEXTUREFORMAT_RED: number;
  26565. /** RED (2nd reference) */
  26566. static readonly TEXTUREFORMAT_R: number;
  26567. /** RG */
  26568. static readonly TEXTUREFORMAT_RG: number;
  26569. /** RED_INTEGER */
  26570. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26571. /** RED_INTEGER (2nd reference) */
  26572. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26573. /** RG_INTEGER */
  26574. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26575. /** RGB_INTEGER */
  26576. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26577. /** RGBA_INTEGER */
  26578. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26579. /** UNSIGNED_BYTE */
  26580. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26581. /** UNSIGNED_BYTE (2nd reference) */
  26582. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26583. /** FLOAT */
  26584. static readonly TEXTURETYPE_FLOAT: number;
  26585. /** HALF_FLOAT */
  26586. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26587. /** BYTE */
  26588. static readonly TEXTURETYPE_BYTE: number;
  26589. /** SHORT */
  26590. static readonly TEXTURETYPE_SHORT: number;
  26591. /** UNSIGNED_SHORT */
  26592. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26593. /** INT */
  26594. static readonly TEXTURETYPE_INT: number;
  26595. /** UNSIGNED_INT */
  26596. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26597. /** UNSIGNED_SHORT_4_4_4_4 */
  26598. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26599. /** UNSIGNED_SHORT_5_5_5_1 */
  26600. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26601. /** UNSIGNED_SHORT_5_6_5 */
  26602. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26603. /** UNSIGNED_INT_2_10_10_10_REV */
  26604. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26605. /** UNSIGNED_INT_24_8 */
  26606. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26607. /** UNSIGNED_INT_10F_11F_11F_REV */
  26608. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26609. /** UNSIGNED_INT_5_9_9_9_REV */
  26610. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26611. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26612. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26613. /** nearest is mag = nearest and min = nearest and mip = linear */
  26614. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26615. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26616. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26617. /** Trilinear is mag = linear and min = linear and mip = linear */
  26618. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26619. /** nearest is mag = nearest and min = nearest and mip = linear */
  26620. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26621. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26622. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26623. /** Trilinear is mag = linear and min = linear and mip = linear */
  26624. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26625. /** mag = nearest and min = nearest and mip = nearest */
  26626. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26627. /** mag = nearest and min = linear and mip = nearest */
  26628. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26629. /** mag = nearest and min = linear and mip = linear */
  26630. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26631. /** mag = nearest and min = linear and mip = none */
  26632. static readonly TEXTURE_NEAREST_LINEAR: number;
  26633. /** mag = nearest and min = nearest and mip = none */
  26634. static readonly TEXTURE_NEAREST_NEAREST: number;
  26635. /** mag = linear and min = nearest and mip = nearest */
  26636. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26637. /** mag = linear and min = nearest and mip = linear */
  26638. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26639. /** mag = linear and min = linear and mip = none */
  26640. static readonly TEXTURE_LINEAR_LINEAR: number;
  26641. /** mag = linear and min = nearest and mip = none */
  26642. static readonly TEXTURE_LINEAR_NEAREST: number;
  26643. /** Explicit coordinates mode */
  26644. static readonly TEXTURE_EXPLICIT_MODE: number;
  26645. /** Spherical coordinates mode */
  26646. static readonly TEXTURE_SPHERICAL_MODE: number;
  26647. /** Planar coordinates mode */
  26648. static readonly TEXTURE_PLANAR_MODE: number;
  26649. /** Cubic coordinates mode */
  26650. static readonly TEXTURE_CUBIC_MODE: number;
  26651. /** Projection coordinates mode */
  26652. static readonly TEXTURE_PROJECTION_MODE: number;
  26653. /** Skybox coordinates mode */
  26654. static readonly TEXTURE_SKYBOX_MODE: number;
  26655. /** Inverse Cubic coordinates mode */
  26656. static readonly TEXTURE_INVCUBIC_MODE: number;
  26657. /** Equirectangular coordinates mode */
  26658. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26659. /** Equirectangular Fixed coordinates mode */
  26660. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26661. /** Equirectangular Fixed Mirrored coordinates mode */
  26662. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26663. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26664. static readonly SCALEMODE_FLOOR: number;
  26665. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26666. static readonly SCALEMODE_NEAREST: number;
  26667. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26668. static readonly SCALEMODE_CEILING: number;
  26669. /**
  26670. * Returns the current npm package of the sdk
  26671. */
  26672. static readonly NpmPackage: string;
  26673. /**
  26674. * Returns the current version of the framework
  26675. */
  26676. static readonly Version: string;
  26677. /**
  26678. * Returns a string describing the current engine
  26679. */
  26680. readonly description: string;
  26681. /**
  26682. * Gets or sets the epsilon value used by collision engine
  26683. */
  26684. static CollisionsEpsilon: number;
  26685. /**
  26686. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26687. */
  26688. static ShadersRepository: string;
  26689. /**
  26690. * Method called to create the default loading screen.
  26691. * This can be overriden in your own app.
  26692. * @param canvas The rendering canvas element
  26693. * @returns The loading screen
  26694. */
  26695. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26696. /**
  26697. * Method called to create the default rescale post process on each engine.
  26698. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26699. /**
  26700. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26701. */
  26702. forcePOTTextures: boolean;
  26703. /**
  26704. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26705. */
  26706. isFullscreen: boolean;
  26707. /**
  26708. * Gets a boolean indicating if the pointer is currently locked
  26709. */
  26710. isPointerLock: boolean;
  26711. /**
  26712. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26713. */
  26714. cullBackFaces: boolean;
  26715. /**
  26716. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26717. */
  26718. renderEvenInBackground: boolean;
  26719. /**
  26720. * Gets or sets a boolean indicating that cache can be kept between frames
  26721. */
  26722. preventCacheWipeBetweenFrames: boolean;
  26723. /**
  26724. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26725. **/
  26726. enableOfflineSupport: boolean;
  26727. /**
  26728. * 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)
  26729. **/
  26730. disableManifestCheck: boolean;
  26731. /**
  26732. * Gets the list of created scenes
  26733. */
  26734. scenes: Scene[];
  26735. /**
  26736. * Event raised when a new scene is created
  26737. */
  26738. onNewSceneAddedObservable: Observable<Scene>;
  26739. /**
  26740. * Gets the list of created postprocesses
  26741. */
  26742. postProcesses: PostProcess[];
  26743. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26744. validateShaderPrograms: boolean;
  26745. /**
  26746. * Observable event triggered each time the rendering canvas is resized
  26747. */
  26748. onResizeObservable: Observable<Engine>;
  26749. /**
  26750. * Observable event triggered each time the canvas loses focus
  26751. */
  26752. onCanvasBlurObservable: Observable<Engine>;
  26753. /**
  26754. * Observable event triggered each time the canvas gains focus
  26755. */
  26756. onCanvasFocusObservable: Observable<Engine>;
  26757. /**
  26758. * Observable event triggered each time the canvas receives pointerout event
  26759. */
  26760. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26761. /**
  26762. * Observable event triggered before each texture is initialized
  26763. */
  26764. onBeforeTextureInitObservable: Observable<Texture>;
  26765. private _vrDisplay;
  26766. private _vrSupported;
  26767. private _oldSize;
  26768. private _oldHardwareScaleFactor;
  26769. private _vrExclusivePointerMode;
  26770. private _webVRInitPromise;
  26771. /**
  26772. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26773. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26774. */
  26775. readonly isInVRExclusivePointerMode: boolean;
  26776. /**
  26777. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26778. */
  26779. disableUniformBuffers: boolean;
  26780. /** @hidden */ uniformBuffers: UniformBuffer[];
  26781. /**
  26782. * Gets a boolean indicating that the engine supports uniform buffers
  26783. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26784. */
  26785. readonly supportsUniformBuffers: boolean;
  26786. /**
  26787. * Observable raised when the engine begins a new frame
  26788. */
  26789. onBeginFrameObservable: Observable<Engine>;
  26790. /**
  26791. * If set, will be used to request the next animation frame for the render loop
  26792. */
  26793. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26794. /**
  26795. * Observable raised when the engine ends the current frame
  26796. */
  26797. onEndFrameObservable: Observable<Engine>;
  26798. /**
  26799. * Observable raised when the engine is about to compile a shader
  26800. */
  26801. onBeforeShaderCompilationObservable: Observable<Engine>;
  26802. /**
  26803. * Observable raised when the engine has jsut compiled a shader
  26804. */
  26805. onAfterShaderCompilationObservable: Observable<Engine>;
  26806. /** @hidden */ gl: WebGLRenderingContext;
  26807. private _renderingCanvas;
  26808. private _windowIsBackground;
  26809. private _webGLVersion;
  26810. protected _highPrecisionShadersAllowed: boolean;
  26811. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  26812. /**
  26813. * Gets a boolean indicating that only power of 2 textures are supported
  26814. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26815. */
  26816. readonly needPOTTextures: boolean;
  26817. /** @hidden */ badOS: boolean;
  26818. /** @hidden */ badDesktopOS: boolean;
  26819. /**
  26820. * Gets the audio engine
  26821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26822. * @ignorenaming
  26823. */
  26824. static audioEngine: IAudioEngine;
  26825. /**
  26826. * Default AudioEngine factory responsible of creating the Audio Engine.
  26827. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26828. */
  26829. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  26830. /**
  26831. * Default offline support factory responsible of creating a tool used to store data locally.
  26832. * By default, this will create a Database object if the workload has been embedded.
  26833. */
  26834. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  26835. private _onFocus;
  26836. private _onBlur;
  26837. private _onCanvasPointerOut;
  26838. private _onCanvasBlur;
  26839. private _onCanvasFocus;
  26840. private _onFullscreenChange;
  26841. private _onPointerLockChange;
  26842. private _onVRDisplayPointerRestricted;
  26843. private _onVRDisplayPointerUnrestricted;
  26844. private _onVrDisplayConnect;
  26845. private _onVrDisplayDisconnect;
  26846. private _onVrDisplayPresentChange;
  26847. /**
  26848. * Observable signaled when VR display mode changes
  26849. */
  26850. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26851. /**
  26852. * Observable signaled when VR request present is complete
  26853. */
  26854. onVRRequestPresentComplete: Observable<boolean>;
  26855. /**
  26856. * Observable signaled when VR request present starts
  26857. */
  26858. onVRRequestPresentStart: Observable<Engine>;
  26859. private _hardwareScalingLevel;
  26860. /** @hidden */
  26861. protected _caps: EngineCapabilities;
  26862. private _pointerLockRequested;
  26863. private _isStencilEnable;
  26864. private _colorWrite;
  26865. private _loadingScreen;
  26866. /** @hidden */ drawCalls: PerfCounter;
  26867. private _glVersion;
  26868. private _glRenderer;
  26869. private _glVendor;
  26870. private _videoTextureSupported;
  26871. private _renderingQueueLaunched;
  26872. private _activeRenderLoops;
  26873. private _deterministicLockstep;
  26874. private _lockstepMaxSteps;
  26875. /**
  26876. * Observable signaled when a context lost event is raised
  26877. */
  26878. onContextLostObservable: Observable<Engine>;
  26879. /**
  26880. * Observable signaled when a context restored event is raised
  26881. */
  26882. onContextRestoredObservable: Observable<Engine>;
  26883. private _onContextLost;
  26884. private _onContextRestored;
  26885. private _contextWasLost;
  26886. private _doNotHandleContextLost;
  26887. /**
  26888. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  26889. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  26890. */
  26891. doNotHandleContextLost: boolean;
  26892. private _performanceMonitor;
  26893. private _fps;
  26894. private _deltaTime;
  26895. /**
  26896. * Turn this value on if you want to pause FPS computation when in background
  26897. */
  26898. disablePerformanceMonitorInBackground: boolean;
  26899. /**
  26900. * Gets the performance monitor attached to this engine
  26901. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  26902. */
  26903. readonly performanceMonitor: PerformanceMonitor;
  26904. /**
  26905. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  26906. */
  26907. disableVertexArrayObjects: boolean;
  26908. /** @hidden */
  26909. protected _depthCullingState: _DepthCullingState;
  26910. /** @hidden */
  26911. protected _stencilState: _StencilState;
  26912. /** @hidden */
  26913. protected _alphaState: _AlphaState;
  26914. /** @hidden */
  26915. protected _alphaMode: number;
  26916. protected _internalTexturesCache: InternalTexture[];
  26917. /** @hidden */
  26918. protected _activeChannel: number;
  26919. private _currentTextureChannel;
  26920. /** @hidden */
  26921. protected _boundTexturesCache: {
  26922. [key: string]: Nullable<InternalTexture>;
  26923. };
  26924. /** @hidden */
  26925. protected _currentEffect: Nullable<Effect>;
  26926. /** @hidden */
  26927. protected _currentProgram: Nullable<WebGLProgram>;
  26928. private _compiledEffects;
  26929. private _vertexAttribArraysEnabled;
  26930. /** @hidden */
  26931. protected _cachedViewport: Nullable<Viewport>;
  26932. private _cachedVertexArrayObject;
  26933. /** @hidden */
  26934. protected _cachedVertexBuffers: any;
  26935. /** @hidden */
  26936. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  26937. /** @hidden */
  26938. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  26939. /** @hidden */
  26940. protected _currentRenderTarget: Nullable<InternalTexture>;
  26941. private _uintIndicesCurrentlySet;
  26942. private _currentBoundBuffer;
  26943. /** @hidden */
  26944. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  26945. private _currentBufferPointers;
  26946. private _currentInstanceLocations;
  26947. private _currentInstanceBuffers;
  26948. private _textureUnits;
  26949. private _workingCanvas;
  26950. private _workingContext;
  26951. private _rescalePostProcess;
  26952. private _dummyFramebuffer;
  26953. private _externalData;
  26954. private _bindedRenderFunction;
  26955. private _vaoRecordInProgress;
  26956. private _mustWipeVertexAttributes;
  26957. private _emptyTexture;
  26958. private _emptyCubeTexture;
  26959. private _emptyTexture3D;
  26960. /** @hidden */ frameHandler: number;
  26961. private _nextFreeTextureSlots;
  26962. private _maxSimultaneousTextures;
  26963. private _activeRequests;
  26964. private _texturesSupported;
  26965. private _textureFormatInUse;
  26966. /**
  26967. * Gets the list of texture formats supported
  26968. */
  26969. readonly texturesSupported: Array<string>;
  26970. /**
  26971. * Gets the list of texture formats in use
  26972. */
  26973. readonly textureFormatInUse: Nullable<string>;
  26974. /**
  26975. * Gets the current viewport
  26976. */
  26977. readonly currentViewport: Nullable<Viewport>;
  26978. /**
  26979. * Gets the default empty texture
  26980. */
  26981. readonly emptyTexture: InternalTexture;
  26982. /**
  26983. * Gets the default empty 3D texture
  26984. */
  26985. readonly emptyTexture3D: InternalTexture;
  26986. /**
  26987. * Gets the default empty cube texture
  26988. */
  26989. readonly emptyCubeTexture: InternalTexture;
  26990. /**
  26991. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  26992. */
  26993. readonly premultipliedAlpha: boolean;
  26994. /**
  26995. * Creates a new engine
  26996. * @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
  26997. * @param antialias defines enable antialiasing (default: false)
  26998. * @param options defines further options to be sent to the getContext() function
  26999. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27000. */
  27001. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27002. private _disableTouchAction;
  27003. private _rebuildInternalTextures;
  27004. private _rebuildEffects;
  27005. /**
  27006. * Gets a boolean indicating if all created effects are ready
  27007. * @returns true if all effects are ready
  27008. */
  27009. areAllEffectsReady(): boolean;
  27010. private _rebuildBuffers;
  27011. private _initGLContext;
  27012. /**
  27013. * Gets version of the current webGL context
  27014. */
  27015. readonly webGLVersion: number;
  27016. /**
  27017. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27018. */
  27019. readonly isStencilEnable: boolean;
  27020. private _prepareWorkingCanvas;
  27021. /**
  27022. * Reset the texture cache to empty state
  27023. */
  27024. resetTextureCache(): void;
  27025. /**
  27026. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27027. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27028. * @returns true if engine is in deterministic lock step mode
  27029. */
  27030. isDeterministicLockStep(): boolean;
  27031. /**
  27032. * Gets the max steps when engine is running in deterministic lock step
  27033. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27034. * @returns the max steps
  27035. */
  27036. getLockstepMaxSteps(): number;
  27037. /**
  27038. * Gets an object containing information about the current webGL context
  27039. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27040. */
  27041. getGlInfo(): {
  27042. vendor: string;
  27043. renderer: string;
  27044. version: string;
  27045. };
  27046. /**
  27047. * Gets current aspect ratio
  27048. * @param camera defines the camera to use to get the aspect ratio
  27049. * @param useScreen defines if screen size must be used (or the current render target if any)
  27050. * @returns a number defining the aspect ratio
  27051. */
  27052. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27053. /**
  27054. * Gets current screen aspect ratio
  27055. * @returns a number defining the aspect ratio
  27056. */
  27057. getScreenAspectRatio(): number;
  27058. /**
  27059. * Gets the current render width
  27060. * @param useScreen defines if screen size must be used (or the current render target if any)
  27061. * @returns a number defining the current render width
  27062. */
  27063. getRenderWidth(useScreen?: boolean): number;
  27064. /**
  27065. * Gets the current render height
  27066. * @param useScreen defines if screen size must be used (or the current render target if any)
  27067. * @returns a number defining the current render height
  27068. */
  27069. getRenderHeight(useScreen?: boolean): number;
  27070. /**
  27071. * Gets the HTML canvas attached with the current webGL context
  27072. * @returns a HTML canvas
  27073. */
  27074. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27075. /**
  27076. * Gets the client rect of the HTML canvas attached with the current webGL context
  27077. * @returns a client rectanglee
  27078. */
  27079. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27080. /**
  27081. * Defines the hardware scaling level.
  27082. * By default the hardware scaling level is computed from the window device ratio.
  27083. * 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.
  27084. * @param level defines the level to use
  27085. */
  27086. setHardwareScalingLevel(level: number): void;
  27087. /**
  27088. * Gets the current hardware scaling level.
  27089. * By default the hardware scaling level is computed from the window device ratio.
  27090. * 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.
  27091. * @returns a number indicating the current hardware scaling level
  27092. */
  27093. getHardwareScalingLevel(): number;
  27094. /**
  27095. * Gets the list of loaded textures
  27096. * @returns an array containing all loaded textures
  27097. */
  27098. getLoadedTexturesCache(): InternalTexture[];
  27099. /**
  27100. * Gets the object containing all engine capabilities
  27101. * @returns the EngineCapabilities object
  27102. */
  27103. getCaps(): EngineCapabilities;
  27104. /**
  27105. * Gets the current depth function
  27106. * @returns a number defining the depth function
  27107. */
  27108. getDepthFunction(): Nullable<number>;
  27109. /**
  27110. * Sets the current depth function
  27111. * @param depthFunc defines the function to use
  27112. */
  27113. setDepthFunction(depthFunc: number): void;
  27114. /**
  27115. * Sets the current depth function to GREATER
  27116. */
  27117. setDepthFunctionToGreater(): void;
  27118. /**
  27119. * Sets the current depth function to GEQUAL
  27120. */
  27121. setDepthFunctionToGreaterOrEqual(): void;
  27122. /**
  27123. * Sets the current depth function to LESS
  27124. */
  27125. setDepthFunctionToLess(): void;
  27126. private _cachedStencilBuffer;
  27127. private _cachedStencilFunction;
  27128. private _cachedStencilMask;
  27129. private _cachedStencilOperationPass;
  27130. private _cachedStencilOperationFail;
  27131. private _cachedStencilOperationDepthFail;
  27132. private _cachedStencilReference;
  27133. /**
  27134. * Caches the the state of the stencil buffer
  27135. */
  27136. cacheStencilState(): void;
  27137. /**
  27138. * Restores the state of the stencil buffer
  27139. */
  27140. restoreStencilState(): void;
  27141. /**
  27142. * Sets the current depth function to LEQUAL
  27143. */
  27144. setDepthFunctionToLessOrEqual(): void;
  27145. /**
  27146. * Gets a boolean indicating if stencil buffer is enabled
  27147. * @returns the current stencil buffer state
  27148. */
  27149. getStencilBuffer(): boolean;
  27150. /**
  27151. * Enable or disable the stencil buffer
  27152. * @param enable defines if the stencil buffer must be enabled or disabled
  27153. */
  27154. setStencilBuffer(enable: boolean): void;
  27155. /**
  27156. * Gets the current stencil mask
  27157. * @returns a number defining the new stencil mask to use
  27158. */
  27159. getStencilMask(): number;
  27160. /**
  27161. * Sets the current stencil mask
  27162. * @param mask defines the new stencil mask to use
  27163. */
  27164. setStencilMask(mask: number): void;
  27165. /**
  27166. * Gets the current stencil function
  27167. * @returns a number defining the stencil function to use
  27168. */
  27169. getStencilFunction(): number;
  27170. /**
  27171. * Gets the current stencil reference value
  27172. * @returns a number defining the stencil reference value to use
  27173. */
  27174. getStencilFunctionReference(): number;
  27175. /**
  27176. * Gets the current stencil mask
  27177. * @returns a number defining the stencil mask to use
  27178. */
  27179. getStencilFunctionMask(): number;
  27180. /**
  27181. * Sets the current stencil function
  27182. * @param stencilFunc defines the new stencil function to use
  27183. */
  27184. setStencilFunction(stencilFunc: number): void;
  27185. /**
  27186. * Sets the current stencil reference
  27187. * @param reference defines the new stencil reference to use
  27188. */
  27189. setStencilFunctionReference(reference: number): void;
  27190. /**
  27191. * Sets the current stencil mask
  27192. * @param mask defines the new stencil mask to use
  27193. */
  27194. setStencilFunctionMask(mask: number): void;
  27195. /**
  27196. * Gets the current stencil operation when stencil fails
  27197. * @returns a number defining stencil operation to use when stencil fails
  27198. */
  27199. getStencilOperationFail(): number;
  27200. /**
  27201. * Gets the current stencil operation when depth fails
  27202. * @returns a number defining stencil operation to use when depth fails
  27203. */
  27204. getStencilOperationDepthFail(): number;
  27205. /**
  27206. * Gets the current stencil operation when stencil passes
  27207. * @returns a number defining stencil operation to use when stencil passes
  27208. */
  27209. getStencilOperationPass(): number;
  27210. /**
  27211. * Sets the stencil operation to use when stencil fails
  27212. * @param operation defines the stencil operation to use when stencil fails
  27213. */
  27214. setStencilOperationFail(operation: number): void;
  27215. /**
  27216. * Sets the stencil operation to use when depth fails
  27217. * @param operation defines the stencil operation to use when depth fails
  27218. */
  27219. setStencilOperationDepthFail(operation: number): void;
  27220. /**
  27221. * Sets the stencil operation to use when stencil passes
  27222. * @param operation defines the stencil operation to use when stencil passes
  27223. */
  27224. setStencilOperationPass(operation: number): void;
  27225. /**
  27226. * Sets a boolean indicating if the dithering state is enabled or disabled
  27227. * @param value defines the dithering state
  27228. */
  27229. setDitheringState(value: boolean): void;
  27230. /**
  27231. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27232. * @param value defines the rasterizer state
  27233. */
  27234. setRasterizerState(value: boolean): void;
  27235. /**
  27236. * stop executing a render loop function and remove it from the execution array
  27237. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27238. */
  27239. stopRenderLoop(renderFunction?: () => void): void;
  27240. /** @hidden */ renderLoop(): void;
  27241. /**
  27242. * Register and execute a render loop. The engine can have more than one render function
  27243. * @param renderFunction defines the function to continuously execute
  27244. */
  27245. runRenderLoop(renderFunction: () => void): void;
  27246. /**
  27247. * Toggle full screen mode
  27248. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27249. */
  27250. switchFullscreen(requestPointerLock: boolean): void;
  27251. /**
  27252. * Enters full screen mode
  27253. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27254. */
  27255. enterFullscreen(requestPointerLock: boolean): void;
  27256. /**
  27257. * Exits full screen mode
  27258. */
  27259. exitFullscreen(): void;
  27260. /**
  27261. * Clear the current render buffer or the current render target (if any is set up)
  27262. * @param color defines the color to use
  27263. * @param backBuffer defines if the back buffer must be cleared
  27264. * @param depth defines if the depth buffer must be cleared
  27265. * @param stencil defines if the stencil buffer must be cleared
  27266. */
  27267. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27268. /**
  27269. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27270. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27271. * @param y defines the y-coordinate of the corner of the clear rectangle
  27272. * @param width defines the width of the clear rectangle
  27273. * @param height defines the height of the clear rectangle
  27274. * @param clearColor defines the clear color
  27275. */
  27276. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27277. /**
  27278. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27279. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27280. * @param y defines the y-coordinate of the corner of the clear rectangle
  27281. * @param width defines the width of the clear rectangle
  27282. * @param height defines the height of the clear rectangle
  27283. */
  27284. enableScissor(x: number, y: number, width: number, height: number): void;
  27285. /**
  27286. * Disable previously set scissor test rectangle
  27287. */
  27288. disableScissor(): void;
  27289. private _viewportCached;
  27290. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  27291. /**
  27292. * Set the WebGL's viewport
  27293. * @param viewport defines the viewport element to be used
  27294. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27295. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27296. */
  27297. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27298. /**
  27299. * Directly set the WebGL Viewport
  27300. * @param x defines the x coordinate of the viewport (in screen space)
  27301. * @param y defines the y coordinate of the viewport (in screen space)
  27302. * @param width defines the width of the viewport (in screen space)
  27303. * @param height defines the height of the viewport (in screen space)
  27304. * @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
  27305. */
  27306. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27307. /**
  27308. * Begin a new frame
  27309. */
  27310. beginFrame(): void;
  27311. /**
  27312. * Enf the current frame
  27313. */
  27314. endFrame(): void;
  27315. /**
  27316. * Resize the view according to the canvas' size
  27317. */
  27318. resize(): void;
  27319. /**
  27320. * Force a specific size of the canvas
  27321. * @param width defines the new canvas' width
  27322. * @param height defines the new canvas' height
  27323. */
  27324. setSize(width: number, height: number): void;
  27325. /**
  27326. * Gets a boolean indicating if a webVR device was detected
  27327. * @returns true if a webVR device was detected
  27328. */
  27329. isVRDevicePresent(): boolean;
  27330. /**
  27331. * Gets the current webVR device
  27332. * @returns the current webVR device (or null)
  27333. */
  27334. getVRDevice(): any;
  27335. /**
  27336. * Initializes a webVR display and starts listening to display change events
  27337. * The onVRDisplayChangedObservable will be notified upon these changes
  27338. * @returns The onVRDisplayChangedObservable
  27339. */
  27340. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27341. /**
  27342. * Initializes a webVR display and starts listening to display change events
  27343. * The onVRDisplayChangedObservable will be notified upon these changes
  27344. * @returns A promise containing a VRDisplay and if vr is supported
  27345. */
  27346. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27347. /**
  27348. * Call this function to switch to webVR mode
  27349. * Will do nothing if webVR is not supported or if there is no webVR device
  27350. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27351. */
  27352. enableVR(): void;
  27353. /**
  27354. * Call this function to leave webVR mode
  27355. * Will do nothing if webVR is not supported or if there is no webVR device
  27356. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27357. */
  27358. disableVR(): void;
  27359. private _onVRFullScreenTriggered;
  27360. private _getVRDisplaysAsync;
  27361. /**
  27362. * Binds the frame buffer to the specified texture.
  27363. * @param texture The texture to render to or null for the default canvas
  27364. * @param faceIndex The face of the texture to render to in case of cube texture
  27365. * @param requiredWidth The width of the target to render to
  27366. * @param requiredHeight The height of the target to render to
  27367. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27368. * @param depthStencilTexture The depth stencil texture to use to render
  27369. * @param lodLevel defines le lod level to bind to the frame buffer
  27370. */
  27371. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27372. private bindUnboundFramebuffer;
  27373. /**
  27374. * Unbind the current render target texture from the webGL context
  27375. * @param texture defines the render target texture to unbind
  27376. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27377. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27378. */
  27379. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27380. /**
  27381. * Unbind a list of render target textures from the webGL context
  27382. * This is used only when drawBuffer extension or webGL2 are active
  27383. * @param textures defines the render target textures to unbind
  27384. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27385. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27386. */
  27387. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27388. /**
  27389. * Force the mipmap generation for the given render target texture
  27390. * @param texture defines the render target texture to use
  27391. */
  27392. generateMipMapsForCubemap(texture: InternalTexture): void;
  27393. /**
  27394. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27395. */
  27396. flushFramebuffer(): void;
  27397. /**
  27398. * Unbind the current render target and bind the default framebuffer
  27399. */
  27400. restoreDefaultFramebuffer(): void;
  27401. /**
  27402. * Create an uniform buffer
  27403. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27404. * @param elements defines the content of the uniform buffer
  27405. * @returns the webGL uniform buffer
  27406. */
  27407. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27408. /**
  27409. * Create a dynamic uniform buffer
  27410. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27411. * @param elements defines the content of the uniform buffer
  27412. * @returns the webGL uniform buffer
  27413. */
  27414. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27415. /**
  27416. * Update an existing uniform buffer
  27417. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27418. * @param uniformBuffer defines the target uniform buffer
  27419. * @param elements defines the content to update
  27420. * @param offset defines the offset in the uniform buffer where update should start
  27421. * @param count defines the size of the data to update
  27422. */
  27423. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27424. private _resetVertexBufferBinding;
  27425. /**
  27426. * Creates a vertex buffer
  27427. * @param data the data for the vertex buffer
  27428. * @returns the new WebGL static buffer
  27429. */
  27430. createVertexBuffer(data: DataArray): WebGLBuffer;
  27431. /**
  27432. * Creates a dynamic vertex buffer
  27433. * @param data the data for the dynamic vertex buffer
  27434. * @returns the new WebGL dynamic buffer
  27435. */
  27436. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27437. /**
  27438. * Update a dynamic index buffer
  27439. * @param indexBuffer defines the target index buffer
  27440. * @param indices defines the data to update
  27441. * @param offset defines the offset in the target index buffer where update should start
  27442. */
  27443. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27444. /**
  27445. * Updates a dynamic vertex buffer.
  27446. * @param vertexBuffer the vertex buffer to update
  27447. * @param data the data used to update the vertex buffer
  27448. * @param byteOffset the byte offset of the data
  27449. * @param byteLength the byte length of the data
  27450. */
  27451. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27452. private _resetIndexBufferBinding;
  27453. /**
  27454. * Creates a new index buffer
  27455. * @param indices defines the content of the index buffer
  27456. * @param updatable defines if the index buffer must be updatable
  27457. * @returns a new webGL buffer
  27458. */
  27459. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27460. /**
  27461. * Bind a webGL buffer to the webGL context
  27462. * @param buffer defines the buffer to bind
  27463. */
  27464. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27465. /**
  27466. * Bind an uniform buffer to the current webGL context
  27467. * @param buffer defines the buffer to bind
  27468. */
  27469. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27470. /**
  27471. * Bind a buffer to the current webGL context at a given location
  27472. * @param buffer defines the buffer to bind
  27473. * @param location defines the index where to bind the buffer
  27474. */
  27475. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27476. /**
  27477. * Bind a specific block at a given index in a specific shader program
  27478. * @param shaderProgram defines the shader program
  27479. * @param blockName defines the block name
  27480. * @param index defines the index where to bind the block
  27481. */
  27482. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27483. private bindIndexBuffer;
  27484. private bindBuffer;
  27485. /**
  27486. * update the bound buffer with the given data
  27487. * @param data defines the data to update
  27488. */
  27489. updateArrayBuffer(data: Float32Array): void;
  27490. private _vertexAttribPointer;
  27491. private _bindIndexBufferWithCache;
  27492. private _bindVertexBuffersAttributes;
  27493. /**
  27494. * Records a vertex array object
  27495. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27496. * @param vertexBuffers defines the list of vertex buffers to store
  27497. * @param indexBuffer defines the index buffer to store
  27498. * @param effect defines the effect to store
  27499. * @returns the new vertex array object
  27500. */
  27501. recordVertexArrayObject(vertexBuffers: {
  27502. [key: string]: VertexBuffer;
  27503. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27504. /**
  27505. * Bind a specific vertex array object
  27506. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27507. * @param vertexArrayObject defines the vertex array object to bind
  27508. * @param indexBuffer defines the index buffer to bind
  27509. */
  27510. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27511. /**
  27512. * Bind webGl buffers directly to the webGL context
  27513. * @param vertexBuffer defines the vertex buffer to bind
  27514. * @param indexBuffer defines the index buffer to bind
  27515. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27516. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27517. * @param effect defines the effect associated with the vertex buffer
  27518. */
  27519. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27520. private _unbindVertexArrayObject;
  27521. /**
  27522. * Bind a list of vertex buffers to the webGL context
  27523. * @param vertexBuffers defines the list of vertex buffers to bind
  27524. * @param indexBuffer defines the index buffer to bind
  27525. * @param effect defines the effect associated with the vertex buffers
  27526. */
  27527. bindBuffers(vertexBuffers: {
  27528. [key: string]: Nullable<VertexBuffer>;
  27529. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27530. /**
  27531. * Unbind all instance attributes
  27532. */
  27533. unbindInstanceAttributes(): void;
  27534. /**
  27535. * Release and free the memory of a vertex array object
  27536. * @param vao defines the vertex array object to delete
  27537. */
  27538. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27539. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  27540. /**
  27541. * Creates a webGL buffer to use with instanciation
  27542. * @param capacity defines the size of the buffer
  27543. * @returns the webGL buffer
  27544. */
  27545. createInstancesBuffer(capacity: number): WebGLBuffer;
  27546. /**
  27547. * Delete a webGL buffer used with instanciation
  27548. * @param buffer defines the webGL buffer to delete
  27549. */
  27550. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27551. /**
  27552. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27553. * @param instancesBuffer defines the webGL buffer to update and bind
  27554. * @param data defines the data to store in the buffer
  27555. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27556. */
  27557. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27558. /**
  27559. * Apply all cached states (depth, culling, stencil and alpha)
  27560. */
  27561. applyStates(): void;
  27562. /**
  27563. * Send a draw order
  27564. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27565. * @param indexStart defines the starting index
  27566. * @param indexCount defines the number of index to draw
  27567. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27568. */
  27569. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27570. /**
  27571. * Draw a list of points
  27572. * @param verticesStart defines the index of first vertex to draw
  27573. * @param verticesCount defines the count of vertices to draw
  27574. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27575. */
  27576. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27577. /**
  27578. * Draw a list of unindexed primitives
  27579. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27580. * @param verticesStart defines the index of first vertex to draw
  27581. * @param verticesCount defines the count of vertices to draw
  27582. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27583. */
  27584. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27585. /**
  27586. * Draw a list of indexed primitives
  27587. * @param fillMode defines the primitive to use
  27588. * @param indexStart defines the starting index
  27589. * @param indexCount defines the number of index to draw
  27590. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27591. */
  27592. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27593. /**
  27594. * Draw a list of unindexed primitives
  27595. * @param fillMode defines the primitive to use
  27596. * @param verticesStart defines the index of first vertex to draw
  27597. * @param verticesCount defines the count of vertices to draw
  27598. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27599. */
  27600. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27601. private _drawMode;
  27602. /** @hidden */ releaseEffect(effect: Effect): void;
  27603. /** @hidden */ deleteProgram(program: WebGLProgram): void;
  27604. /**
  27605. * Create a new effect (used to store vertex/fragment shaders)
  27606. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27607. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27608. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27609. * @param samplers defines an array of string used to represent textures
  27610. * @param defines defines the string containing the defines to use to compile the shaders
  27611. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27612. * @param onCompiled defines a function to call when the effect creation is successful
  27613. * @param onError defines a function to call when the effect creation has failed
  27614. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27615. * @returns the new Effect
  27616. */
  27617. 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;
  27618. private _compileShader;
  27619. private _compileRawShader;
  27620. /**
  27621. * Directly creates a webGL program
  27622. * @param vertexCode defines the vertex shader code to use
  27623. * @param fragmentCode defines the fragment shader code to use
  27624. * @param context defines the webGL context to use (if not set, the current one will be used)
  27625. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27626. * @returns the new webGL program
  27627. */
  27628. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27629. /**
  27630. * Creates a webGL program
  27631. * @param vertexCode defines the vertex shader code to use
  27632. * @param fragmentCode defines the fragment shader code to use
  27633. * @param defines defines the string containing the defines to use to compile the shaders
  27634. * @param context defines the webGL context to use (if not set, the current one will be used)
  27635. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27636. * @returns the new webGL program
  27637. */
  27638. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27639. private _createShaderProgram;
  27640. private _finalizeProgram;
  27641. /** @hidden */ isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  27642. /** @hidden */ executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  27643. /**
  27644. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27645. * @param shaderProgram defines the webGL program to use
  27646. * @param uniformsNames defines the list of uniform names
  27647. * @returns an array of webGL uniform locations
  27648. */
  27649. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27650. /**
  27651. * Gets the lsit of active attributes for a given webGL program
  27652. * @param shaderProgram defines the webGL program to use
  27653. * @param attributesNames defines the list of attribute names to get
  27654. * @returns an array of indices indicating the offset of each attribute
  27655. */
  27656. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  27657. /**
  27658. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27659. * @param effect defines the effect to activate
  27660. */
  27661. enableEffect(effect: Nullable<Effect>): void;
  27662. /**
  27663. * Set the value of an uniform to an array of int32
  27664. * @param uniform defines the webGL uniform location where to store the value
  27665. * @param array defines the array of int32 to store
  27666. */
  27667. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27668. /**
  27669. * Set the value of an uniform to an array of int32 (stored as vec2)
  27670. * @param uniform defines the webGL uniform location where to store the value
  27671. * @param array defines the array of int32 to store
  27672. */
  27673. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27674. /**
  27675. * Set the value of an uniform to an array of int32 (stored as vec3)
  27676. * @param uniform defines the webGL uniform location where to store the value
  27677. * @param array defines the array of int32 to store
  27678. */
  27679. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27680. /**
  27681. * Set the value of an uniform to an array of int32 (stored as vec4)
  27682. * @param uniform defines the webGL uniform location where to store the value
  27683. * @param array defines the array of int32 to store
  27684. */
  27685. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27686. /**
  27687. * Set the value of an uniform to an array of float32
  27688. * @param uniform defines the webGL uniform location where to store the value
  27689. * @param array defines the array of float32 to store
  27690. */
  27691. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27692. /**
  27693. * Set the value of an uniform to an array of float32 (stored as vec2)
  27694. * @param uniform defines the webGL uniform location where to store the value
  27695. * @param array defines the array of float32 to store
  27696. */
  27697. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27698. /**
  27699. * Set the value of an uniform to an array of float32 (stored as vec3)
  27700. * @param uniform defines the webGL uniform location where to store the value
  27701. * @param array defines the array of float32 to store
  27702. */
  27703. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27704. /**
  27705. * Set the value of an uniform to an array of float32 (stored as vec4)
  27706. * @param uniform defines the webGL uniform location where to store the value
  27707. * @param array defines the array of float32 to store
  27708. */
  27709. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27710. /**
  27711. * Set the value of an uniform to an array of number
  27712. * @param uniform defines the webGL uniform location where to store the value
  27713. * @param array defines the array of number to store
  27714. */
  27715. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27716. /**
  27717. * Set the value of an uniform to an array of number (stored as vec2)
  27718. * @param uniform defines the webGL uniform location where to store the value
  27719. * @param array defines the array of number to store
  27720. */
  27721. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27722. /**
  27723. * Set the value of an uniform to an array of number (stored as vec3)
  27724. * @param uniform defines the webGL uniform location where to store the value
  27725. * @param array defines the array of number to store
  27726. */
  27727. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27728. /**
  27729. * Set the value of an uniform to an array of number (stored as vec4)
  27730. * @param uniform defines the webGL uniform location where to store the value
  27731. * @param array defines the array of number to store
  27732. */
  27733. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27734. /**
  27735. * Set the value of an uniform to an array of float32 (stored as matrices)
  27736. * @param uniform defines the webGL uniform location where to store the value
  27737. * @param matrices defines the array of float32 to store
  27738. */
  27739. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27740. /**
  27741. * Set the value of an uniform to a matrix
  27742. * @param uniform defines the webGL uniform location where to store the value
  27743. * @param matrix defines the matrix to store
  27744. */
  27745. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27746. /**
  27747. * Set the value of an uniform to a matrix (3x3)
  27748. * @param uniform defines the webGL uniform location where to store the value
  27749. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27750. */
  27751. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27752. /**
  27753. * Set the value of an uniform to a matrix (2x2)
  27754. * @param uniform defines the webGL uniform location where to store the value
  27755. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27756. */
  27757. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27758. /**
  27759. * Set the value of an uniform to a number (int)
  27760. * @param uniform defines the webGL uniform location where to store the value
  27761. * @param value defines the int number to store
  27762. */
  27763. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27764. /**
  27765. * Set the value of an uniform to a number (float)
  27766. * @param uniform defines the webGL uniform location where to store the value
  27767. * @param value defines the float number to store
  27768. */
  27769. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27770. /**
  27771. * Set the value of an uniform to a vec2
  27772. * @param uniform defines the webGL uniform location where to store the value
  27773. * @param x defines the 1st component of the value
  27774. * @param y defines the 2nd component of the value
  27775. */
  27776. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27777. /**
  27778. * Set the value of an uniform to a vec3
  27779. * @param uniform defines the webGL uniform location where to store the value
  27780. * @param x defines the 1st component of the value
  27781. * @param y defines the 2nd component of the value
  27782. * @param z defines the 3rd component of the value
  27783. */
  27784. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27785. /**
  27786. * Set the value of an uniform to a boolean
  27787. * @param uniform defines the webGL uniform location where to store the value
  27788. * @param bool defines the boolean to store
  27789. */
  27790. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27791. /**
  27792. * Set the value of an uniform to a vec4
  27793. * @param uniform defines the webGL uniform location where to store the value
  27794. * @param x defines the 1st component of the value
  27795. * @param y defines the 2nd component of the value
  27796. * @param z defines the 3rd component of the value
  27797. * @param w defines the 4th component of the value
  27798. */
  27799. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27800. /**
  27801. * Set the value of an uniform to a Color3
  27802. * @param uniform defines the webGL uniform location where to store the value
  27803. * @param color3 defines the color to store
  27804. */
  27805. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27806. /**
  27807. * Set the value of an uniform to a Color3 and an alpha value
  27808. * @param uniform defines the webGL uniform location where to store the value
  27809. * @param color3 defines the color to store
  27810. * @param alpha defines the alpha component to store
  27811. */
  27812. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27813. /**
  27814. * Sets a Color4 on a uniform variable
  27815. * @param uniform defines the uniform location
  27816. * @param color4 defines the value to be set
  27817. */
  27818. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27819. /**
  27820. * Set various states to the webGL context
  27821. * @param culling defines backface culling state
  27822. * @param zOffset defines the value to apply to zOffset (0 by default)
  27823. * @param force defines if states must be applied even if cache is up to date
  27824. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27825. */
  27826. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27827. /**
  27828. * Set the z offset to apply to current rendering
  27829. * @param value defines the offset to apply
  27830. */
  27831. setZOffset(value: number): void;
  27832. /**
  27833. * Gets the current value of the zOffset
  27834. * @returns the current zOffset state
  27835. */
  27836. getZOffset(): number;
  27837. /**
  27838. * Enable or disable depth buffering
  27839. * @param enable defines the state to set
  27840. */
  27841. setDepthBuffer(enable: boolean): void;
  27842. /**
  27843. * Gets a boolean indicating if depth writing is enabled
  27844. * @returns the current depth writing state
  27845. */
  27846. getDepthWrite(): boolean;
  27847. /**
  27848. * Enable or disable depth writing
  27849. * @param enable defines the state to set
  27850. */
  27851. setDepthWrite(enable: boolean): void;
  27852. /**
  27853. * Enable or disable color writing
  27854. * @param enable defines the state to set
  27855. */
  27856. setColorWrite(enable: boolean): void;
  27857. /**
  27858. * Gets a boolean indicating if color writing is enabled
  27859. * @returns the current color writing state
  27860. */
  27861. getColorWrite(): boolean;
  27862. /**
  27863. * Sets alpha constants used by some alpha blending modes
  27864. * @param r defines the red component
  27865. * @param g defines the green component
  27866. * @param b defines the blue component
  27867. * @param a defines the alpha component
  27868. */
  27869. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  27870. /**
  27871. * Sets the current alpha mode
  27872. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  27873. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  27874. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27875. */
  27876. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  27877. /**
  27878. * Gets the current alpha mode
  27879. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27880. * @returns the current alpha mode
  27881. */
  27882. getAlphaMode(): number;
  27883. /**
  27884. * Clears the list of texture accessible through engine.
  27885. * This can help preventing texture load conflict due to name collision.
  27886. */
  27887. clearInternalTexturesCache(): void;
  27888. /**
  27889. * Force the entire cache to be cleared
  27890. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  27891. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  27892. */
  27893. wipeCaches(bruteForce?: boolean): void;
  27894. /**
  27895. * Set the compressed texture format to use, based on the formats you have, and the formats
  27896. * supported by the hardware / browser.
  27897. *
  27898. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  27899. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  27900. * to API arguments needed to compressed textures. This puts the burden on the container
  27901. * generator to house the arcane code for determining these for current & future formats.
  27902. *
  27903. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27904. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27905. *
  27906. * Note: The result of this call is not taken into account when a texture is base64.
  27907. *
  27908. * @param formatsAvailable defines the list of those format families you have created
  27909. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  27910. *
  27911. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  27912. * @returns The extension selected.
  27913. */
  27914. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  27915. private _getSamplingParameters;
  27916. private _partialLoadImg;
  27917. private _cascadeLoadImgs;
  27918. /** @hidden */ createTexture(): WebGLTexture;
  27919. /**
  27920. * Usually called from Texture.ts.
  27921. * Passed information to create a WebGLTexture
  27922. * @param urlArg defines a value which contains one of the following:
  27923. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  27924. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  27925. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  27926. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  27927. * @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)
  27928. * @param scene needed for loading to the correct scene
  27929. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  27930. * @param onLoad optional callback to be called upon successful completion
  27931. * @param onError optional callback to be called upon failure
  27932. * @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
  27933. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  27934. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  27935. * @param forcedExtension defines the extension to use to pick the right loader
  27936. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  27937. * @returns a InternalTexture for assignment back into BABYLON.Texture
  27938. */
  27939. 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;
  27940. private _rescaleTexture;
  27941. /**
  27942. * Update a raw texture
  27943. * @param texture defines the texture to update
  27944. * @param data defines the data to store in the texture
  27945. * @param format defines the format of the data
  27946. * @param invertY defines if data must be stored with Y axis inverted
  27947. * @param compression defines the compression used (null by default)
  27948. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27949. */
  27950. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  27951. /**
  27952. * Creates a raw texture
  27953. * @param data defines the data to store in the texture
  27954. * @param width defines the width of the texture
  27955. * @param height defines the height of the texture
  27956. * @param format defines the format of the data
  27957. * @param generateMipMaps defines if the engine should generate the mip levels
  27958. * @param invertY defines if data must be stored with Y axis inverted
  27959. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27960. * @param compression defines the compression used (null by default)
  27961. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27962. * @returns the raw texture inside an InternalTexture
  27963. */
  27964. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  27965. private _unpackFlipYCached;
  27966. /**
  27967. * In case you are sharing the context with other applications, it might
  27968. * be interested to not cache the unpack flip y state to ensure a consistent
  27969. * value would be set.
  27970. */
  27971. enableUnpackFlipYCached: boolean;
  27972. /** @hidden */ unpackFlipY(value: boolean): void;
  27973. /** @hidden */ getUnpackAlignement(): number;
  27974. /**
  27975. * Creates a dynamic texture
  27976. * @param width defines the width of the texture
  27977. * @param height defines the height of the texture
  27978. * @param generateMipMaps defines if the engine should generate the mip levels
  27979. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27980. * @returns the dynamic texture inside an InternalTexture
  27981. */
  27982. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  27983. /**
  27984. * Update the sampling mode of a given texture
  27985. * @param samplingMode defines the required sampling mode
  27986. * @param texture defines the texture to update
  27987. */
  27988. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  27989. /**
  27990. * Update the content of a dynamic texture
  27991. * @param texture defines the texture to update
  27992. * @param canvas defines the canvas containing the source
  27993. * @param invertY defines if data must be stored with Y axis inverted
  27994. * @param premulAlpha defines if alpha is stored as premultiplied
  27995. * @param format defines the format of the data
  27996. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  27997. */
  27998. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  27999. /**
  28000. * Update a video texture
  28001. * @param texture defines the texture to update
  28002. * @param video defines the video element to use
  28003. * @param invertY defines if data must be stored with Y axis inverted
  28004. */
  28005. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28006. /**
  28007. * Updates a depth texture Comparison Mode and Function.
  28008. * If the comparison Function is equal to 0, the mode will be set to none.
  28009. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28010. * @param texture The texture to set the comparison function for
  28011. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28012. */
  28013. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28014. private _setupDepthStencilTexture;
  28015. /**
  28016. * Creates a depth stencil texture.
  28017. * This is only available in WebGL 2 or with the depth texture extension available.
  28018. * @param size The size of face edge in the texture.
  28019. * @param options The options defining the texture.
  28020. * @returns The texture
  28021. */
  28022. createDepthStencilTexture(size: number | {
  28023. width: number;
  28024. height: number;
  28025. }, options: DepthTextureCreationOptions): InternalTexture;
  28026. /**
  28027. * Creates a depth stencil texture.
  28028. * This is only available in WebGL 2 or with the depth texture extension available.
  28029. * @param size The size of face edge in the texture.
  28030. * @param options The options defining the texture.
  28031. * @returns The texture
  28032. */
  28033. private _createDepthStencilTexture;
  28034. /**
  28035. * Creates a depth stencil cube texture.
  28036. * This is only available in WebGL 2.
  28037. * @param size The size of face edge in the cube texture.
  28038. * @param options The options defining the cube texture.
  28039. * @returns The cube texture
  28040. */
  28041. private _createDepthStencilCubeTexture;
  28042. /**
  28043. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28044. * @param renderTarget The render target to set the frame buffer for
  28045. */
  28046. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28047. /**
  28048. * Creates a new render target texture
  28049. * @param size defines the size of the texture
  28050. * @param options defines the options used to create the texture
  28051. * @returns a new render target texture stored in an InternalTexture
  28052. */
  28053. createRenderTargetTexture(size: number | {
  28054. width: number;
  28055. height: number;
  28056. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28057. /**
  28058. * Create a multi render target texture
  28059. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28060. * @param size defines the size of the texture
  28061. * @param options defines the creation options
  28062. * @returns the cube texture as an InternalTexture
  28063. */
  28064. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28065. private _setupFramebufferDepthAttachments;
  28066. /**
  28067. * Updates the sample count of a render target texture
  28068. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28069. * @param texture defines the texture to update
  28070. * @param samples defines the sample count to set
  28071. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28072. */
  28073. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28074. /**
  28075. * Update the sample count for a given multiple render target texture
  28076. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28077. * @param textures defines the textures to update
  28078. * @param samples defines the sample count to set
  28079. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28080. */
  28081. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28082. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28083. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28084. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28085. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28086. /**
  28087. * Creates a new render target cube texture
  28088. * @param size defines the size of the texture
  28089. * @param options defines the options used to create the texture
  28090. * @returns a new render target cube texture stored in an InternalTexture
  28091. */
  28092. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28093. /**
  28094. * Creates a cube texture
  28095. * @param rootUrl defines the url where the files to load is located
  28096. * @param scene defines the current scene
  28097. * @param files defines the list of files to load (1 per face)
  28098. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28099. * @param onLoad defines an optional callback raised when the texture is loaded
  28100. * @param onError defines an optional callback raised if there is an issue to load the texture
  28101. * @param format defines the format of the data
  28102. * @param forcedExtension defines the extension to use to pick the right loader
  28103. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28104. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28105. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28106. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28107. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28108. * @returns the cube texture as an InternalTexture
  28109. */
  28110. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28111. /**
  28112. * @hidden
  28113. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  28114. /**
  28115. * Update a raw cube texture
  28116. * @param texture defines the texture to udpdate
  28117. * @param data defines the data to store
  28118. * @param format defines the data format
  28119. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28120. * @param invertY defines if data must be stored with Y axis inverted
  28121. * @param compression defines the compression used (null by default)
  28122. * @param level defines which level of the texture to update
  28123. */
  28124. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28125. /**
  28126. * Creates a new raw cube texture
  28127. * @param data defines the array of data to use to create each face
  28128. * @param size defines the size of the textures
  28129. * @param format defines the format of the data
  28130. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28131. * @param generateMipMaps defines if the engine should generate the mip levels
  28132. * @param invertY defines if data must be stored with Y axis inverted
  28133. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28134. * @param compression defines the compression used (null by default)
  28135. * @returns the cube texture as an InternalTexture
  28136. */
  28137. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28138. /**
  28139. * Creates a new raw cube texture from a specified url
  28140. * @param url defines the url where the data is located
  28141. * @param scene defines the current scene
  28142. * @param size defines the size of the textures
  28143. * @param format defines the format of the data
  28144. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28145. * @param noMipmap defines if the engine should avoid generating the mip levels
  28146. * @param callback defines a callback used to extract texture data from loaded data
  28147. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28148. * @param onLoad defines a callback called when texture is loaded
  28149. * @param onError defines a callback called if there is an error
  28150. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28151. * @param invertY defines if data must be stored with Y axis inverted
  28152. * @returns the cube texture as an InternalTexture
  28153. */
  28154. 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;
  28155. /**
  28156. * Update a raw 3D texture
  28157. * @param texture defines the texture to update
  28158. * @param data defines the data to store
  28159. * @param format defines the data format
  28160. * @param invertY defines if data must be stored with Y axis inverted
  28161. * @param compression defines the used compression (can be null)
  28162. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28163. */
  28164. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28165. /**
  28166. * Creates a new raw 3D texture
  28167. * @param data defines the data used to create the texture
  28168. * @param width defines the width of the texture
  28169. * @param height defines the height of the texture
  28170. * @param depth defines the depth of the texture
  28171. * @param format defines the format of the texture
  28172. * @param generateMipMaps defines if the engine must generate mip levels
  28173. * @param invertY defines if data must be stored with Y axis inverted
  28174. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28175. * @param compression defines the compressed used (can be null)
  28176. * @param textureType defines the compressed used (can be null)
  28177. * @returns a new raw 3D texture (stored in an InternalTexture)
  28178. */
  28179. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28180. private _prepareWebGLTextureContinuation;
  28181. private _prepareWebGLTexture;
  28182. private _convertRGBtoRGBATextureData;
  28183. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  28184. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  28185. private setProgram;
  28186. private _boundUniforms;
  28187. /**
  28188. * Binds an effect to the webGL context
  28189. * @param effect defines the effect to bind
  28190. */
  28191. bindSamplers(effect: Effect): void;
  28192. private _activateCurrentTexture;
  28193. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28194. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28195. /**
  28196. * Sets a texture to the webGL context from a postprocess
  28197. * @param channel defines the channel to use
  28198. * @param postProcess defines the source postprocess
  28199. */
  28200. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28201. /**
  28202. * Binds the output of the passed in post process to the texture channel specified
  28203. * @param channel The channel the texture should be bound to
  28204. * @param postProcess The post process which's output should be bound
  28205. */
  28206. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28207. /**
  28208. * Unbind all textures from the webGL context
  28209. */
  28210. unbindAllTextures(): void;
  28211. /**
  28212. * Sets a texture to the according uniform.
  28213. * @param channel The texture channel
  28214. * @param uniform The uniform to set
  28215. * @param texture The texture to apply
  28216. */
  28217. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28218. /**
  28219. * Sets a depth stencil texture from a render target to the according uniform.
  28220. * @param channel The texture channel
  28221. * @param uniform The uniform to set
  28222. * @param texture The render target texture containing the depth stencil texture to apply
  28223. */
  28224. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28225. private _bindSamplerUniformToChannel;
  28226. private _getTextureWrapMode;
  28227. private _setTexture;
  28228. /**
  28229. * Sets an array of texture to the webGL context
  28230. * @param channel defines the channel where the texture array must be set
  28231. * @param uniform defines the associated uniform location
  28232. * @param textures defines the array of textures to bind
  28233. */
  28234. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28235. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28236. private _setTextureParameterFloat;
  28237. private _setTextureParameterInteger;
  28238. /**
  28239. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28240. * @param x defines the x coordinate of the rectangle where pixels must be read
  28241. * @param y defines the y coordinate of the rectangle where pixels must be read
  28242. * @param width defines the width of the rectangle where pixels must be read
  28243. * @param height defines the height of the rectangle where pixels must be read
  28244. * @returns a Uint8Array containing RGBA colors
  28245. */
  28246. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28247. /**
  28248. * Add an externaly attached data from its key.
  28249. * This method call will fail and return false, if such key already exists.
  28250. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28251. * @param key the unique key that identifies the data
  28252. * @param data the data object to associate to the key for this Engine instance
  28253. * @return true if no such key were already present and the data was added successfully, false otherwise
  28254. */
  28255. addExternalData<T>(key: string, data: T): boolean;
  28256. /**
  28257. * Get an externaly attached data from its key
  28258. * @param key the unique key that identifies the data
  28259. * @return the associated data, if present (can be null), or undefined if not present
  28260. */
  28261. getExternalData<T>(key: string): T;
  28262. /**
  28263. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28264. * @param key the unique key that identifies the data
  28265. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28266. * @return the associated data, can be null if the factory returned null.
  28267. */
  28268. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28269. /**
  28270. * Remove an externaly attached data from the Engine instance
  28271. * @param key the unique key that identifies the data
  28272. * @return true if the data was successfully removed, false if it doesn't exist
  28273. */
  28274. removeExternalData(key: string): boolean;
  28275. /**
  28276. * Unbind all vertex attributes from the webGL context
  28277. */
  28278. unbindAllAttributes(): void;
  28279. /**
  28280. * 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
  28281. */
  28282. releaseEffects(): void;
  28283. /**
  28284. * Dispose and release all associated resources
  28285. */
  28286. dispose(): void;
  28287. /**
  28288. * Display the loading screen
  28289. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28290. */
  28291. displayLoadingUI(): void;
  28292. /**
  28293. * Hide the loading screen
  28294. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28295. */
  28296. hideLoadingUI(): void;
  28297. /**
  28298. * Gets the current loading screen object
  28299. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28300. */
  28301. /**
  28302. * Sets the current loading screen object
  28303. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28304. */
  28305. loadingScreen: ILoadingScreen;
  28306. /**
  28307. * Sets the current loading screen text
  28308. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28309. */
  28310. loadingUIText: string;
  28311. /**
  28312. * Sets the current loading screen background color
  28313. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28314. */
  28315. loadingUIBackgroundColor: string;
  28316. /**
  28317. * Attach a new callback raised when context lost event is fired
  28318. * @param callback defines the callback to call
  28319. */
  28320. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28321. /**
  28322. * Attach a new callback raised when context restored event is fired
  28323. * @param callback defines the callback to call
  28324. */
  28325. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28326. /**
  28327. * Gets the source code of the vertex shader associated with a specific webGL program
  28328. * @param program defines the program to use
  28329. * @returns a string containing the source code of the vertex shader associated with the program
  28330. */
  28331. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28332. /**
  28333. * Gets the source code of the fragment shader associated with a specific webGL program
  28334. * @param program defines the program to use
  28335. * @returns a string containing the source code of the fragment shader associated with the program
  28336. */
  28337. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28338. /**
  28339. * Get the current error code of the webGL context
  28340. * @returns the error code
  28341. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28342. */
  28343. getError(): number;
  28344. /**
  28345. * Gets the current framerate
  28346. * @returns a number representing the framerate
  28347. */
  28348. getFps(): number;
  28349. /**
  28350. * Gets the time spent between current and previous frame
  28351. * @returns a number representing the delta time in ms
  28352. */
  28353. getDeltaTime(): number;
  28354. private _measureFps;
  28355. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28356. private _canRenderToFloatFramebuffer;
  28357. private _canRenderToHalfFloatFramebuffer;
  28358. private _canRenderToFramebuffer;
  28359. /** @hidden */ getWebGLTextureType(type: number): number;
  28360. private _getInternalFormat;
  28361. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28362. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  28363. /** @hidden */ loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  28364. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28365. private _partialLoadFile;
  28366. private _cascadeLoadFiles;
  28367. /**
  28368. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28369. * @returns true if the engine can be created
  28370. * @ignorenaming
  28371. */
  28372. static isSupported(): boolean;
  28373. }
  28374. }
  28375. declare module BABYLON {
  28376. /**
  28377. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28378. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28379. */
  28380. export class EffectFallbacks {
  28381. private _defines;
  28382. private _currentRank;
  28383. private _maxRank;
  28384. private _mesh;
  28385. /**
  28386. * Removes the fallback from the bound mesh.
  28387. */
  28388. unBindMesh(): void;
  28389. /**
  28390. * Adds a fallback on the specified property.
  28391. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28392. * @param define The name of the define in the shader
  28393. */
  28394. addFallback(rank: number, define: string): void;
  28395. /**
  28396. * Sets the mesh to use CPU skinning when needing to fallback.
  28397. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28398. * @param mesh The mesh to use the fallbacks.
  28399. */
  28400. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28401. /**
  28402. * Checks to see if more fallbacks are still availible.
  28403. */
  28404. readonly isMoreFallbacks: boolean;
  28405. /**
  28406. * Removes the defines that shoould be removed when falling back.
  28407. * @param currentDefines defines the current define statements for the shader.
  28408. * @param effect defines the current effect we try to compile
  28409. * @returns The resulting defines with defines of the current rank removed.
  28410. */
  28411. reduce(currentDefines: string, effect: Effect): string;
  28412. }
  28413. /**
  28414. * Options to be used when creating an effect.
  28415. */
  28416. export class EffectCreationOptions {
  28417. /**
  28418. * Atrributes that will be used in the shader.
  28419. */
  28420. attributes: string[];
  28421. /**
  28422. * Uniform varible names that will be set in the shader.
  28423. */
  28424. uniformsNames: string[];
  28425. /**
  28426. * Uniform buffer varible names that will be set in the shader.
  28427. */
  28428. uniformBuffersNames: string[];
  28429. /**
  28430. * Sampler texture variable names that will be set in the shader.
  28431. */
  28432. samplers: string[];
  28433. /**
  28434. * Define statements that will be set in the shader.
  28435. */
  28436. defines: any;
  28437. /**
  28438. * Possible fallbacks for this effect to improve performance when needed.
  28439. */
  28440. fallbacks: Nullable<EffectFallbacks>;
  28441. /**
  28442. * Callback that will be called when the shader is compiled.
  28443. */
  28444. onCompiled: Nullable<(effect: Effect) => void>;
  28445. /**
  28446. * Callback that will be called if an error occurs during shader compilation.
  28447. */
  28448. onError: Nullable<(effect: Effect, errors: string) => void>;
  28449. /**
  28450. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28451. */
  28452. indexParameters: any;
  28453. /**
  28454. * Max number of lights that can be used in the shader.
  28455. */
  28456. maxSimultaneousLights: number;
  28457. /**
  28458. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28459. */
  28460. transformFeedbackVaryings: Nullable<string[]>;
  28461. }
  28462. /**
  28463. * Effect containing vertex and fragment shader that can be executed on an object.
  28464. */
  28465. export class Effect implements IDisposable {
  28466. /**
  28467. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28468. */
  28469. static ShadersRepository: string;
  28470. /**
  28471. * Name of the effect.
  28472. */
  28473. name: any;
  28474. /**
  28475. * String container all the define statements that should be set on the shader.
  28476. */
  28477. defines: string;
  28478. /**
  28479. * Callback that will be called when the shader is compiled.
  28480. */
  28481. onCompiled: Nullable<(effect: Effect) => void>;
  28482. /**
  28483. * Callback that will be called if an error occurs during shader compilation.
  28484. */
  28485. onError: Nullable<(effect: Effect, errors: string) => void>;
  28486. /**
  28487. * Callback that will be called when effect is bound.
  28488. */
  28489. onBind: Nullable<(effect: Effect) => void>;
  28490. /**
  28491. * Unique ID of the effect.
  28492. */
  28493. uniqueId: number;
  28494. /**
  28495. * Observable that will be called when the shader is compiled.
  28496. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28497. */
  28498. onCompileObservable: Observable<Effect>;
  28499. /**
  28500. * Observable that will be called if an error occurs during shader compilation.
  28501. */
  28502. onErrorObservable: Observable<Effect>;
  28503. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  28504. /**
  28505. * Observable that will be called when effect is bound.
  28506. */
  28507. readonly onBindObservable: Observable<Effect>;
  28508. /** @hidden */ bonesComputationForcedToCPU: boolean;
  28509. private static _uniqueIdSeed;
  28510. private _engine;
  28511. private _uniformBuffersNames;
  28512. private _uniformsNames;
  28513. private _samplerList;
  28514. private _samplers;
  28515. private _isReady;
  28516. private _compilationError;
  28517. private _attributesNames;
  28518. private _attributes;
  28519. private _uniforms;
  28520. /**
  28521. * Key for the effect.
  28522. * @hidden
  28523. */ key: string;
  28524. private _indexParameters;
  28525. private _fallbacks;
  28526. private _vertexSourceCode;
  28527. private _fragmentSourceCode;
  28528. private _vertexSourceCodeOverride;
  28529. private _fragmentSourceCodeOverride;
  28530. private _transformFeedbackVaryings;
  28531. /**
  28532. * Compiled shader to webGL program.
  28533. * @hidden
  28534. */ program: WebGLProgram;
  28535. private _valueCache;
  28536. private static _baseCache;
  28537. /**
  28538. * Instantiates an effect.
  28539. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28540. * @param baseName Name of the effect.
  28541. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28542. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28543. * @param samplers List of sampler variables that will be passed to the shader.
  28544. * @param engine Engine to be used to render the effect
  28545. * @param defines Define statements to be added to the shader.
  28546. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28547. * @param onCompiled Callback that will be called when the shader is compiled.
  28548. * @param onError Callback that will be called if an error occurs during shader compilation.
  28549. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28550. */
  28551. 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);
  28552. /**
  28553. * Unique key for this effect
  28554. */
  28555. readonly key: string;
  28556. /**
  28557. * If the effect has been compiled and prepared.
  28558. * @returns if the effect is compiled and prepared.
  28559. */
  28560. isReady(): boolean;
  28561. /**
  28562. * The engine the effect was initialized with.
  28563. * @returns the engine.
  28564. */
  28565. getEngine(): Engine;
  28566. /**
  28567. * The compiled webGL program for the effect
  28568. * @returns the webGL program.
  28569. */
  28570. getProgram(): WebGLProgram;
  28571. /**
  28572. * The set of names of attribute variables for the shader.
  28573. * @returns An array of attribute names.
  28574. */
  28575. getAttributesNames(): string[];
  28576. /**
  28577. * Returns the attribute at the given index.
  28578. * @param index The index of the attribute.
  28579. * @returns The location of the attribute.
  28580. */
  28581. getAttributeLocation(index: number): number;
  28582. /**
  28583. * Returns the attribute based on the name of the variable.
  28584. * @param name of the attribute to look up.
  28585. * @returns the attribute location.
  28586. */
  28587. getAttributeLocationByName(name: string): number;
  28588. /**
  28589. * The number of attributes.
  28590. * @returns the numnber of attributes.
  28591. */
  28592. getAttributesCount(): number;
  28593. /**
  28594. * Gets the index of a uniform variable.
  28595. * @param uniformName of the uniform to look up.
  28596. * @returns the index.
  28597. */
  28598. getUniformIndex(uniformName: string): number;
  28599. /**
  28600. * Returns the attribute based on the name of the variable.
  28601. * @param uniformName of the uniform to look up.
  28602. * @returns the location of the uniform.
  28603. */
  28604. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28605. /**
  28606. * Returns an array of sampler variable names
  28607. * @returns The array of sampler variable neames.
  28608. */
  28609. getSamplers(): string[];
  28610. /**
  28611. * The error from the last compilation.
  28612. * @returns the error string.
  28613. */
  28614. getCompilationError(): string;
  28615. /**
  28616. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28617. * @param func The callback to be used.
  28618. */
  28619. executeWhenCompiled(func: (effect: Effect) => void): void;
  28620. private _checkIsReady;
  28621. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28622. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28623. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28624. private _processShaderConversion;
  28625. private _processIncludes;
  28626. private _processPrecision;
  28627. /**
  28628. * Recompiles the webGL program
  28629. * @param vertexSourceCode The source code for the vertex shader.
  28630. * @param fragmentSourceCode The source code for the fragment shader.
  28631. * @param onCompiled Callback called when completed.
  28632. * @param onError Callback called on error.
  28633. * @hidden
  28634. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  28635. /**
  28636. * Gets the uniform locations of the the specified variable names
  28637. * @param names THe names of the variables to lookup.
  28638. * @returns Array of locations in the same order as variable names.
  28639. */
  28640. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  28641. /**
  28642. * Prepares the effect
  28643. * @hidden
  28644. */ prepareEffect(): void;
  28645. /**
  28646. * Checks if the effect is supported. (Must be called after compilation)
  28647. */
  28648. readonly isSupported: boolean;
  28649. /**
  28650. * Binds a texture to the engine to be used as output of the shader.
  28651. * @param channel Name of the output variable.
  28652. * @param texture Texture to bind.
  28653. * @hidden
  28654. */ bindTexture(channel: string, texture: InternalTexture): void;
  28655. /**
  28656. * Sets a texture on the engine to be used in the shader.
  28657. * @param channel Name of the sampler variable.
  28658. * @param texture Texture to set.
  28659. */
  28660. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28661. /**
  28662. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28663. * @param channel Name of the sampler variable.
  28664. * @param texture Texture to set.
  28665. */
  28666. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28667. /**
  28668. * Sets an array of textures on the engine to be used in the shader.
  28669. * @param channel Name of the variable.
  28670. * @param textures Textures to set.
  28671. */
  28672. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28673. /**
  28674. * 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)
  28675. * @param channel Name of the sampler variable.
  28676. * @param postProcess Post process to get the input texture from.
  28677. */
  28678. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28679. /**
  28680. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28681. * 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)
  28682. * @param channel Name of the sampler variable.
  28683. * @param postProcess Post process to get the output texture from.
  28684. */
  28685. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28686. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28687. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28688. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28689. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28690. /**
  28691. * Binds a buffer to a uniform.
  28692. * @param buffer Buffer to bind.
  28693. * @param name Name of the uniform variable to bind to.
  28694. */
  28695. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  28696. /**
  28697. * Binds block to a uniform.
  28698. * @param blockName Name of the block to bind.
  28699. * @param index Index to bind.
  28700. */
  28701. bindUniformBlock(blockName: string, index: number): void;
  28702. /**
  28703. * Sets an interger value on a uniform variable.
  28704. * @param uniformName Name of the variable.
  28705. * @param value Value to be set.
  28706. * @returns this effect.
  28707. */
  28708. setInt(uniformName: string, value: number): Effect;
  28709. /**
  28710. * Sets an int array on a uniform variable.
  28711. * @param uniformName Name of the variable.
  28712. * @param array array to be set.
  28713. * @returns this effect.
  28714. */
  28715. setIntArray(uniformName: string, array: Int32Array): Effect;
  28716. /**
  28717. * 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)
  28718. * @param uniformName Name of the variable.
  28719. * @param array array to be set.
  28720. * @returns this effect.
  28721. */
  28722. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28723. /**
  28724. * 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)
  28725. * @param uniformName Name of the variable.
  28726. * @param array array to be set.
  28727. * @returns this effect.
  28728. */
  28729. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28730. /**
  28731. * 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)
  28732. * @param uniformName Name of the variable.
  28733. * @param array array to be set.
  28734. * @returns this effect.
  28735. */
  28736. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28737. /**
  28738. * Sets an float array on a uniform variable.
  28739. * @param uniformName Name of the variable.
  28740. * @param array array to be set.
  28741. * @returns this effect.
  28742. */
  28743. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28744. /**
  28745. * 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)
  28746. * @param uniformName Name of the variable.
  28747. * @param array array to be set.
  28748. * @returns this effect.
  28749. */
  28750. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28751. /**
  28752. * 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)
  28753. * @param uniformName Name of the variable.
  28754. * @param array array to be set.
  28755. * @returns this effect.
  28756. */
  28757. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28758. /**
  28759. * 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)
  28760. * @param uniformName Name of the variable.
  28761. * @param array array to be set.
  28762. * @returns this effect.
  28763. */
  28764. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28765. /**
  28766. * Sets an array on a uniform variable.
  28767. * @param uniformName Name of the variable.
  28768. * @param array array to be set.
  28769. * @returns this effect.
  28770. */
  28771. setArray(uniformName: string, array: number[]): Effect;
  28772. /**
  28773. * 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)
  28774. * @param uniformName Name of the variable.
  28775. * @param array array to be set.
  28776. * @returns this effect.
  28777. */
  28778. setArray2(uniformName: string, array: number[]): Effect;
  28779. /**
  28780. * 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)
  28781. * @param uniformName Name of the variable.
  28782. * @param array array to be set.
  28783. * @returns this effect.
  28784. */
  28785. setArray3(uniformName: string, array: number[]): Effect;
  28786. /**
  28787. * 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)
  28788. * @param uniformName Name of the variable.
  28789. * @param array array to be set.
  28790. * @returns this effect.
  28791. */
  28792. setArray4(uniformName: string, array: number[]): Effect;
  28793. /**
  28794. * Sets matrices on a uniform variable.
  28795. * @param uniformName Name of the variable.
  28796. * @param matrices matrices to be set.
  28797. * @returns this effect.
  28798. */
  28799. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28800. /**
  28801. * Sets matrix on a uniform variable.
  28802. * @param uniformName Name of the variable.
  28803. * @param matrix matrix to be set.
  28804. * @returns this effect.
  28805. */
  28806. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28807. /**
  28808. * 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)
  28809. * @param uniformName Name of the variable.
  28810. * @param matrix matrix to be set.
  28811. * @returns this effect.
  28812. */
  28813. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28814. /**
  28815. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28816. * @param uniformName Name of the variable.
  28817. * @param matrix matrix to be set.
  28818. * @returns this effect.
  28819. */
  28820. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28821. /**
  28822. * Sets a float on a uniform variable.
  28823. * @param uniformName Name of the variable.
  28824. * @param value value to be set.
  28825. * @returns this effect.
  28826. */
  28827. setFloat(uniformName: string, value: number): Effect;
  28828. /**
  28829. * Sets a boolean on a uniform variable.
  28830. * @param uniformName Name of the variable.
  28831. * @param bool value to be set.
  28832. * @returns this effect.
  28833. */
  28834. setBool(uniformName: string, bool: boolean): Effect;
  28835. /**
  28836. * Sets a Vector2 on a uniform variable.
  28837. * @param uniformName Name of the variable.
  28838. * @param vector2 vector2 to be set.
  28839. * @returns this effect.
  28840. */
  28841. setVector2(uniformName: string, vector2: Vector2): Effect;
  28842. /**
  28843. * Sets a float2 on a uniform variable.
  28844. * @param uniformName Name of the variable.
  28845. * @param x First float in float2.
  28846. * @param y Second float in float2.
  28847. * @returns this effect.
  28848. */
  28849. setFloat2(uniformName: string, x: number, y: number): Effect;
  28850. /**
  28851. * Sets a Vector3 on a uniform variable.
  28852. * @param uniformName Name of the variable.
  28853. * @param vector3 Value to be set.
  28854. * @returns this effect.
  28855. */
  28856. setVector3(uniformName: string, vector3: Vector3): Effect;
  28857. /**
  28858. * Sets a float3 on a uniform variable.
  28859. * @param uniformName Name of the variable.
  28860. * @param x First float in float3.
  28861. * @param y Second float in float3.
  28862. * @param z Third float in float3.
  28863. * @returns this effect.
  28864. */
  28865. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28866. /**
  28867. * Sets a Vector4 on a uniform variable.
  28868. * @param uniformName Name of the variable.
  28869. * @param vector4 Value to be set.
  28870. * @returns this effect.
  28871. */
  28872. setVector4(uniformName: string, vector4: Vector4): Effect;
  28873. /**
  28874. * Sets a float4 on a uniform variable.
  28875. * @param uniformName Name of the variable.
  28876. * @param x First float in float4.
  28877. * @param y Second float in float4.
  28878. * @param z Third float in float4.
  28879. * @param w Fourth float in float4.
  28880. * @returns this effect.
  28881. */
  28882. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28883. /**
  28884. * Sets a Color3 on a uniform variable.
  28885. * @param uniformName Name of the variable.
  28886. * @param color3 Value to be set.
  28887. * @returns this effect.
  28888. */
  28889. setColor3(uniformName: string, color3: Color3): Effect;
  28890. /**
  28891. * Sets a Color4 on a uniform variable.
  28892. * @param uniformName Name of the variable.
  28893. * @param color3 Value to be set.
  28894. * @param alpha Alpha value to be set.
  28895. * @returns this effect.
  28896. */
  28897. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28898. /**
  28899. * Sets a Color4 on a uniform variable
  28900. * @param uniformName defines the name of the variable
  28901. * @param color4 defines the value to be set
  28902. * @returns this effect.
  28903. */
  28904. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28905. /** Release all associated resources */
  28906. dispose(): void;
  28907. /**
  28908. * This function will add a new shader to the shader store
  28909. * @param name the name of the shader
  28910. * @param pixelShader optional pixel shader content
  28911. * @param vertexShader optional vertex shader content
  28912. */
  28913. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28914. /**
  28915. * Store of each shader (The can be looked up using effect.key)
  28916. */
  28917. static ShadersStore: {
  28918. [key: string]: string;
  28919. };
  28920. /**
  28921. * Store of each included file for a shader (The can be looked up using effect.key)
  28922. */
  28923. static IncludesShadersStore: {
  28924. [key: string]: string;
  28925. };
  28926. /**
  28927. * Resets the cache of effects.
  28928. */
  28929. static ResetCache(): void;
  28930. }
  28931. }
  28932. declare module BABYLON {
  28933. /**
  28934. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28935. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28936. * 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;
  28937. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28938. */
  28939. export class ColorCurves {
  28940. private _dirty;
  28941. private _tempColor;
  28942. private _globalCurve;
  28943. private _highlightsCurve;
  28944. private _midtonesCurve;
  28945. private _shadowsCurve;
  28946. private _positiveCurve;
  28947. private _negativeCurve;
  28948. private _globalHue;
  28949. private _globalDensity;
  28950. private _globalSaturation;
  28951. private _globalExposure;
  28952. /**
  28953. * Gets the global Hue value.
  28954. * 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).
  28955. */
  28956. /**
  28957. * Sets the global Hue value.
  28958. * 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).
  28959. */
  28960. globalHue: number;
  28961. /**
  28962. * Gets the global Density value.
  28963. * 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.
  28964. * Values less than zero provide a filter of opposite hue.
  28965. */
  28966. /**
  28967. * Sets the global Density value.
  28968. * 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.
  28969. * Values less than zero provide a filter of opposite hue.
  28970. */
  28971. globalDensity: number;
  28972. /**
  28973. * Gets the global Saturation value.
  28974. * 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.
  28975. */
  28976. /**
  28977. * Sets the global Saturation value.
  28978. * 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.
  28979. */
  28980. globalSaturation: number;
  28981. /**
  28982. * Gets the global Exposure value.
  28983. * 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.
  28984. */
  28985. /**
  28986. * Sets the global Exposure value.
  28987. * 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.
  28988. */
  28989. globalExposure: number;
  28990. private _highlightsHue;
  28991. private _highlightsDensity;
  28992. private _highlightsSaturation;
  28993. private _highlightsExposure;
  28994. /**
  28995. * Gets the highlights Hue value.
  28996. * 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).
  28997. */
  28998. /**
  28999. * Sets the highlights Hue value.
  29000. * 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).
  29001. */
  29002. highlightsHue: number;
  29003. /**
  29004. * Gets the highlights Density value.
  29005. * 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.
  29006. * Values less than zero provide a filter of opposite hue.
  29007. */
  29008. /**
  29009. * Sets the highlights Density value.
  29010. * 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.
  29011. * Values less than zero provide a filter of opposite hue.
  29012. */
  29013. highlightsDensity: number;
  29014. /**
  29015. * Gets the highlights Saturation value.
  29016. * 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.
  29017. */
  29018. /**
  29019. * Sets the highlights Saturation value.
  29020. * 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.
  29021. */
  29022. highlightsSaturation: number;
  29023. /**
  29024. * Gets the highlights Exposure value.
  29025. * 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.
  29026. */
  29027. /**
  29028. * Sets the highlights Exposure value.
  29029. * 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.
  29030. */
  29031. highlightsExposure: number;
  29032. private _midtonesHue;
  29033. private _midtonesDensity;
  29034. private _midtonesSaturation;
  29035. private _midtonesExposure;
  29036. /**
  29037. * Gets the midtones Hue value.
  29038. * 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).
  29039. */
  29040. /**
  29041. * Sets the midtones Hue value.
  29042. * 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).
  29043. */
  29044. midtonesHue: number;
  29045. /**
  29046. * Gets the midtones Density value.
  29047. * 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.
  29048. * Values less than zero provide a filter of opposite hue.
  29049. */
  29050. /**
  29051. * Sets the midtones Density value.
  29052. * 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.
  29053. * Values less than zero provide a filter of opposite hue.
  29054. */
  29055. midtonesDensity: number;
  29056. /**
  29057. * Gets the midtones Saturation value.
  29058. * 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.
  29059. */
  29060. /**
  29061. * Sets the midtones Saturation value.
  29062. * 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.
  29063. */
  29064. midtonesSaturation: number;
  29065. /**
  29066. * Gets the midtones Exposure 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 exposure and negative values decrease exposure.
  29068. */
  29069. /**
  29070. * Sets the midtones Exposure 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 exposure and negative values decrease exposure.
  29072. */
  29073. midtonesExposure: number;
  29074. private _shadowsHue;
  29075. private _shadowsDensity;
  29076. private _shadowsSaturation;
  29077. private _shadowsExposure;
  29078. /**
  29079. * Gets the shadows Hue value.
  29080. * 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).
  29081. */
  29082. /**
  29083. * Sets the shadows Hue value.
  29084. * 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).
  29085. */
  29086. shadowsHue: number;
  29087. /**
  29088. * Gets the shadows Density value.
  29089. * 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.
  29090. * Values less than zero provide a filter of opposite hue.
  29091. */
  29092. /**
  29093. * Sets the shadows Density value.
  29094. * 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.
  29095. * Values less than zero provide a filter of opposite hue.
  29096. */
  29097. shadowsDensity: number;
  29098. /**
  29099. * Gets the shadows Saturation value.
  29100. * 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.
  29101. */
  29102. /**
  29103. * Sets the shadows Saturation value.
  29104. * 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.
  29105. */
  29106. shadowsSaturation: number;
  29107. /**
  29108. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  29110. */
  29111. /**
  29112. * Sets the shadows Exposure 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 exposure and negative values decrease exposure.
  29114. */
  29115. shadowsExposure: number;
  29116. /**
  29117. * Returns the class name
  29118. * @returns The class name
  29119. */
  29120. getClassName(): string;
  29121. /**
  29122. * Binds the color curves to the shader.
  29123. * @param colorCurves The color curve to bind
  29124. * @param effect The effect to bind to
  29125. * @param positiveUniform The positive uniform shader parameter
  29126. * @param neutralUniform The neutral uniform shader parameter
  29127. * @param negativeUniform The negative uniform shader parameter
  29128. */
  29129. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29130. /**
  29131. * Prepare the list of uniforms associated with the ColorCurves effects.
  29132. * @param uniformsList The list of uniforms used in the effect
  29133. */
  29134. static PrepareUniforms(uniformsList: string[]): void;
  29135. /**
  29136. * Returns color grading data based on a hue, density, saturation and exposure value.
  29137. * @param filterHue The hue of the color filter.
  29138. * @param filterDensity The density of the color filter.
  29139. * @param saturation The saturation.
  29140. * @param exposure The exposure.
  29141. * @param result The result data container.
  29142. */
  29143. private getColorGradingDataToRef;
  29144. /**
  29145. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29146. * @param value The input slider value in range [-100,100].
  29147. * @returns Adjusted value.
  29148. */
  29149. private static applyColorGradingSliderNonlinear;
  29150. /**
  29151. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29152. * @param hue The hue (H) input.
  29153. * @param saturation The saturation (S) input.
  29154. * @param brightness The brightness (B) input.
  29155. * @result An RGBA color represented as Vector4.
  29156. */
  29157. private static fromHSBToRef;
  29158. /**
  29159. * Returns a value clamped between min and max
  29160. * @param value The value to clamp
  29161. * @param min The minimum of value
  29162. * @param max The maximum of value
  29163. * @returns The clamped value.
  29164. */
  29165. private static clamp;
  29166. /**
  29167. * Clones the current color curve instance.
  29168. * @return The cloned curves
  29169. */
  29170. clone(): ColorCurves;
  29171. /**
  29172. * Serializes the current color curve instance to a json representation.
  29173. * @return a JSON representation
  29174. */
  29175. serialize(): any;
  29176. /**
  29177. * Parses the color curve from a json representation.
  29178. * @param source the JSON source to parse
  29179. * @return The parsed curves
  29180. */
  29181. static Parse(source: any): ColorCurves;
  29182. }
  29183. }
  29184. declare module BABYLON {
  29185. /**
  29186. * Interface to follow in your material defines to integrate easily the
  29187. * Image proccessing functions.
  29188. * @hidden
  29189. */
  29190. export interface IImageProcessingConfigurationDefines {
  29191. IMAGEPROCESSING: boolean;
  29192. VIGNETTE: boolean;
  29193. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29194. VIGNETTEBLENDMODEOPAQUE: boolean;
  29195. TONEMAPPING: boolean;
  29196. TONEMAPPING_ACES: boolean;
  29197. CONTRAST: boolean;
  29198. EXPOSURE: boolean;
  29199. COLORCURVES: boolean;
  29200. COLORGRADING: boolean;
  29201. COLORGRADING3D: boolean;
  29202. SAMPLER3DGREENDEPTH: boolean;
  29203. SAMPLER3DBGRMAP: boolean;
  29204. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29205. }
  29206. /**
  29207. * @hidden
  29208. */
  29209. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29210. IMAGEPROCESSING: boolean;
  29211. VIGNETTE: boolean;
  29212. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29213. VIGNETTEBLENDMODEOPAQUE: boolean;
  29214. TONEMAPPING: boolean;
  29215. TONEMAPPING_ACES: boolean;
  29216. CONTRAST: boolean;
  29217. COLORCURVES: boolean;
  29218. COLORGRADING: boolean;
  29219. COLORGRADING3D: boolean;
  29220. SAMPLER3DGREENDEPTH: boolean;
  29221. SAMPLER3DBGRMAP: boolean;
  29222. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29223. EXPOSURE: boolean;
  29224. constructor();
  29225. }
  29226. /**
  29227. * This groups together the common properties used for image processing either in direct forward pass
  29228. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29229. * or not.
  29230. */
  29231. export class ImageProcessingConfiguration {
  29232. /**
  29233. * Default tone mapping applied in BabylonJS.
  29234. */
  29235. static readonly TONEMAPPING_STANDARD: number;
  29236. /**
  29237. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29238. * to other engines rendering to increase portability.
  29239. */
  29240. static readonly TONEMAPPING_ACES: number;
  29241. /**
  29242. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29243. */
  29244. colorCurves: Nullable<ColorCurves>;
  29245. private _colorCurvesEnabled;
  29246. /**
  29247. * Gets wether the color curves effect is enabled.
  29248. */
  29249. /**
  29250. * Sets wether the color curves effect is enabled.
  29251. */
  29252. colorCurvesEnabled: boolean;
  29253. private _colorGradingTexture;
  29254. /**
  29255. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29256. */
  29257. /**
  29258. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29259. */
  29260. colorGradingTexture: Nullable<BaseTexture>;
  29261. private _colorGradingEnabled;
  29262. /**
  29263. * Gets wether the color grading effect is enabled.
  29264. */
  29265. /**
  29266. * Sets wether the color grading effect is enabled.
  29267. */
  29268. colorGradingEnabled: boolean;
  29269. private _colorGradingWithGreenDepth;
  29270. /**
  29271. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29272. */
  29273. /**
  29274. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29275. */
  29276. colorGradingWithGreenDepth: boolean;
  29277. private _colorGradingBGR;
  29278. /**
  29279. * Gets wether the color grading texture contains BGR values.
  29280. */
  29281. /**
  29282. * Sets wether the color grading texture contains BGR values.
  29283. */
  29284. colorGradingBGR: boolean;
  29285. /** @hidden */ exposure: number;
  29286. /**
  29287. * Gets the Exposure used in the effect.
  29288. */
  29289. /**
  29290. * Sets the Exposure used in the effect.
  29291. */
  29292. exposure: number;
  29293. private _toneMappingEnabled;
  29294. /**
  29295. * Gets wether the tone mapping effect is enabled.
  29296. */
  29297. /**
  29298. * Sets wether the tone mapping effect is enabled.
  29299. */
  29300. toneMappingEnabled: boolean;
  29301. private _toneMappingType;
  29302. /**
  29303. * Gets the type of tone mapping effect.
  29304. */
  29305. /**
  29306. * Sets the type of tone mapping effect used in BabylonJS.
  29307. */
  29308. toneMappingType: number;
  29309. protected _contrast: number;
  29310. /**
  29311. * Gets the contrast used in the effect.
  29312. */
  29313. /**
  29314. * Sets the contrast used in the effect.
  29315. */
  29316. contrast: number;
  29317. /**
  29318. * Vignette stretch size.
  29319. */
  29320. vignetteStretch: number;
  29321. /**
  29322. * Vignette centre X Offset.
  29323. */
  29324. vignetteCentreX: number;
  29325. /**
  29326. * Vignette centre Y Offset.
  29327. */
  29328. vignetteCentreY: number;
  29329. /**
  29330. * Vignette weight or intensity of the vignette effect.
  29331. */
  29332. vignetteWeight: number;
  29333. /**
  29334. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29335. * if vignetteEnabled is set to true.
  29336. */
  29337. vignetteColor: Color4;
  29338. /**
  29339. * Camera field of view used by the Vignette effect.
  29340. */
  29341. vignetteCameraFov: number;
  29342. private _vignetteBlendMode;
  29343. /**
  29344. * Gets the vignette blend mode allowing different kind of effect.
  29345. */
  29346. /**
  29347. * Sets the vignette blend mode allowing different kind of effect.
  29348. */
  29349. vignetteBlendMode: number;
  29350. private _vignetteEnabled;
  29351. /**
  29352. * Gets wether the vignette effect is enabled.
  29353. */
  29354. /**
  29355. * Sets wether the vignette effect is enabled.
  29356. */
  29357. vignetteEnabled: boolean;
  29358. private _applyByPostProcess;
  29359. /**
  29360. * Gets wether the image processing is applied through a post process or not.
  29361. */
  29362. /**
  29363. * Sets wether the image processing is applied through a post process or not.
  29364. */
  29365. applyByPostProcess: boolean;
  29366. private _isEnabled;
  29367. /**
  29368. * Gets wether the image processing is enabled or not.
  29369. */
  29370. /**
  29371. * Sets wether the image processing is enabled or not.
  29372. */
  29373. isEnabled: boolean;
  29374. /**
  29375. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29376. */
  29377. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29378. /**
  29379. * Method called each time the image processing information changes requires to recompile the effect.
  29380. */
  29381. protected _updateParameters(): void;
  29382. /**
  29383. * Gets the current class name.
  29384. * @return "ImageProcessingConfiguration"
  29385. */
  29386. getClassName(): string;
  29387. /**
  29388. * Prepare the list of uniforms associated with the Image Processing effects.
  29389. * @param uniforms The list of uniforms used in the effect
  29390. * @param defines the list of defines currently in use
  29391. */
  29392. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29393. /**
  29394. * Prepare the list of samplers associated with the Image Processing effects.
  29395. * @param samplersList The list of uniforms used in the effect
  29396. * @param defines the list of defines currently in use
  29397. */
  29398. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29399. /**
  29400. * Prepare the list of defines associated to the shader.
  29401. * @param defines the list of defines to complete
  29402. * @param forPostProcess Define if we are currently in post process mode or not
  29403. */
  29404. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29405. /**
  29406. * Returns true if all the image processing information are ready.
  29407. * @returns True if ready, otherwise, false
  29408. */
  29409. isReady(): boolean;
  29410. /**
  29411. * Binds the image processing to the shader.
  29412. * @param effect The effect to bind to
  29413. * @param aspectRatio Define the current aspect ratio of the effect
  29414. */
  29415. bind(effect: Effect, aspectRatio?: number): void;
  29416. /**
  29417. * Clones the current image processing instance.
  29418. * @return The cloned image processing
  29419. */
  29420. clone(): ImageProcessingConfiguration;
  29421. /**
  29422. * Serializes the current image processing instance to a json representation.
  29423. * @return a JSON representation
  29424. */
  29425. serialize(): any;
  29426. /**
  29427. * Parses the image processing from a json representation.
  29428. * @param source the JSON source to parse
  29429. * @return The parsed image processing
  29430. */
  29431. static Parse(source: any): ImageProcessingConfiguration;
  29432. private static _VIGNETTEMODE_MULTIPLY;
  29433. private static _VIGNETTEMODE_OPAQUE;
  29434. /**
  29435. * Used to apply the vignette as a mix with the pixel color.
  29436. */
  29437. static readonly VIGNETTEMODE_MULTIPLY: number;
  29438. /**
  29439. * Used to apply the vignette as a replacement of the pixel color.
  29440. */
  29441. static readonly VIGNETTEMODE_OPAQUE: number;
  29442. }
  29443. }
  29444. declare module BABYLON {
  29445. /**
  29446. * This represents all the required information to add a fresnel effect on a material:
  29447. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29448. */
  29449. export class FresnelParameters {
  29450. private _isEnabled;
  29451. /**
  29452. * Define if the fresnel effect is enable or not.
  29453. */
  29454. isEnabled: boolean;
  29455. /**
  29456. * Define the color used on edges (grazing angle)
  29457. */
  29458. leftColor: Color3;
  29459. /**
  29460. * Define the color used on center
  29461. */
  29462. rightColor: Color3;
  29463. /**
  29464. * Define bias applied to computed fresnel term
  29465. */
  29466. bias: number;
  29467. /**
  29468. * Defined the power exponent applied to fresnel term
  29469. */
  29470. power: number;
  29471. /**
  29472. * Clones the current fresnel and its valuues
  29473. * @returns a clone fresnel configuration
  29474. */
  29475. clone(): FresnelParameters;
  29476. /**
  29477. * Serializes the current fresnel parameters to a JSON representation.
  29478. * @return the JSON serialization
  29479. */
  29480. serialize(): any;
  29481. /**
  29482. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29483. * @param parsedFresnelParameters Define the JSON representation
  29484. * @returns the parsed parameters
  29485. */
  29486. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29487. }
  29488. }
  29489. declare module BABYLON {
  29490. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29491. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29492. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29493. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29494. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29495. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29496. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29497. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29498. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29499. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29500. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29501. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29502. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29503. /**
  29504. * Decorator used to define property that can be serialized as reference to a camera
  29505. * @param sourceName defines the name of the property to decorate
  29506. */
  29507. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29508. /**
  29509. * Class used to help serialization objects
  29510. */
  29511. export class SerializationHelper {
  29512. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29513. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29514. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29515. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29516. /**
  29517. * Appends the serialized animations from the source animations
  29518. * @param source Source containing the animations
  29519. * @param destination Target to store the animations
  29520. */
  29521. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29522. /**
  29523. * Static function used to serialized a specific entity
  29524. * @param entity defines the entity to serialize
  29525. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29526. * @returns a JSON compatible object representing the serialization of the entity
  29527. */
  29528. static Serialize<T>(entity: T, serializationObject?: any): any;
  29529. /**
  29530. * Creates a new entity from a serialization data object
  29531. * @param creationFunction defines a function used to instanciated the new entity
  29532. * @param source defines the source serialization data
  29533. * @param scene defines the hosting scene
  29534. * @param rootUrl defines the root url for resources
  29535. * @returns a new entity
  29536. */
  29537. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29538. /**
  29539. * Clones an object
  29540. * @param creationFunction defines the function used to instanciate the new object
  29541. * @param source defines the source object
  29542. * @returns the cloned object
  29543. */
  29544. static Clone<T>(creationFunction: () => T, source: T): T;
  29545. /**
  29546. * Instanciates a new object based on a source one (some data will be shared between both object)
  29547. * @param creationFunction defines the function used to instanciate the new object
  29548. * @param source defines the source object
  29549. * @returns the new object
  29550. */
  29551. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29552. }
  29553. }
  29554. declare module BABYLON {
  29555. /**
  29556. * This is the base class of all the camera used in the application.
  29557. * @see http://doc.babylonjs.com/features/cameras
  29558. */
  29559. export class Camera extends Node {
  29560. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29561. /**
  29562. * This is the default projection mode used by the cameras.
  29563. * It helps recreating a feeling of perspective and better appreciate depth.
  29564. * This is the best way to simulate real life cameras.
  29565. */
  29566. static readonly PERSPECTIVE_CAMERA: number;
  29567. /**
  29568. * This helps creating camera with an orthographic mode.
  29569. * 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.
  29570. */
  29571. static readonly ORTHOGRAPHIC_CAMERA: number;
  29572. /**
  29573. * This is the default FOV mode for perspective cameras.
  29574. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29575. */
  29576. static readonly FOVMODE_VERTICAL_FIXED: number;
  29577. /**
  29578. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29579. */
  29580. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29581. /**
  29582. * This specifies ther is no need for a camera rig.
  29583. * Basically only one eye is rendered corresponding to the camera.
  29584. */
  29585. static readonly RIG_MODE_NONE: number;
  29586. /**
  29587. * Simulates a camera Rig with one blue eye and one red eye.
  29588. * This can be use with 3d blue and red glasses.
  29589. */
  29590. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29591. /**
  29592. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29593. */
  29594. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29595. /**
  29596. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29597. */
  29598. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29599. /**
  29600. * Defines that both eyes of the camera will be rendered over under each other.
  29601. */
  29602. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29603. /**
  29604. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29605. */
  29606. static readonly RIG_MODE_VR: number;
  29607. /**
  29608. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29609. */
  29610. static readonly RIG_MODE_WEBVR: number;
  29611. /**
  29612. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29613. */
  29614. static readonly RIG_MODE_CUSTOM: number;
  29615. /**
  29616. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29617. */
  29618. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29619. /**
  29620. * Define the input manager associated with the camera.
  29621. */
  29622. inputs: CameraInputsManager<Camera>;
  29623. /** @hidden */ position: Vector3;
  29624. /**
  29625. * Define the current local position of the camera in the scene
  29626. */
  29627. position: Vector3;
  29628. /**
  29629. * The vector the camera should consider as up.
  29630. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29631. */
  29632. upVector: Vector3;
  29633. /**
  29634. * Define the current limit on the left side for an orthographic camera
  29635. * In scene unit
  29636. */
  29637. orthoLeft: Nullable<number>;
  29638. /**
  29639. * Define the current limit on the right side for an orthographic camera
  29640. * In scene unit
  29641. */
  29642. orthoRight: Nullable<number>;
  29643. /**
  29644. * Define the current limit on the bottom side for an orthographic camera
  29645. * In scene unit
  29646. */
  29647. orthoBottom: Nullable<number>;
  29648. /**
  29649. * Define the current limit on the top side for an orthographic camera
  29650. * In scene unit
  29651. */
  29652. orthoTop: Nullable<number>;
  29653. /**
  29654. * Field Of View is set in Radians. (default is 0.8)
  29655. */
  29656. fov: number;
  29657. /**
  29658. * Define the minimum distance the camera can see from.
  29659. * This is important to note that the depth buffer are not infinite and the closer it starts
  29660. * the more your scene might encounter depth fighting issue.
  29661. */
  29662. minZ: number;
  29663. /**
  29664. * Define the maximum distance the camera can see to.
  29665. * This is important to note that the depth buffer are not infinite and the further it end
  29666. * the more your scene might encounter depth fighting issue.
  29667. */
  29668. maxZ: number;
  29669. /**
  29670. * Define the default inertia of the camera.
  29671. * This helps giving a smooth feeling to the camera movement.
  29672. */
  29673. inertia: number;
  29674. /**
  29675. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29676. */
  29677. mode: number;
  29678. /**
  29679. * Define wether the camera is intermediate.
  29680. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29681. */
  29682. isIntermediate: boolean;
  29683. /**
  29684. * Define the viewport of the camera.
  29685. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29686. */
  29687. viewport: Viewport;
  29688. /**
  29689. * Restricts the camera to viewing objects with the same layerMask.
  29690. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29691. */
  29692. layerMask: number;
  29693. /**
  29694. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29695. */
  29696. fovMode: number;
  29697. /**
  29698. * Rig mode of the camera.
  29699. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29700. * This is normally controlled byt the camera themselves as internal use.
  29701. */
  29702. cameraRigMode: number;
  29703. /**
  29704. * Defines the distance between both "eyes" in case of a RIG
  29705. */
  29706. interaxialDistance: number;
  29707. /**
  29708. * Defines if stereoscopic rendering is done side by side or over under.
  29709. */
  29710. isStereoscopicSideBySide: boolean;
  29711. /**
  29712. * 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
  29713. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29714. * else in the scene.
  29715. */
  29716. customRenderTargets: RenderTargetTexture[];
  29717. /**
  29718. * When set, the camera will render to this render target instead of the default canvas
  29719. */
  29720. outputRenderTarget: Nullable<RenderTargetTexture>;
  29721. /**
  29722. * Observable triggered when the camera view matrix has changed.
  29723. */
  29724. onViewMatrixChangedObservable: Observable<Camera>;
  29725. /**
  29726. * Observable triggered when the camera Projection matrix has changed.
  29727. */
  29728. onProjectionMatrixChangedObservable: Observable<Camera>;
  29729. /**
  29730. * Observable triggered when the inputs have been processed.
  29731. */
  29732. onAfterCheckInputsObservable: Observable<Camera>;
  29733. /**
  29734. * Observable triggered when reset has been called and applied to the camera.
  29735. */
  29736. onRestoreStateObservable: Observable<Camera>;
  29737. /** @hidden */ cameraRigParams: any;
  29738. /** @hidden */ rigCameras: Camera[];
  29739. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  29740. protected _webvrViewMatrix: Matrix;
  29741. /** @hidden */ skipRendering: boolean;
  29742. /** @hidden */ projectionMatrix: Matrix;
  29743. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  29744. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  29745. protected _globalPosition: Vector3;
  29746. /** hidden */ computedViewMatrix: Matrix;
  29747. private _doNotComputeProjectionMatrix;
  29748. private _transformMatrix;
  29749. private _frustumPlanes;
  29750. private _refreshFrustumPlanes;
  29751. private _storedFov;
  29752. private _stateStored;
  29753. /**
  29754. * Instantiates a new camera object.
  29755. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29756. * @see http://doc.babylonjs.com/features/cameras
  29757. * @param name Defines the name of the camera in the scene
  29758. * @param position Defines the position of the camera
  29759. * @param scene Defines the scene the camera belongs too
  29760. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29761. */
  29762. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29763. /**
  29764. * Store current camera state (fov, position, etc..)
  29765. * @returns the camera
  29766. */
  29767. storeState(): Camera;
  29768. /**
  29769. * Restores the camera state values if it has been stored. You must call storeState() first
  29770. */
  29771. protected _restoreStateValues(): boolean;
  29772. /**
  29773. * Restored camera state. You must call storeState() first.
  29774. * @returns true if restored and false otherwise
  29775. */
  29776. restoreState(): boolean;
  29777. /**
  29778. * Gets the class name of the camera.
  29779. * @returns the class name
  29780. */
  29781. getClassName(): string;
  29782. /** @hidden */ protected readonly _isCamera: boolean;
  29783. /**
  29784. * Gets a string representation of the camera useful for debug purpose.
  29785. * @param fullDetails Defines that a more verboe level of logging is required
  29786. * @returns the string representation
  29787. */
  29788. toString(fullDetails?: boolean): string;
  29789. /**
  29790. * Gets the current world space position of the camera.
  29791. */
  29792. readonly globalPosition: Vector3;
  29793. /**
  29794. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29795. * @returns the active meshe list
  29796. */
  29797. getActiveMeshes(): SmartArray<AbstractMesh>;
  29798. /**
  29799. * Check wether a mesh is part of the current active mesh list of the camera
  29800. * @param mesh Defines the mesh to check
  29801. * @returns true if active, false otherwise
  29802. */
  29803. isActiveMesh(mesh: Mesh): boolean;
  29804. /**
  29805. * Is this camera ready to be used/rendered
  29806. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29807. * @return true if the camera is ready
  29808. */
  29809. isReady(completeCheck?: boolean): boolean;
  29810. /** @hidden */ initCache(): void;
  29811. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29812. /** @hidden */ isSynchronized(): boolean;
  29813. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29814. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29815. /**
  29816. * Attach the input controls to a specific dom element to get the input from.
  29817. * @param element Defines the element the controls should be listened from
  29818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29819. */
  29820. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29821. /**
  29822. * Detach the current controls from the specified dom element.
  29823. * @param element Defines the element to stop listening the inputs from
  29824. */
  29825. detachControl(element: HTMLElement): void;
  29826. /**
  29827. * Update the camera state according to the different inputs gathered during the frame.
  29828. */
  29829. update(): void;
  29830. /** @hidden */ checkInputs(): void;
  29831. /** @hidden */
  29832. readonly rigCameras: Camera[];
  29833. /**
  29834. * Gets the post process used by the rig cameras
  29835. */
  29836. readonly rigPostProcess: Nullable<PostProcess>;
  29837. /**
  29838. * Internal, gets the first post proces.
  29839. * @returns the first post process to be run on this camera.
  29840. */ getFirstPostProcess(): Nullable<PostProcess>;
  29841. private _cascadePostProcessesToRigCams;
  29842. /**
  29843. * Attach a post process to the camera.
  29844. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29845. * @param postProcess The post process to attach to the camera
  29846. * @param insertAt The position of the post process in case several of them are in use in the scene
  29847. * @returns the position the post process has been inserted at
  29848. */
  29849. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29850. /**
  29851. * Detach a post process to the camera.
  29852. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29853. * @param postProcess The post process to detach from the camera
  29854. */
  29855. detachPostProcess(postProcess: PostProcess): void;
  29856. /**
  29857. * Gets the current world matrix of the camera
  29858. */
  29859. getWorldMatrix(): Matrix;
  29860. /** @hidden */ getViewMatrix(): Matrix;
  29861. /**
  29862. * Gets the current view matrix of the camera.
  29863. * @param force forces the camera to recompute the matrix without looking at the cached state
  29864. * @returns the view matrix
  29865. */
  29866. getViewMatrix(force?: boolean): Matrix;
  29867. /**
  29868. * Freeze the projection matrix.
  29869. * It will prevent the cache check of the camera projection compute and can speed up perf
  29870. * if no parameter of the camera are meant to change
  29871. * @param projection Defines manually a projection if necessary
  29872. */
  29873. freezeProjectionMatrix(projection?: Matrix): void;
  29874. /**
  29875. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29876. */
  29877. unfreezeProjectionMatrix(): void;
  29878. /**
  29879. * Gets the current projection matrix of the camera.
  29880. * @param force forces the camera to recompute the matrix without looking at the cached state
  29881. * @returns the projection matrix
  29882. */
  29883. getProjectionMatrix(force?: boolean): Matrix;
  29884. /**
  29885. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29886. * @returns a Matrix
  29887. */
  29888. getTransformationMatrix(): Matrix;
  29889. private _updateFrustumPlanes;
  29890. /**
  29891. * Checks if a cullable object (mesh...) is in the camera frustum
  29892. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29893. * @param target The object to check
  29894. * @returns true if the object is in frustum otherwise false
  29895. */
  29896. isInFrustum(target: ICullable): boolean;
  29897. /**
  29898. * Checks if a cullable object (mesh...) is in the camera frustum
  29899. * Unlike isInFrustum this cheks the full bounding box
  29900. * @param target The object to check
  29901. * @returns true if the object is in frustum otherwise false
  29902. */
  29903. isCompletelyInFrustum(target: ICullable): boolean;
  29904. /**
  29905. * Gets a ray in the forward direction from the camera.
  29906. * @param length Defines the length of the ray to create
  29907. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29908. * @param origin Defines the start point of the ray which defaults to the camera position
  29909. * @returns the forward ray
  29910. */
  29911. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29912. /**
  29913. * Releases resources associated with this node.
  29914. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29915. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29916. */
  29917. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29918. /** @hidden */ isLeftCamera: boolean;
  29919. /**
  29920. * Gets the left camera of a rig setup in case of Rigged Camera
  29921. */
  29922. readonly isLeftCamera: boolean;
  29923. /** @hidden */ isRightCamera: boolean;
  29924. /**
  29925. * Gets the right camera of a rig setup in case of Rigged Camera
  29926. */
  29927. readonly isRightCamera: boolean;
  29928. /**
  29929. * Gets the left camera of a rig setup in case of Rigged Camera
  29930. */
  29931. readonly leftCamera: Nullable<FreeCamera>;
  29932. /**
  29933. * Gets the right camera of a rig setup in case of Rigged Camera
  29934. */
  29935. readonly rightCamera: Nullable<FreeCamera>;
  29936. /**
  29937. * Gets the left camera target of a rig setup in case of Rigged Camera
  29938. * @returns the target position
  29939. */
  29940. getLeftTarget(): Nullable<Vector3>;
  29941. /**
  29942. * Gets the right camera target of a rig setup in case of Rigged Camera
  29943. * @returns the target position
  29944. */
  29945. getRightTarget(): Nullable<Vector3>;
  29946. /**
  29947. * @hidden
  29948. */
  29949. setCameraRigMode(mode: number, rigParams: any): void;
  29950. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  29951. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29952. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  29953. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29954. /** @hidden */ getVRProjectionMatrix(): Matrix;
  29955. protected _updateCameraRotationMatrix(): void;
  29956. protected _updateWebVRCameraRotationMatrix(): void;
  29957. /**
  29958. * This function MUST be overwritten by the different WebVR cameras available.
  29959. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29960. * @hidden
  29961. */ getWebVRProjectionMatrix(): Matrix;
  29962. /**
  29963. * This function MUST be overwritten by the different WebVR cameras available.
  29964. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29965. * @hidden
  29966. */ getWebVRViewMatrix(): Matrix;
  29967. /** @hidden */
  29968. setCameraRigParameter(name: string, value: any): void;
  29969. /**
  29970. * needs to be overridden by children so sub has required properties to be copied
  29971. * @hidden
  29972. */
  29973. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29974. /**
  29975. * May need to be overridden by children
  29976. * @hidden
  29977. */ updateRigCameras(): void;
  29978. /** @hidden */ setupInputs(): void;
  29979. /**
  29980. * Serialiaze the camera setup to a json represention
  29981. * @returns the JSON representation
  29982. */
  29983. serialize(): any;
  29984. /**
  29985. * Clones the current camera.
  29986. * @param name The cloned camera name
  29987. * @returns the cloned camera
  29988. */
  29989. clone(name: string): Camera;
  29990. /**
  29991. * Gets the direction of the camera relative to a given local axis.
  29992. * @param localAxis Defines the reference axis to provide a relative direction.
  29993. * @return the direction
  29994. */
  29995. getDirection(localAxis: Vector3): Vector3;
  29996. /**
  29997. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29998. * @param localAxis Defines the reference axis to provide a relative direction.
  29999. * @param result Defines the vector to store the result in
  30000. */
  30001. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30002. /**
  30003. * Gets a camera constructor for a given camera type
  30004. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30005. * @param name The name of the camera the result will be able to instantiate
  30006. * @param scene The scene the result will construct the camera in
  30007. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30008. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30009. * @returns a factory method to construc the camera
  30010. */
  30011. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30012. /**
  30013. * Compute the world matrix of the camera.
  30014. * @returns the camera workd matrix
  30015. */
  30016. computeWorldMatrix(): Matrix;
  30017. /**
  30018. * Parse a JSON and creates the camera from the parsed information
  30019. * @param parsedCamera The JSON to parse
  30020. * @param scene The scene to instantiate the camera in
  30021. * @returns the newly constructed camera
  30022. */
  30023. static Parse(parsedCamera: any, scene: Scene): Camera;
  30024. }
  30025. }
  30026. declare module BABYLON {
  30027. /**
  30028. * Interface for any object that can request an animation frame
  30029. */
  30030. export interface ICustomAnimationFrameRequester {
  30031. /**
  30032. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30033. */
  30034. renderFunction?: Function;
  30035. /**
  30036. * Called to request the next frame to render to
  30037. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30038. */
  30039. requestAnimationFrame: Function;
  30040. /**
  30041. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30042. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30043. */
  30044. requestID?: number;
  30045. }
  30046. /**
  30047. * Interface containing an array of animations
  30048. */
  30049. export interface IAnimatable {
  30050. /**
  30051. * Array of animations
  30052. */
  30053. animations: Nullable<Array<Animation>>;
  30054. }
  30055. /** Interface used by value gradients (color, factor, ...) */
  30056. export interface IValueGradient {
  30057. /**
  30058. * Gets or sets the gradient value (between 0 and 1)
  30059. */
  30060. gradient: number;
  30061. }
  30062. /** Class used to store color4 gradient */
  30063. export class ColorGradient implements IValueGradient {
  30064. /**
  30065. * Gets or sets the gradient value (between 0 and 1)
  30066. */
  30067. gradient: number;
  30068. /**
  30069. * Gets or sets first associated color
  30070. */
  30071. color1: Color4;
  30072. /**
  30073. * Gets or sets second associated color
  30074. */
  30075. color2?: Color4;
  30076. /**
  30077. * Will get a color picked randomly between color1 and color2.
  30078. * If color2 is undefined then color1 will be used
  30079. * @param result defines the target Color4 to store the result in
  30080. */
  30081. getColorToRef(result: Color4): void;
  30082. }
  30083. /** Class used to store color 3 gradient */
  30084. export class Color3Gradient implements IValueGradient {
  30085. /**
  30086. * Gets or sets the gradient value (between 0 and 1)
  30087. */
  30088. gradient: number;
  30089. /**
  30090. * Gets or sets the associated color
  30091. */
  30092. color: Color3;
  30093. }
  30094. /** Class used to store factor gradient */
  30095. export class FactorGradient implements IValueGradient {
  30096. /**
  30097. * Gets or sets the gradient value (between 0 and 1)
  30098. */
  30099. gradient: number;
  30100. /**
  30101. * Gets or sets first associated factor
  30102. */
  30103. factor1: number;
  30104. /**
  30105. * Gets or sets second associated factor
  30106. */
  30107. factor2?: number;
  30108. /**
  30109. * Will get a number picked randomly between factor1 and factor2.
  30110. * If factor2 is undefined then factor1 will be used
  30111. * @returns the picked number
  30112. */
  30113. getFactor(): number;
  30114. }
  30115. /**
  30116. * @ignore
  30117. * Application error to support additional information when loading a file
  30118. */
  30119. export class LoadFileError extends Error {
  30120. /** defines the optional web request */
  30121. request?: WebRequest | undefined;
  30122. private static _setPrototypeOf;
  30123. /**
  30124. * Creates a new LoadFileError
  30125. * @param message defines the message of the error
  30126. * @param request defines the optional web request
  30127. */
  30128. constructor(message: string,
  30129. /** defines the optional web request */
  30130. request?: WebRequest | undefined);
  30131. }
  30132. /**
  30133. * Class used to define a retry strategy when error happens while loading assets
  30134. */
  30135. export class RetryStrategy {
  30136. /**
  30137. * Function used to defines an exponential back off strategy
  30138. * @param maxRetries defines the maximum number of retries (3 by default)
  30139. * @param baseInterval defines the interval between retries
  30140. * @returns the strategy function to use
  30141. */
  30142. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30143. }
  30144. /**
  30145. * File request interface
  30146. */
  30147. export interface IFileRequest {
  30148. /**
  30149. * Raised when the request is complete (success or error).
  30150. */
  30151. onCompleteObservable: Observable<IFileRequest>;
  30152. /**
  30153. * Aborts the request for a file.
  30154. */
  30155. abort: () => void;
  30156. }
  30157. /**
  30158. * Class containing a set of static utilities functions
  30159. */
  30160. export class Tools {
  30161. /**
  30162. * Gets or sets the base URL to use to load assets
  30163. */
  30164. static BaseUrl: string;
  30165. /**
  30166. * Enable/Disable Custom HTTP Request Headers globally.
  30167. * default = false
  30168. * @see CustomRequestHeaders
  30169. */
  30170. static UseCustomRequestHeaders: boolean;
  30171. /**
  30172. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30173. * i.e. when loading files, where the server/service expects an Authorization header
  30174. */
  30175. static CustomRequestHeaders: {
  30176. [key: string]: string;
  30177. };
  30178. /**
  30179. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30180. */
  30181. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30182. /**
  30183. * Default behaviour for cors in the application.
  30184. * It can be a string if the expected behavior is identical in the entire app.
  30185. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30186. */
  30187. static CorsBehavior: string | ((url: string | string[]) => string);
  30188. /**
  30189. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30190. * @ignorenaming
  30191. */
  30192. static UseFallbackTexture: boolean;
  30193. /**
  30194. * Use this object to register external classes like custom textures or material
  30195. * to allow the laoders to instantiate them
  30196. */
  30197. static RegisteredExternalClasses: {
  30198. [key: string]: Object;
  30199. };
  30200. /**
  30201. * Texture content used if a texture cannot loaded
  30202. * @ignorenaming
  30203. */
  30204. static fallbackTexture: string;
  30205. /**
  30206. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30207. * @param u defines the coordinate on X axis
  30208. * @param v defines the coordinate on Y axis
  30209. * @param width defines the width of the source data
  30210. * @param height defines the height of the source data
  30211. * @param pixels defines the source byte array
  30212. * @param color defines the output color
  30213. */
  30214. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30215. /**
  30216. * Interpolates between a and b via alpha
  30217. * @param a The lower value (returned when alpha = 0)
  30218. * @param b The upper value (returned when alpha = 1)
  30219. * @param alpha The interpolation-factor
  30220. * @return The mixed value
  30221. */
  30222. static Mix(a: number, b: number, alpha: number): number;
  30223. /**
  30224. * Tries to instantiate a new object from a given class name
  30225. * @param className defines the class name to instantiate
  30226. * @returns the new object or null if the system was not able to do the instantiation
  30227. */
  30228. static Instantiate(className: string): any;
  30229. /**
  30230. * Provides a slice function that will work even on IE
  30231. * @param data defines the array to slice
  30232. * @param start defines the start of the data (optional)
  30233. * @param end defines the end of the data (optional)
  30234. * @returns the new sliced array
  30235. */
  30236. static Slice<T>(data: T, start?: number, end?: number): T;
  30237. /**
  30238. * Polyfill for setImmediate
  30239. * @param action defines the action to execute after the current execution block
  30240. */
  30241. static SetImmediate(action: () => void): void;
  30242. /**
  30243. * Function indicating if a number is an exponent of 2
  30244. * @param value defines the value to test
  30245. * @returns true if the value is an exponent of 2
  30246. */
  30247. static IsExponentOfTwo(value: number): boolean;
  30248. private static _tmpFloatArray;
  30249. /**
  30250. * Returns the nearest 32-bit single precision float representation of a Number
  30251. * @param value A Number. If the parameter is of a different type, it will get converted
  30252. * to a number or to NaN if it cannot be converted
  30253. * @returns number
  30254. */
  30255. static FloatRound(value: number): number;
  30256. /**
  30257. * Find the next highest power of two.
  30258. * @param x Number to start search from.
  30259. * @return Next highest power of two.
  30260. */
  30261. static CeilingPOT(x: number): number;
  30262. /**
  30263. * Find the next lowest power of two.
  30264. * @param x Number to start search from.
  30265. * @return Next lowest power of two.
  30266. */
  30267. static FloorPOT(x: number): number;
  30268. /**
  30269. * Find the nearest power of two.
  30270. * @param x Number to start search from.
  30271. * @return Next nearest power of two.
  30272. */
  30273. static NearestPOT(x: number): number;
  30274. /**
  30275. * Get the closest exponent of two
  30276. * @param value defines the value to approximate
  30277. * @param max defines the maximum value to return
  30278. * @param mode defines how to define the closest value
  30279. * @returns closest exponent of two of the given value
  30280. */
  30281. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30282. /**
  30283. * Extracts the filename from a path
  30284. * @param path defines the path to use
  30285. * @returns the filename
  30286. */
  30287. static GetFilename(path: string): string;
  30288. /**
  30289. * Extracts the "folder" part of a path (everything before the filename).
  30290. * @param uri The URI to extract the info from
  30291. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30292. * @returns The "folder" part of the path
  30293. */
  30294. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30295. /**
  30296. * Extracts text content from a DOM element hierarchy
  30297. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30298. */
  30299. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30300. /**
  30301. * Convert an angle in radians to degrees
  30302. * @param angle defines the angle to convert
  30303. * @returns the angle in degrees
  30304. */
  30305. static ToDegrees(angle: number): number;
  30306. /**
  30307. * Convert an angle in degrees to radians
  30308. * @param angle defines the angle to convert
  30309. * @returns the angle in radians
  30310. */
  30311. static ToRadians(angle: number): number;
  30312. /**
  30313. * Encode a buffer to a base64 string
  30314. * @param buffer defines the buffer to encode
  30315. * @returns the encoded string
  30316. */
  30317. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30318. /**
  30319. * Extracts minimum and maximum values from a list of indexed positions
  30320. * @param positions defines the positions to use
  30321. * @param indices defines the indices to the positions
  30322. * @param indexStart defines the start index
  30323. * @param indexCount defines the end index
  30324. * @param bias defines bias value to add to the result
  30325. * @return minimum and maximum values
  30326. */
  30327. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30328. minimum: Vector3;
  30329. maximum: Vector3;
  30330. };
  30331. /**
  30332. * Extracts minimum and maximum values from a list of positions
  30333. * @param positions defines the positions to use
  30334. * @param start defines the start index in the positions array
  30335. * @param count defines the number of positions to handle
  30336. * @param bias defines bias value to add to the result
  30337. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30338. * @return minimum and maximum values
  30339. */
  30340. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30341. minimum: Vector3;
  30342. maximum: Vector3;
  30343. };
  30344. /**
  30345. * Returns an array if obj is not an array
  30346. * @param obj defines the object to evaluate as an array
  30347. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30348. * @returns either obj directly if obj is an array or a new array containing obj
  30349. */
  30350. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30351. /**
  30352. * Gets the pointer prefix to use
  30353. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30354. */
  30355. static GetPointerPrefix(): string;
  30356. /**
  30357. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30358. * @param func - the function to be called
  30359. * @param requester - the object that will request the next frame. Falls back to window.
  30360. * @returns frame number
  30361. */
  30362. static QueueNewFrame(func: () => void, requester?: any): number;
  30363. /**
  30364. * Ask the browser to promote the current element to fullscreen rendering mode
  30365. * @param element defines the DOM element to promote
  30366. */
  30367. static RequestFullscreen(element: HTMLElement): void;
  30368. /**
  30369. * Asks the browser to exit fullscreen mode
  30370. */
  30371. static ExitFullscreen(): void;
  30372. /**
  30373. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30374. * @param url define the url we are trying
  30375. * @param element define the dom element where to configure the cors policy
  30376. */
  30377. static SetCorsBehavior(url: string | string[], element: {
  30378. crossOrigin: string | null;
  30379. }): void;
  30380. /**
  30381. * Removes unwanted characters from an url
  30382. * @param url defines the url to clean
  30383. * @returns the cleaned url
  30384. */
  30385. static CleanUrl(url: string): string;
  30386. /**
  30387. * Gets or sets a function used to pre-process url before using them to load assets
  30388. */
  30389. static PreprocessUrl: (url: string) => string;
  30390. /**
  30391. * Loads an image as an HTMLImageElement.
  30392. * @param input url string, ArrayBuffer, or Blob to load
  30393. * @param onLoad callback called when the image successfully loads
  30394. * @param onError callback called when the image fails to load
  30395. * @param offlineProvider offline provider for caching
  30396. * @returns the HTMLImageElement of the loaded image
  30397. */
  30398. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30399. /**
  30400. * Loads a file
  30401. * @param url url string, ArrayBuffer, or Blob to load
  30402. * @param onSuccess callback called when the file successfully loads
  30403. * @param onProgress callback called while file is loading (if the server supports this mode)
  30404. * @param offlineProvider defines the offline provider for caching
  30405. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30406. * @param onError callback called when the file fails to load
  30407. * @returns a file request object
  30408. */
  30409. 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;
  30410. /**
  30411. * Load a script (identified by an url). When the url returns, the
  30412. * content of this file is added into a new script element, attached to the DOM (body element)
  30413. * @param scriptUrl defines the url of the script to laod
  30414. * @param onSuccess defines the callback called when the script is loaded
  30415. * @param onError defines the callback to call if an error occurs
  30416. * @param scriptId defines the id of the script element
  30417. */
  30418. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30419. /**
  30420. * Load an asynchronous script (identified by an url). When the url returns, the
  30421. * content of this file is added into a new script element, attached to the DOM (body element)
  30422. * @param scriptUrl defines the url of the script to laod
  30423. * @param scriptId defines the id of the script element
  30424. * @returns a promise request object
  30425. */
  30426. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30427. /**
  30428. * Loads a file from a blob
  30429. * @param fileToLoad defines the blob to use
  30430. * @param callback defines the callback to call when data is loaded
  30431. * @param progressCallback defines the callback to call during loading process
  30432. * @returns a file request object
  30433. */
  30434. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30435. /**
  30436. * Loads a file
  30437. * @param fileToLoad defines the file to load
  30438. * @param callback defines the callback to call when data is loaded
  30439. * @param progressCallBack defines the callback to call during loading process
  30440. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30441. * @returns a file request object
  30442. */
  30443. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30444. /**
  30445. * Creates a data url from a given string content
  30446. * @param content defines the content to convert
  30447. * @returns the new data url link
  30448. */
  30449. static FileAsURL(content: string): string;
  30450. /**
  30451. * Format the given number to a specific decimal format
  30452. * @param value defines the number to format
  30453. * @param decimals defines the number of decimals to use
  30454. * @returns the formatted string
  30455. */
  30456. static Format(value: number, decimals?: number): string;
  30457. /**
  30458. * Checks if a given vector is inside a specific range
  30459. * @param v defines the vector to test
  30460. * @param min defines the minimum range
  30461. * @param max defines the maximum range
  30462. */
  30463. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30464. /**
  30465. * Tries to copy an object by duplicating every property
  30466. * @param source defines the source object
  30467. * @param destination defines the target object
  30468. * @param doNotCopyList defines a list of properties to avoid
  30469. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30470. */
  30471. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30472. /**
  30473. * Gets a boolean indicating if the given object has no own property
  30474. * @param obj defines the object to test
  30475. * @returns true if object has no own property
  30476. */
  30477. static IsEmpty(obj: any): boolean;
  30478. /**
  30479. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30480. * @param str Source string
  30481. * @param suffix Suffix to search for in the source string
  30482. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30483. */
  30484. static EndsWith(str: string, suffix: string): boolean;
  30485. /**
  30486. * Function used to register events at window level
  30487. * @param events defines the events to register
  30488. */
  30489. static RegisterTopRootEvents(events: {
  30490. name: string;
  30491. handler: Nullable<(e: FocusEvent) => any>;
  30492. }[]): void;
  30493. /**
  30494. * Function used to unregister events from window level
  30495. * @param events defines the events to unregister
  30496. */
  30497. static UnregisterTopRootEvents(events: {
  30498. name: string;
  30499. handler: Nullable<(e: FocusEvent) => any>;
  30500. }[]): void;
  30501. /**
  30502. * @ignore
  30503. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30504. /**
  30505. * Dumps the current bound framebuffer
  30506. * @param width defines the rendering width
  30507. * @param height defines the rendering height
  30508. * @param engine defines the hosting engine
  30509. * @param successCallback defines the callback triggered once the data are available
  30510. * @param mimeType defines the mime type of the result
  30511. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30512. */
  30513. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30514. /**
  30515. * Converts the canvas data to blob.
  30516. * This acts as a polyfill for browsers not supporting the to blob function.
  30517. * @param canvas Defines the canvas to extract the data from
  30518. * @param successCallback Defines the callback triggered once the data are available
  30519. * @param mimeType Defines the mime type of the result
  30520. */
  30521. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30522. /**
  30523. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30524. * @param successCallback defines the callback triggered once the data are available
  30525. * @param mimeType defines the mime type of the result
  30526. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30527. */
  30528. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30529. /**
  30530. * Downloads a blob in the browser
  30531. * @param blob defines the blob to download
  30532. * @param fileName defines the name of the downloaded file
  30533. */
  30534. static Download(blob: Blob, fileName: string): void;
  30535. /**
  30536. * Captures a screenshot of the current rendering
  30537. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30538. * @param engine defines the rendering engine
  30539. * @param camera defines the source camera
  30540. * @param size This parameter can be set to a single number or to an object with the
  30541. * following (optional) properties: precision, width, height. If a single number is passed,
  30542. * it will be used for both width and height. If an object is passed, the screenshot size
  30543. * will be derived from the parameters. The precision property is a multiplier allowing
  30544. * rendering at a higher or lower resolution
  30545. * @param successCallback defines the callback receives a single parameter which contains the
  30546. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30547. * src parameter of an <img> to display it
  30548. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30549. * Check your browser for supported MIME types
  30550. */
  30551. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30552. /**
  30553. * Generates an image screenshot from the specified camera.
  30554. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30555. * @param engine The engine to use for rendering
  30556. * @param camera The camera to use for rendering
  30557. * @param size This parameter can be set to a single number or to an object with the
  30558. * following (optional) properties: precision, width, height. If a single number is passed,
  30559. * it will be used for both width and height. If an object is passed, the screenshot size
  30560. * will be derived from the parameters. The precision property is a multiplier allowing
  30561. * rendering at a higher or lower resolution
  30562. * @param successCallback The callback receives a single parameter which contains the
  30563. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30564. * src parameter of an <img> to display it
  30565. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30566. * Check your browser for supported MIME types
  30567. * @param samples Texture samples (default: 1)
  30568. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30569. * @param fileName A name for for the downloaded file.
  30570. */
  30571. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30572. /**
  30573. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30574. * Be aware Math.random() could cause collisions, but:
  30575. * "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"
  30576. * @returns a pseudo random id
  30577. */
  30578. static RandomId(): string;
  30579. /**
  30580. * Test if the given uri is a base64 string
  30581. * @param uri The uri to test
  30582. * @return True if the uri is a base64 string or false otherwise
  30583. */
  30584. static IsBase64(uri: string): boolean;
  30585. /**
  30586. * Decode the given base64 uri.
  30587. * @param uri The uri to decode
  30588. * @return The decoded base64 data.
  30589. */
  30590. static DecodeBase64(uri: string): ArrayBuffer;
  30591. /**
  30592. * Gets the absolute url.
  30593. * @param url the input url
  30594. * @return the absolute url
  30595. */
  30596. static GetAbsoluteUrl(url: string): string;
  30597. /**
  30598. * No log
  30599. */
  30600. static readonly NoneLogLevel: number;
  30601. /**
  30602. * Only message logs
  30603. */
  30604. static readonly MessageLogLevel: number;
  30605. /**
  30606. * Only warning logs
  30607. */
  30608. static readonly WarningLogLevel: number;
  30609. /**
  30610. * Only error logs
  30611. */
  30612. static readonly ErrorLogLevel: number;
  30613. /**
  30614. * All logs
  30615. */
  30616. static readonly AllLogLevel: number;
  30617. /**
  30618. * Gets a value indicating the number of loading errors
  30619. * @ignorenaming
  30620. */
  30621. static readonly errorsCount: number;
  30622. /**
  30623. * Callback called when a new log is added
  30624. */
  30625. static OnNewCacheEntry: (entry: string) => void;
  30626. /**
  30627. * Log a message to the console
  30628. * @param message defines the message to log
  30629. */
  30630. static Log(message: string): void;
  30631. /**
  30632. * Write a warning message to the console
  30633. * @param message defines the message to log
  30634. */
  30635. static Warn(message: string): void;
  30636. /**
  30637. * Write an error message to the console
  30638. * @param message defines the message to log
  30639. */
  30640. static Error(message: string): void;
  30641. /**
  30642. * Gets current log cache (list of logs)
  30643. */
  30644. static readonly LogCache: string;
  30645. /**
  30646. * Clears the log cache
  30647. */
  30648. static ClearLogCache(): void;
  30649. /**
  30650. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30651. */
  30652. static LogLevels: number;
  30653. /**
  30654. * Checks if the loaded document was accessed via `file:`-Protocol.
  30655. * @returns boolean
  30656. */
  30657. static IsFileURL(): boolean;
  30658. /**
  30659. * Checks if the window object exists
  30660. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30661. */
  30662. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30663. /**
  30664. * No performance log
  30665. */
  30666. static readonly PerformanceNoneLogLevel: number;
  30667. /**
  30668. * Use user marks to log performance
  30669. */
  30670. static readonly PerformanceUserMarkLogLevel: number;
  30671. /**
  30672. * Log performance to the console
  30673. */
  30674. static readonly PerformanceConsoleLogLevel: number;
  30675. private static _performance;
  30676. /**
  30677. * Sets the current performance log level
  30678. */
  30679. static PerformanceLogLevel: number;
  30680. private static _StartPerformanceCounterDisabled;
  30681. private static _EndPerformanceCounterDisabled;
  30682. private static _StartUserMark;
  30683. private static _EndUserMark;
  30684. private static _StartPerformanceConsole;
  30685. private static _EndPerformanceConsole;
  30686. /**
  30687. * Starts a performance counter
  30688. */
  30689. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30690. /**
  30691. * Ends a specific performance coutner
  30692. */
  30693. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30694. /**
  30695. * Gets either window.performance.now() if supported or Date.now() else
  30696. */
  30697. static readonly Now: number;
  30698. /**
  30699. * This method will return the name of the class used to create the instance of the given object.
  30700. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30701. * @param object the object to get the class name from
  30702. * @param isType defines if the object is actually a type
  30703. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30704. */
  30705. static GetClassName(object: any, isType?: boolean): string;
  30706. /**
  30707. * Gets the first element of an array satisfying a given predicate
  30708. * @param array defines the array to browse
  30709. * @param predicate defines the predicate to use
  30710. * @returns null if not found or the element
  30711. */
  30712. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30713. /**
  30714. * This method will return the name of the full name of the class, including its owning module (if any).
  30715. * 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).
  30716. * @param object the object to get the class name from
  30717. * @param isType defines if the object is actually a type
  30718. * @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.
  30719. * @ignorenaming
  30720. */
  30721. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30722. /**
  30723. * Returns a promise that resolves after the given amount of time.
  30724. * @param delay Number of milliseconds to delay
  30725. * @returns Promise that resolves after the given amount of time
  30726. */
  30727. static DelayAsync(delay: number): Promise<void>;
  30728. /**
  30729. * Gets the current gradient from an array of IValueGradient
  30730. * @param ratio defines the current ratio to get
  30731. * @param gradients defines the array of IValueGradient
  30732. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30733. */
  30734. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30735. }
  30736. /**
  30737. * This class is used to track a performance counter which is number based.
  30738. * The user has access to many properties which give statistics of different nature.
  30739. *
  30740. * The implementer can track two kinds of Performance Counter: time and count.
  30741. * 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.
  30742. * 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.
  30743. */
  30744. export class PerfCounter {
  30745. /**
  30746. * Gets or sets a global boolean to turn on and off all the counters
  30747. */
  30748. static Enabled: boolean;
  30749. /**
  30750. * Returns the smallest value ever
  30751. */
  30752. readonly min: number;
  30753. /**
  30754. * Returns the biggest value ever
  30755. */
  30756. readonly max: number;
  30757. /**
  30758. * Returns the average value since the performance counter is running
  30759. */
  30760. readonly average: number;
  30761. /**
  30762. * Returns the average value of the last second the counter was monitored
  30763. */
  30764. readonly lastSecAverage: number;
  30765. /**
  30766. * Returns the current value
  30767. */
  30768. readonly current: number;
  30769. /**
  30770. * Gets the accumulated total
  30771. */
  30772. readonly total: number;
  30773. /**
  30774. * Gets the total value count
  30775. */
  30776. readonly count: number;
  30777. /**
  30778. * Creates a new counter
  30779. */
  30780. constructor();
  30781. /**
  30782. * Call this method to start monitoring a new frame.
  30783. * 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.
  30784. */
  30785. fetchNewFrame(): void;
  30786. /**
  30787. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30788. * @param newCount the count value to add to the monitored count
  30789. * @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.
  30790. */
  30791. addCount(newCount: number, fetchResult: boolean): void;
  30792. /**
  30793. * Start monitoring this performance counter
  30794. */
  30795. beginMonitoring(): void;
  30796. /**
  30797. * Compute the time lapsed since the previous beginMonitoring() call.
  30798. * @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
  30799. */
  30800. endMonitoring(newFrame?: boolean): void;
  30801. private _fetchResult;
  30802. private _startMonitoringTime;
  30803. private _min;
  30804. private _max;
  30805. private _average;
  30806. private _current;
  30807. private _totalValueCount;
  30808. private _totalAccumulated;
  30809. private _lastSecAverage;
  30810. private _lastSecAccumulated;
  30811. private _lastSecTime;
  30812. private _lastSecValueCount;
  30813. }
  30814. /**
  30815. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30816. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30817. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30818. * @param name The name of the class, case should be preserved
  30819. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30820. */
  30821. export function className(name: string, module?: string): (target: Object) => void;
  30822. /**
  30823. * An implementation of a loop for asynchronous functions.
  30824. */
  30825. export class AsyncLoop {
  30826. /**
  30827. * Defines the number of iterations for the loop
  30828. */
  30829. iterations: number;
  30830. /**
  30831. * Defines the current index of the loop.
  30832. */
  30833. index: number;
  30834. private _done;
  30835. private _fn;
  30836. private _successCallback;
  30837. /**
  30838. * Constructor.
  30839. * @param iterations the number of iterations.
  30840. * @param func the function to run each iteration
  30841. * @param successCallback the callback that will be called upon succesful execution
  30842. * @param offset starting offset.
  30843. */
  30844. constructor(
  30845. /**
  30846. * Defines the number of iterations for the loop
  30847. */
  30848. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30849. /**
  30850. * Execute the next iteration. Must be called after the last iteration was finished.
  30851. */
  30852. executeNext(): void;
  30853. /**
  30854. * Break the loop and run the success callback.
  30855. */
  30856. breakLoop(): void;
  30857. /**
  30858. * Create and run an async loop.
  30859. * @param iterations the number of iterations.
  30860. * @param fn the function to run each iteration
  30861. * @param successCallback the callback that will be called upon succesful execution
  30862. * @param offset starting offset.
  30863. * @returns the created async loop object
  30864. */
  30865. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30866. /**
  30867. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30868. * @param iterations total number of iterations
  30869. * @param syncedIterations number of synchronous iterations in each async iteration.
  30870. * @param fn the function to call each iteration.
  30871. * @param callback a success call back that will be called when iterating stops.
  30872. * @param breakFunction a break condition (optional)
  30873. * @param timeout timeout settings for the setTimeout function. default - 0.
  30874. * @returns the created async loop object
  30875. */
  30876. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30877. }
  30878. }
  30879. declare module BABYLON {
  30880. /** @hidden */
  30881. export interface ICollisionCoordinator {
  30882. createCollider(): Collider;
  30883. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30884. init(scene: Scene): void;
  30885. }
  30886. /** @hidden */
  30887. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30888. private _scene;
  30889. private _scaledPosition;
  30890. private _scaledVelocity;
  30891. private _finalPosition;
  30892. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30893. createCollider(): Collider;
  30894. init(scene: Scene): void;
  30895. private _collideWithWorld;
  30896. }
  30897. }
  30898. declare module BABYLON {
  30899. /**
  30900. * This class defines the direct association between an animation and a target
  30901. */
  30902. export class TargetedAnimation {
  30903. /**
  30904. * Animation to perform
  30905. */
  30906. animation: Animation;
  30907. /**
  30908. * Target to animate
  30909. */
  30910. target: any;
  30911. }
  30912. /**
  30913. * Use this class to create coordinated animations on multiple targets
  30914. */
  30915. export class AnimationGroup implements IDisposable {
  30916. /** The name of the animation group */
  30917. name: string;
  30918. private _scene;
  30919. private _targetedAnimations;
  30920. private _animatables;
  30921. private _from;
  30922. private _to;
  30923. private _isStarted;
  30924. private _isPaused;
  30925. private _speedRatio;
  30926. /**
  30927. * Gets or sets the unique id of the node
  30928. */
  30929. uniqueId: number;
  30930. /**
  30931. * This observable will notify when one animation have ended
  30932. */
  30933. onAnimationEndObservable: Observable<TargetedAnimation>;
  30934. /**
  30935. * Observer raised when one animation loops
  30936. */
  30937. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30938. /**
  30939. * This observable will notify when all animations have ended.
  30940. */
  30941. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30942. /**
  30943. * This observable will notify when all animations have paused.
  30944. */
  30945. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30946. /**
  30947. * This observable will notify when all animations are playing.
  30948. */
  30949. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30950. /**
  30951. * Gets the first frame
  30952. */
  30953. readonly from: number;
  30954. /**
  30955. * Gets the last frame
  30956. */
  30957. readonly to: number;
  30958. /**
  30959. * Define if the animations are started
  30960. */
  30961. readonly isStarted: boolean;
  30962. /**
  30963. * Gets a value indicating that the current group is playing
  30964. */
  30965. readonly isPlaying: boolean;
  30966. /**
  30967. * Gets or sets the speed ratio to use for all animations
  30968. */
  30969. /**
  30970. * Gets or sets the speed ratio to use for all animations
  30971. */
  30972. speedRatio: number;
  30973. /**
  30974. * Gets the targeted animations for this animation group
  30975. */
  30976. readonly targetedAnimations: Array<TargetedAnimation>;
  30977. /**
  30978. * returning the list of animatables controlled by this animation group.
  30979. */
  30980. readonly animatables: Array<Animatable>;
  30981. /**
  30982. * Instantiates a new Animation Group.
  30983. * This helps managing several animations at once.
  30984. * @see http://doc.babylonjs.com/how_to/group
  30985. * @param name Defines the name of the group
  30986. * @param scene Defines the scene the group belongs to
  30987. */
  30988. constructor(
  30989. /** The name of the animation group */
  30990. name: string, scene?: Nullable<Scene>);
  30991. /**
  30992. * Add an animation (with its target) in the group
  30993. * @param animation defines the animation we want to add
  30994. * @param target defines the target of the animation
  30995. * @returns the TargetedAnimation object
  30996. */
  30997. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  30998. /**
  30999. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31000. * It can add constant keys at begin or end
  31001. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31002. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31003. * @returns the animation group
  31004. */
  31005. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31006. /**
  31007. * Start all animations on given targets
  31008. * @param loop defines if animations must loop
  31009. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31010. * @param from defines the from key (optional)
  31011. * @param to defines the to key (optional)
  31012. * @returns the current animation group
  31013. */
  31014. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31015. /**
  31016. * Pause all animations
  31017. * @returns the animation group
  31018. */
  31019. pause(): AnimationGroup;
  31020. /**
  31021. * Play all animations to initial state
  31022. * This function will start() the animations if they were not started or will restart() them if they were paused
  31023. * @param loop defines if animations must loop
  31024. * @returns the animation group
  31025. */
  31026. play(loop?: boolean): AnimationGroup;
  31027. /**
  31028. * Reset all animations to initial state
  31029. * @returns the animation group
  31030. */
  31031. reset(): AnimationGroup;
  31032. /**
  31033. * Restart animations from key 0
  31034. * @returns the animation group
  31035. */
  31036. restart(): AnimationGroup;
  31037. /**
  31038. * Stop all animations
  31039. * @returns the animation group
  31040. */
  31041. stop(): AnimationGroup;
  31042. /**
  31043. * Set animation weight for all animatables
  31044. * @param weight defines the weight to use
  31045. * @return the animationGroup
  31046. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31047. */
  31048. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31049. /**
  31050. * Synchronize and normalize all animatables with a source animatable
  31051. * @param root defines the root animatable to synchronize with
  31052. * @return the animationGroup
  31053. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31054. */
  31055. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31056. /**
  31057. * Goes to a specific frame in this animation group
  31058. * @param frame the frame number to go to
  31059. * @return the animationGroup
  31060. */
  31061. goToFrame(frame: number): AnimationGroup;
  31062. /**
  31063. * Dispose all associated resources
  31064. */
  31065. dispose(): void;
  31066. private _checkAnimationGroupEnded;
  31067. /**
  31068. * Clone the current animation group and returns a copy
  31069. * @param newName defines the name of the new group
  31070. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31071. * @returns the new aniamtion group
  31072. */
  31073. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31074. /**
  31075. * Returns a new AnimationGroup object parsed from the source provided.
  31076. * @param parsedAnimationGroup defines the source
  31077. * @param scene defines the scene that will receive the animationGroup
  31078. * @returns a new AnimationGroup
  31079. */
  31080. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31081. /**
  31082. * Returns the string "AnimationGroup"
  31083. * @returns "AnimationGroup"
  31084. */
  31085. getClassName(): string;
  31086. /**
  31087. * Creates a detailled string about the object
  31088. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31089. * @returns a string representing the object
  31090. */
  31091. toString(fullDetails?: boolean): string;
  31092. }
  31093. }
  31094. declare module BABYLON {
  31095. /**
  31096. * Define an interface for all classes that will hold resources
  31097. */
  31098. export interface IDisposable {
  31099. /**
  31100. * Releases all held resources
  31101. */
  31102. dispose(): void;
  31103. }
  31104. /** Interface defining initialization parameters for Scene class */
  31105. export interface SceneOptions {
  31106. /**
  31107. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31108. * It will improve performance when the number of geometries becomes important.
  31109. */
  31110. useGeometryUniqueIdsMap?: boolean;
  31111. /**
  31112. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31113. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31114. */
  31115. useMaterialMeshMap?: boolean;
  31116. /**
  31117. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31118. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31119. */
  31120. useClonedMeshhMap?: boolean;
  31121. }
  31122. /**
  31123. * Represents a scene to be rendered by the engine.
  31124. * @see http://doc.babylonjs.com/features/scene
  31125. */
  31126. export class Scene extends AbstractScene implements IAnimatable {
  31127. private static _uniqueIdCounter;
  31128. /** The fog is deactivated */
  31129. static readonly FOGMODE_NONE: number;
  31130. /** The fog density is following an exponential function */
  31131. static readonly FOGMODE_EXP: number;
  31132. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31133. static readonly FOGMODE_EXP2: number;
  31134. /** The fog density is following a linear function. */
  31135. static readonly FOGMODE_LINEAR: number;
  31136. /**
  31137. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31138. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31139. */
  31140. static MinDeltaTime: number;
  31141. /**
  31142. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31143. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31144. */
  31145. static MaxDeltaTime: number;
  31146. /**
  31147. * Factory used to create the default material.
  31148. * @param name The name of the material to create
  31149. * @param scene The scene to create the material for
  31150. * @returns The default material
  31151. */
  31152. static DefaultMaterialFactory(scene: Scene): Material;
  31153. /**
  31154. * Factory used to create the a collision coordinator.
  31155. * @returns The collision coordinator
  31156. */
  31157. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31158. /** @hidden */ protected readonly _isScene: boolean;
  31159. /**
  31160. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31161. */
  31162. autoClear: boolean;
  31163. /**
  31164. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31165. */
  31166. autoClearDepthAndStencil: boolean;
  31167. /**
  31168. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31169. */
  31170. clearColor: Color4;
  31171. /**
  31172. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31173. */
  31174. ambientColor: Color3;
  31175. /**
  31176. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31177. * It should only be one of the following (if not the default embedded one):
  31178. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31179. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31180. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31181. * The material properties need to be setup according to the type of texture in use.
  31182. */
  31183. environmentBRDFTexture: BaseTexture;
  31184. /** @hidden */
  31185. protected _environmentTexture: Nullable<BaseTexture>;
  31186. /**
  31187. * Texture used in all pbr material as the reflection texture.
  31188. * As in the majority of the scene they are the same (exception for multi room and so on),
  31189. * this is easier to reference from here than from all the materials.
  31190. */
  31191. /**
  31192. * Texture used in all pbr material as the reflection texture.
  31193. * As in the majority of the scene they are the same (exception for multi room and so on),
  31194. * this is easier to set here than in all the materials.
  31195. */
  31196. environmentTexture: Nullable<BaseTexture>;
  31197. /** @hidden */
  31198. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31199. /**
  31200. * Default image processing configuration used either in the rendering
  31201. * Forward main pass or through the imageProcessingPostProcess if present.
  31202. * As in the majority of the scene they are the same (exception for multi camera),
  31203. * this is easier to reference from here than from all the materials and post process.
  31204. *
  31205. * No setter as we it is a shared configuration, you can set the values instead.
  31206. */
  31207. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31208. private _forceWireframe;
  31209. /**
  31210. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31211. */
  31212. forceWireframe: boolean;
  31213. private _forcePointsCloud;
  31214. /**
  31215. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31216. */
  31217. forcePointsCloud: boolean;
  31218. /**
  31219. * Gets or sets the active clipplane 1
  31220. */
  31221. clipPlane: Nullable<Plane>;
  31222. /**
  31223. * Gets or sets the active clipplane 2
  31224. */
  31225. clipPlane2: Nullable<Plane>;
  31226. /**
  31227. * Gets or sets the active clipplane 3
  31228. */
  31229. clipPlane3: Nullable<Plane>;
  31230. /**
  31231. * Gets or sets the active clipplane 4
  31232. */
  31233. clipPlane4: Nullable<Plane>;
  31234. /**
  31235. * Gets or sets a boolean indicating if animations are enabled
  31236. */
  31237. animationsEnabled: boolean;
  31238. private _animationPropertiesOverride;
  31239. /**
  31240. * Gets or sets the animation properties override
  31241. */
  31242. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31243. /**
  31244. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31245. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31246. */
  31247. useConstantAnimationDeltaTime: boolean;
  31248. /**
  31249. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31250. * Please note that it requires to run a ray cast through the scene on every frame
  31251. */
  31252. constantlyUpdateMeshUnderPointer: boolean;
  31253. /**
  31254. * Defines the HTML cursor to use when hovering over interactive elements
  31255. */
  31256. hoverCursor: string;
  31257. /**
  31258. * Defines the HTML default cursor to use (empty by default)
  31259. */
  31260. defaultCursor: string;
  31261. /**
  31262. * This is used to call preventDefault() on pointer down
  31263. * in order to block unwanted artifacts like system double clicks
  31264. */
  31265. preventDefaultOnPointerDown: boolean;
  31266. /**
  31267. * This is used to call preventDefault() on pointer up
  31268. * in order to block unwanted artifacts like system double clicks
  31269. */
  31270. preventDefaultOnPointerUp: boolean;
  31271. /**
  31272. * Gets or sets user defined metadata
  31273. */
  31274. metadata: any;
  31275. /**
  31276. * For internal use only. Please do not use.
  31277. */
  31278. reservedDataStore: any;
  31279. /**
  31280. * Gets the name of the plugin used to load this scene (null by default)
  31281. */
  31282. loadingPluginName: string;
  31283. /**
  31284. * Use this array to add regular expressions used to disable offline support for specific urls
  31285. */
  31286. disableOfflineSupportExceptionRules: RegExp[];
  31287. /**
  31288. * An event triggered when the scene is disposed.
  31289. */
  31290. onDisposeObservable: Observable<Scene>;
  31291. private _onDisposeObserver;
  31292. /** Sets a function to be executed when this scene is disposed. */
  31293. onDispose: () => void;
  31294. /**
  31295. * An event triggered before rendering the scene (right after animations and physics)
  31296. */
  31297. onBeforeRenderObservable: Observable<Scene>;
  31298. private _onBeforeRenderObserver;
  31299. /** Sets a function to be executed before rendering this scene */
  31300. beforeRender: Nullable<() => void>;
  31301. /**
  31302. * An event triggered after rendering the scene
  31303. */
  31304. onAfterRenderObservable: Observable<Scene>;
  31305. private _onAfterRenderObserver;
  31306. /** Sets a function to be executed after rendering this scene */
  31307. afterRender: Nullable<() => void>;
  31308. /**
  31309. * An event triggered before animating the scene
  31310. */
  31311. onBeforeAnimationsObservable: Observable<Scene>;
  31312. /**
  31313. * An event triggered after animations processing
  31314. */
  31315. onAfterAnimationsObservable: Observable<Scene>;
  31316. /**
  31317. * An event triggered before draw calls are ready to be sent
  31318. */
  31319. onBeforeDrawPhaseObservable: Observable<Scene>;
  31320. /**
  31321. * An event triggered after draw calls have been sent
  31322. */
  31323. onAfterDrawPhaseObservable: Observable<Scene>;
  31324. /**
  31325. * An event triggered when the scene is ready
  31326. */
  31327. onReadyObservable: Observable<Scene>;
  31328. /**
  31329. * An event triggered before rendering a camera
  31330. */
  31331. onBeforeCameraRenderObservable: Observable<Camera>;
  31332. private _onBeforeCameraRenderObserver;
  31333. /** Sets a function to be executed before rendering a camera*/
  31334. beforeCameraRender: () => void;
  31335. /**
  31336. * An event triggered after rendering a camera
  31337. */
  31338. onAfterCameraRenderObservable: Observable<Camera>;
  31339. private _onAfterCameraRenderObserver;
  31340. /** Sets a function to be executed after rendering a camera*/
  31341. afterCameraRender: () => void;
  31342. /**
  31343. * An event triggered when active meshes evaluation is about to start
  31344. */
  31345. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31346. /**
  31347. * An event triggered when active meshes evaluation is done
  31348. */
  31349. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31350. /**
  31351. * An event triggered when particles rendering is about to start
  31352. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31353. */
  31354. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31355. /**
  31356. * An event triggered when particles rendering is done
  31357. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31358. */
  31359. onAfterParticlesRenderingObservable: Observable<Scene>;
  31360. /**
  31361. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31362. */
  31363. onDataLoadedObservable: Observable<Scene>;
  31364. /**
  31365. * An event triggered when a camera is created
  31366. */
  31367. onNewCameraAddedObservable: Observable<Camera>;
  31368. /**
  31369. * An event triggered when a camera is removed
  31370. */
  31371. onCameraRemovedObservable: Observable<Camera>;
  31372. /**
  31373. * An event triggered when a light is created
  31374. */
  31375. onNewLightAddedObservable: Observable<Light>;
  31376. /**
  31377. * An event triggered when a light is removed
  31378. */
  31379. onLightRemovedObservable: Observable<Light>;
  31380. /**
  31381. * An event triggered when a geometry is created
  31382. */
  31383. onNewGeometryAddedObservable: Observable<Geometry>;
  31384. /**
  31385. * An event triggered when a geometry is removed
  31386. */
  31387. onGeometryRemovedObservable: Observable<Geometry>;
  31388. /**
  31389. * An event triggered when a transform node is created
  31390. */
  31391. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31392. /**
  31393. * An event triggered when a transform node is removed
  31394. */
  31395. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31396. /**
  31397. * An event triggered when a mesh is created
  31398. */
  31399. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31400. /**
  31401. * An event triggered when a mesh is removed
  31402. */
  31403. onMeshRemovedObservable: Observable<AbstractMesh>;
  31404. /**
  31405. * An event triggered when a skeleton is created
  31406. */
  31407. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31408. /**
  31409. * An event triggered when a skeleton is removed
  31410. */
  31411. onSkeletonRemovedObservable: Observable<Skeleton>;
  31412. /**
  31413. * An event triggered when a material is created
  31414. */
  31415. onNewMaterialAddedObservable: Observable<Material>;
  31416. /**
  31417. * An event triggered when a material is removed
  31418. */
  31419. onMaterialRemovedObservable: Observable<Material>;
  31420. /**
  31421. * An event triggered when a texture is created
  31422. */
  31423. onNewTextureAddedObservable: Observable<BaseTexture>;
  31424. /**
  31425. * An event triggered when a texture is removed
  31426. */
  31427. onTextureRemovedObservable: Observable<BaseTexture>;
  31428. /**
  31429. * An event triggered when render targets are about to be rendered
  31430. * Can happen multiple times per frame.
  31431. */
  31432. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31433. /**
  31434. * An event triggered when render targets were rendered.
  31435. * Can happen multiple times per frame.
  31436. */
  31437. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31438. /**
  31439. * An event triggered before calculating deterministic simulation step
  31440. */
  31441. onBeforeStepObservable: Observable<Scene>;
  31442. /**
  31443. * An event triggered after calculating deterministic simulation step
  31444. */
  31445. onAfterStepObservable: Observable<Scene>;
  31446. /**
  31447. * An event triggered when the activeCamera property is updated
  31448. */
  31449. onActiveCameraChanged: Observable<Scene>;
  31450. /**
  31451. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31452. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31453. * 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)
  31454. */
  31455. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31456. /**
  31457. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31458. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31459. * 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)
  31460. */
  31461. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31462. /**
  31463. * This Observable will when a mesh has been imported into the scene.
  31464. */
  31465. onMeshImportedObservable: Observable<AbstractMesh>;
  31466. /**
  31467. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31468. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31469. */
  31470. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31471. /** @hidden */ registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31472. /**
  31473. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31474. */
  31475. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31476. /**
  31477. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31478. */
  31479. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31480. /**
  31481. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31482. */
  31483. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31484. private _onPointerMove;
  31485. private _onPointerDown;
  31486. private _onPointerUp;
  31487. /** Callback called when a pointer move is detected */
  31488. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31489. /** Callback called when a pointer down is detected */
  31490. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31491. /** Callback called when a pointer up is detected */
  31492. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31493. /** Callback called when a pointer pick is detected */
  31494. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31495. /**
  31496. * 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).
  31497. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31498. */
  31499. onPrePointerObservable: Observable<PointerInfoPre>;
  31500. /**
  31501. * Observable event triggered each time an input event is received from the rendering canvas
  31502. */
  31503. onPointerObservable: Observable<PointerInfo>;
  31504. /**
  31505. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31506. */
  31507. readonly unTranslatedPointer: Vector2;
  31508. /** The distance in pixel that you have to move to prevent some events */
  31509. static DragMovementThreshold: number;
  31510. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31511. static LongPressDelay: number;
  31512. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31513. static DoubleClickDelay: number;
  31514. /** If you need to check double click without raising a single click at first click, enable this flag */
  31515. static ExclusiveDoubleClickMode: boolean;
  31516. private _initClickEvent;
  31517. private _initActionManager;
  31518. private _delayedSimpleClick;
  31519. private _delayedSimpleClickTimeout;
  31520. private _previousDelayedSimpleClickTimeout;
  31521. private _meshPickProceed;
  31522. private _previousButtonPressed;
  31523. private _currentPickResult;
  31524. private _previousPickResult;
  31525. private _totalPointersPressed;
  31526. private _doubleClickOccured;
  31527. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31528. cameraToUseForPointers: Nullable<Camera>;
  31529. private _pointerX;
  31530. private _pointerY;
  31531. private _unTranslatedPointerX;
  31532. private _unTranslatedPointerY;
  31533. private _startingPointerPosition;
  31534. private _previousStartingPointerPosition;
  31535. private _startingPointerTime;
  31536. private _previousStartingPointerTime;
  31537. private _pointerCaptures;
  31538. private _timeAccumulator;
  31539. private _currentStepId;
  31540. private _currentInternalStep;
  31541. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  31542. /**
  31543. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31544. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31545. */
  31546. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31547. /**
  31548. * Observable event triggered each time an keyboard event is received from the hosting window
  31549. */
  31550. onKeyboardObservable: Observable<KeyboardInfo>;
  31551. private _onKeyDown;
  31552. private _onKeyUp;
  31553. private _onCanvasFocusObserver;
  31554. private _onCanvasBlurObserver;
  31555. private _useRightHandedSystem;
  31556. /**
  31557. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31558. */
  31559. useRightHandedSystem: boolean;
  31560. /**
  31561. * Sets the step Id used by deterministic lock step
  31562. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31563. * @param newStepId defines the step Id
  31564. */
  31565. setStepId(newStepId: number): void;
  31566. /**
  31567. * Gets the step Id used by deterministic lock step
  31568. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31569. * @returns the step Id
  31570. */
  31571. getStepId(): number;
  31572. /**
  31573. * Gets the internal step used by deterministic lock step
  31574. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31575. * @returns the internal step
  31576. */
  31577. getInternalStep(): number;
  31578. private _fogEnabled;
  31579. /**
  31580. * Gets or sets a boolean indicating if fog is enabled on this scene
  31581. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31582. * (Default is true)
  31583. */
  31584. fogEnabled: boolean;
  31585. private _fogMode;
  31586. /**
  31587. * Gets or sets the fog mode to use
  31588. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31589. * | mode | value |
  31590. * | --- | --- |
  31591. * | FOGMODE_NONE | 0 |
  31592. * | FOGMODE_EXP | 1 |
  31593. * | FOGMODE_EXP2 | 2 |
  31594. * | FOGMODE_LINEAR | 3 |
  31595. */
  31596. fogMode: number;
  31597. /**
  31598. * Gets or sets the fog color to use
  31599. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31600. * (Default is Color3(0.2, 0.2, 0.3))
  31601. */
  31602. fogColor: Color3;
  31603. /**
  31604. * Gets or sets the fog density to use
  31605. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31606. * (Default is 0.1)
  31607. */
  31608. fogDensity: number;
  31609. /**
  31610. * Gets or sets the fog start distance to use
  31611. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31612. * (Default is 0)
  31613. */
  31614. fogStart: number;
  31615. /**
  31616. * Gets or sets the fog end distance to use
  31617. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31618. * (Default is 1000)
  31619. */
  31620. fogEnd: number;
  31621. private _shadowsEnabled;
  31622. /**
  31623. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31624. */
  31625. shadowsEnabled: boolean;
  31626. private _lightsEnabled;
  31627. /**
  31628. * Gets or sets a boolean indicating if lights are enabled on this scene
  31629. */
  31630. lightsEnabled: boolean;
  31631. /** All of the active cameras added to this scene. */
  31632. activeCameras: Camera[];
  31633. /** @hidden */ activeCamera: Nullable<Camera>;
  31634. /** Gets or sets the current active camera */
  31635. activeCamera: Nullable<Camera>;
  31636. private _defaultMaterial;
  31637. /** The default material used on meshes when no material is affected */
  31638. /** The default material used on meshes when no material is affected */
  31639. defaultMaterial: Material;
  31640. private _texturesEnabled;
  31641. /**
  31642. * Gets or sets a boolean indicating if textures are enabled on this scene
  31643. */
  31644. texturesEnabled: boolean;
  31645. /**
  31646. * Gets or sets a boolean indicating if particles are enabled on this scene
  31647. */
  31648. particlesEnabled: boolean;
  31649. /**
  31650. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31651. */
  31652. spritesEnabled: boolean;
  31653. private _skeletonsEnabled;
  31654. /**
  31655. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31656. */
  31657. skeletonsEnabled: boolean;
  31658. /**
  31659. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31660. */
  31661. lensFlaresEnabled: boolean;
  31662. /**
  31663. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31664. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31665. */
  31666. collisionsEnabled: boolean;
  31667. private _collisionCoordinator;
  31668. /** @hidden */
  31669. readonly collisionCoordinator: ICollisionCoordinator;
  31670. /**
  31671. * Defines the gravity applied to this scene (used only for collisions)
  31672. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31673. */
  31674. gravity: Vector3;
  31675. /**
  31676. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31677. */
  31678. postProcessesEnabled: boolean;
  31679. /**
  31680. * The list of postprocesses added to the scene
  31681. */
  31682. postProcesses: PostProcess[];
  31683. /**
  31684. * Gets the current postprocess manager
  31685. */
  31686. postProcessManager: PostProcessManager;
  31687. /**
  31688. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31689. */
  31690. renderTargetsEnabled: boolean;
  31691. /**
  31692. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31693. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31694. */
  31695. dumpNextRenderTargets: boolean;
  31696. /**
  31697. * The list of user defined render targets added to the scene
  31698. */
  31699. customRenderTargets: RenderTargetTexture[];
  31700. /**
  31701. * Defines if texture loading must be delayed
  31702. * If true, textures will only be loaded when they need to be rendered
  31703. */
  31704. useDelayedTextureLoading: boolean;
  31705. /**
  31706. * Gets the list of meshes imported to the scene through SceneLoader
  31707. */
  31708. importedMeshesFiles: String[];
  31709. /**
  31710. * Gets or sets a boolean indicating if probes are enabled on this scene
  31711. */
  31712. probesEnabled: boolean;
  31713. /**
  31714. * Gets or sets the current offline provider to use to store scene data
  31715. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31716. */
  31717. offlineProvider: IOfflineProvider;
  31718. /**
  31719. * Gets or sets the action manager associated with the scene
  31720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31721. */
  31722. actionManager: AbstractActionManager;
  31723. private _meshesForIntersections;
  31724. /**
  31725. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31726. */
  31727. proceduralTexturesEnabled: boolean;
  31728. private _engine;
  31729. private _totalVertices;
  31730. /** @hidden */ activeIndices: PerfCounter;
  31731. /** @hidden */ activeParticles: PerfCounter;
  31732. /** @hidden */ activeBones: PerfCounter;
  31733. private _animationRatio;
  31734. /** @hidden */ animationTimeLast: number;
  31735. /** @hidden */ animationTime: number;
  31736. /**
  31737. * Gets or sets a general scale for animation speed
  31738. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31739. */
  31740. animationTimeScale: number;
  31741. /** @hidden */ cachedMaterial: Nullable<Material>;
  31742. /** @hidden */ cachedEffect: Nullable<Effect>;
  31743. /** @hidden */ cachedVisibility: Nullable<number>;
  31744. private _renderId;
  31745. private _frameId;
  31746. private _executeWhenReadyTimeoutId;
  31747. private _intermediateRendering;
  31748. private _viewUpdateFlag;
  31749. private _projectionUpdateFlag;
  31750. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  31751. private _activeRequests;
  31752. /** @hidden */ pendingData: any[];
  31753. private _isDisposed;
  31754. /**
  31755. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31756. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31757. */
  31758. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31759. private _activeMeshes;
  31760. private _processedMaterials;
  31761. private _renderTargets;
  31762. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  31763. private _activeSkeletons;
  31764. private _softwareSkinnedMeshes;
  31765. private _renderingManager;
  31766. /** @hidden */ activeAnimatables: Animatable[];
  31767. private _transformMatrix;
  31768. private _sceneUbo;
  31769. /** @hidden */ viewMatrix: Matrix;
  31770. private _projectionMatrix;
  31771. private _wheelEventName;
  31772. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  31773. /** @hidden */ frustumPlanes: Plane[];
  31774. /**
  31775. * Gets the list of frustum planes (built from the active camera)
  31776. */
  31777. readonly frustumPlanes: Plane[];
  31778. /**
  31779. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31780. * This is useful if there are more lights that the maximum simulteanous authorized
  31781. */
  31782. requireLightSorting: boolean;
  31783. /** @hidden */
  31784. readonly useMaterialMeshMap: boolean;
  31785. /** @hidden */
  31786. readonly useClonedMeshhMap: boolean;
  31787. private _pointerOverMesh;
  31788. private _pickedDownMesh;
  31789. private _pickedUpMesh;
  31790. private _externalData;
  31791. private _uid;
  31792. /**
  31793. * @hidden
  31794. * Backing store of defined scene components.
  31795. */ components: ISceneComponent[];
  31796. /**
  31797. * @hidden
  31798. * Backing store of defined scene components.
  31799. */ serializableComponents: ISceneSerializableComponent[];
  31800. /**
  31801. * List of components to register on the next registration step.
  31802. */
  31803. private _transientComponents;
  31804. /**
  31805. * Registers the transient components if needed.
  31806. */
  31807. private _registerTransientComponents;
  31808. /**
  31809. * @hidden
  31810. * Add a component to the scene.
  31811. * Note that the ccomponent could be registered on th next frame if this is called after
  31812. * the register component stage.
  31813. * @param component Defines the component to add to the scene
  31814. */ addComponent(component: ISceneComponent): void;
  31815. /**
  31816. * @hidden
  31817. * Gets a component from the scene.
  31818. * @param name defines the name of the component to retrieve
  31819. * @returns the component or null if not present
  31820. */ getComponent(name: string): Nullable<ISceneComponent>;
  31821. /**
  31822. * @hidden
  31823. * Defines the actions happening before camera updates.
  31824. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31825. /**
  31826. * @hidden
  31827. * Defines the actions happening before clear the canvas.
  31828. */ beforeClearStage: Stage<SimpleStageAction>;
  31829. /**
  31830. * @hidden
  31831. * Defines the actions when collecting render targets for the frame.
  31832. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31833. /**
  31834. * @hidden
  31835. * Defines the actions happening for one camera in the frame.
  31836. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31837. /**
  31838. * @hidden
  31839. * Defines the actions happening during the per mesh ready checks.
  31840. */ isReadyForMeshStage: Stage<MeshStageAction>;
  31841. /**
  31842. * @hidden
  31843. * Defines the actions happening before evaluate active mesh checks.
  31844. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31845. /**
  31846. * @hidden
  31847. * Defines the actions happening during the evaluate sub mesh checks.
  31848. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31849. /**
  31850. * @hidden
  31851. * Defines the actions happening during the active mesh stage.
  31852. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  31853. /**
  31854. * @hidden
  31855. * Defines the actions happening during the per camera render target step.
  31856. */ cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  31857. /**
  31858. * @hidden
  31859. * Defines the actions happening just before the active camera is drawing.
  31860. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  31861. /**
  31862. * @hidden
  31863. * Defines the actions happening just before a render target is drawing.
  31864. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31865. /**
  31866. * @hidden
  31867. * Defines the actions happening just before a rendering group is drawing.
  31868. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31869. /**
  31870. * @hidden
  31871. * Defines the actions happening just before a mesh is drawing.
  31872. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31873. /**
  31874. * @hidden
  31875. * Defines the actions happening just after a mesh has been drawn.
  31876. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31877. /**
  31878. * @hidden
  31879. * Defines the actions happening just after a rendering group has been drawn.
  31880. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31881. /**
  31882. * @hidden
  31883. * Defines the actions happening just after the active camera has been drawn.
  31884. */ afterCameraDrawStage: Stage<CameraStageAction>;
  31885. /**
  31886. * @hidden
  31887. * Defines the actions happening just after a render target has been drawn.
  31888. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31889. /**
  31890. * @hidden
  31891. * Defines the actions happening just after rendering all cameras and computing intersections.
  31892. */ afterRenderStage: Stage<SimpleStageAction>;
  31893. /**
  31894. * @hidden
  31895. * Defines the actions happening when a pointer move event happens.
  31896. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  31897. /**
  31898. * @hidden
  31899. * Defines the actions happening when a pointer down event happens.
  31900. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  31901. /**
  31902. * @hidden
  31903. * Defines the actions happening when a pointer up event happens.
  31904. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  31905. /**
  31906. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31907. */
  31908. private geometriesByUniqueId;
  31909. /**
  31910. * Creates a new Scene
  31911. * @param engine defines the engine to use to render this scene
  31912. * @param options defines the scene options
  31913. */
  31914. constructor(engine: Engine, options?: SceneOptions);
  31915. /**
  31916. * Gets a string idenfifying the name of the class
  31917. * @returns "Scene" string
  31918. */
  31919. getClassName(): string;
  31920. private _defaultMeshCandidates;
  31921. /**
  31922. * @hidden
  31923. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31924. private _defaultSubMeshCandidates;
  31925. /**
  31926. * @hidden
  31927. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31928. /**
  31929. * Sets the default candidate providers for the scene.
  31930. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31931. * and getCollidingSubMeshCandidates to their default function
  31932. */
  31933. setDefaultCandidateProviders(): void;
  31934. /**
  31935. * Gets the mesh that is currently under the pointer
  31936. */
  31937. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31938. /**
  31939. * Gets or sets the current on-screen X position of the pointer
  31940. */
  31941. pointerX: number;
  31942. /**
  31943. * Gets or sets the current on-screen Y position of the pointer
  31944. */
  31945. pointerY: number;
  31946. /**
  31947. * Gets the cached material (ie. the latest rendered one)
  31948. * @returns the cached material
  31949. */
  31950. getCachedMaterial(): Nullable<Material>;
  31951. /**
  31952. * Gets the cached effect (ie. the latest rendered one)
  31953. * @returns the cached effect
  31954. */
  31955. getCachedEffect(): Nullable<Effect>;
  31956. /**
  31957. * Gets the cached visibility state (ie. the latest rendered one)
  31958. * @returns the cached visibility state
  31959. */
  31960. getCachedVisibility(): Nullable<number>;
  31961. /**
  31962. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31963. * @param material defines the current material
  31964. * @param effect defines the current effect
  31965. * @param visibility defines the current visibility state
  31966. * @returns true if one parameter is not cached
  31967. */
  31968. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31969. /**
  31970. * Gets the engine associated with the scene
  31971. * @returns an Engine
  31972. */
  31973. getEngine(): Engine;
  31974. /**
  31975. * Gets the total number of vertices rendered per frame
  31976. * @returns the total number of vertices rendered per frame
  31977. */
  31978. getTotalVertices(): number;
  31979. /**
  31980. * Gets the performance counter for total vertices
  31981. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31982. */
  31983. readonly totalVerticesPerfCounter: PerfCounter;
  31984. /**
  31985. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  31986. * @returns the total number of active indices rendered per frame
  31987. */
  31988. getActiveIndices(): number;
  31989. /**
  31990. * Gets the performance counter for active indices
  31991. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31992. */
  31993. readonly totalActiveIndicesPerfCounter: PerfCounter;
  31994. /**
  31995. * Gets the total number of active particles rendered per frame
  31996. * @returns the total number of active particles rendered per frame
  31997. */
  31998. getActiveParticles(): number;
  31999. /**
  32000. * Gets the performance counter for active particles
  32001. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32002. */
  32003. readonly activeParticlesPerfCounter: PerfCounter;
  32004. /**
  32005. * Gets the total number of active bones rendered per frame
  32006. * @returns the total number of active bones rendered per frame
  32007. */
  32008. getActiveBones(): number;
  32009. /**
  32010. * Gets the performance counter for active bones
  32011. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32012. */
  32013. readonly activeBonesPerfCounter: PerfCounter;
  32014. /**
  32015. * Gets the array of active meshes
  32016. * @returns an array of AbstractMesh
  32017. */
  32018. getActiveMeshes(): SmartArray<AbstractMesh>;
  32019. /**
  32020. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32021. * @returns a number
  32022. */
  32023. getAnimationRatio(): number;
  32024. /**
  32025. * Gets an unique Id for the current render phase
  32026. * @returns a number
  32027. */
  32028. getRenderId(): number;
  32029. /**
  32030. * Gets an unique Id for the current frame
  32031. * @returns a number
  32032. */
  32033. getFrameId(): number;
  32034. /** Call this function if you want to manually increment the render Id*/
  32035. incrementRenderId(): void;
  32036. private _updatePointerPosition;
  32037. private _createUbo;
  32038. private _setRayOnPointerInfo;
  32039. /**
  32040. * Use this method to simulate a pointer move on a mesh
  32041. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32042. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32043. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32044. * @returns the current scene
  32045. */
  32046. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32047. private _processPointerMove;
  32048. private _checkPrePointerObservable;
  32049. /**
  32050. * Use this method to simulate a pointer down on a mesh
  32051. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32052. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32053. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32054. * @returns the current scene
  32055. */
  32056. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32057. private _processPointerDown;
  32058. /**
  32059. * Use this method to simulate a pointer up on a mesh
  32060. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32061. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32062. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32063. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32064. * @returns the current scene
  32065. */
  32066. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32067. private _processPointerUp;
  32068. /**
  32069. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32070. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32071. * @returns true if the pointer was captured
  32072. */
  32073. isPointerCaptured(pointerId?: number): boolean;
  32074. /** @hidden */ isPointerSwiping(): boolean;
  32075. /**
  32076. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32077. * @param attachUp defines if you want to attach events to pointerup
  32078. * @param attachDown defines if you want to attach events to pointerdown
  32079. * @param attachMove defines if you want to attach events to pointermove
  32080. */
  32081. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32082. /** Detaches all event handlers*/
  32083. detachControl(): void;
  32084. /**
  32085. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32086. * Delay loaded resources are not taking in account
  32087. * @return true if all required resources are ready
  32088. */
  32089. isReady(): boolean;
  32090. /** Resets all cached information relative to material (including effect and visibility) */
  32091. resetCachedMaterial(): void;
  32092. /**
  32093. * Registers a function to be called before every frame render
  32094. * @param func defines the function to register
  32095. */
  32096. registerBeforeRender(func: () => void): void;
  32097. /**
  32098. * Unregisters a function called before every frame render
  32099. * @param func defines the function to unregister
  32100. */
  32101. unregisterBeforeRender(func: () => void): void;
  32102. /**
  32103. * Registers a function to be called after every frame render
  32104. * @param func defines the function to register
  32105. */
  32106. registerAfterRender(func: () => void): void;
  32107. /**
  32108. * Unregisters a function called after every frame render
  32109. * @param func defines the function to unregister
  32110. */
  32111. unregisterAfterRender(func: () => void): void;
  32112. private _executeOnceBeforeRender;
  32113. /**
  32114. * The provided function will run before render once and will be disposed afterwards.
  32115. * A timeout delay can be provided so that the function will be executed in N ms.
  32116. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32117. * @param func The function to be executed.
  32118. * @param timeout optional delay in ms
  32119. */
  32120. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32121. /** @hidden */ addPendingData(data: any): void;
  32122. /** @hidden */ removePendingData(data: any): void;
  32123. /**
  32124. * Returns the number of items waiting to be loaded
  32125. * @returns the number of items waiting to be loaded
  32126. */
  32127. getWaitingItemsCount(): number;
  32128. /**
  32129. * Returns a boolean indicating if the scene is still loading data
  32130. */
  32131. readonly isLoading: boolean;
  32132. /**
  32133. * Registers a function to be executed when the scene is ready
  32134. * @param {Function} func - the function to be executed
  32135. */
  32136. executeWhenReady(func: () => void): void;
  32137. /**
  32138. * Returns a promise that resolves when the scene is ready
  32139. * @returns A promise that resolves when the scene is ready
  32140. */
  32141. whenReadyAsync(): Promise<void>;
  32142. /** @hidden */ checkIsReady(): void;
  32143. /**
  32144. * Gets all animatable attached to the scene
  32145. */
  32146. readonly animatables: Animatable[];
  32147. /**
  32148. * Resets the last animation time frame.
  32149. * Useful to override when animations start running when loading a scene for the first time.
  32150. */
  32151. resetLastAnimationTimeFrame(): void;
  32152. /**
  32153. * Gets the current view matrix
  32154. * @returns a Matrix
  32155. */
  32156. getViewMatrix(): Matrix;
  32157. /**
  32158. * Gets the current projection matrix
  32159. * @returns a Matrix
  32160. */
  32161. getProjectionMatrix(): Matrix;
  32162. /**
  32163. * Gets the current transform matrix
  32164. * @returns a Matrix made of View * Projection
  32165. */
  32166. getTransformMatrix(): Matrix;
  32167. /**
  32168. * Sets the current transform matrix
  32169. * @param viewL defines the View matrix to use
  32170. * @param projectionL defines the Projection matrix to use
  32171. * @param viewR defines the right View matrix to use (if provided)
  32172. * @param projectionR defines the right Projection matrix to use (if provided)
  32173. */
  32174. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32175. /**
  32176. * Gets the uniform buffer used to store scene data
  32177. * @returns a UniformBuffer
  32178. */
  32179. getSceneUniformBuffer(): UniformBuffer;
  32180. /**
  32181. * Gets an unique (relatively to the current scene) Id
  32182. * @returns an unique number for the scene
  32183. */
  32184. getUniqueId(): number;
  32185. /**
  32186. * Add a mesh to the list of scene's meshes
  32187. * @param newMesh defines the mesh to add
  32188. * @param recursive if all child meshes should also be added to the scene
  32189. */
  32190. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32191. /**
  32192. * Remove a mesh for the list of scene's meshes
  32193. * @param toRemove defines the mesh to remove
  32194. * @param recursive if all child meshes should also be removed from the scene
  32195. * @returns the index where the mesh was in the mesh list
  32196. */
  32197. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32198. /**
  32199. * Add a transform node to the list of scene's transform nodes
  32200. * @param newTransformNode defines the transform node to add
  32201. */
  32202. addTransformNode(newTransformNode: TransformNode): void;
  32203. /**
  32204. * Remove a transform node for the list of scene's transform nodes
  32205. * @param toRemove defines the transform node to remove
  32206. * @returns the index where the transform node was in the transform node list
  32207. */
  32208. removeTransformNode(toRemove: TransformNode): number;
  32209. /**
  32210. * Remove a skeleton for the list of scene's skeletons
  32211. * @param toRemove defines the skeleton to remove
  32212. * @returns the index where the skeleton was in the skeleton list
  32213. */
  32214. removeSkeleton(toRemove: Skeleton): number;
  32215. /**
  32216. * Remove a morph target for the list of scene's morph targets
  32217. * @param toRemove defines the morph target to remove
  32218. * @returns the index where the morph target was in the morph target list
  32219. */
  32220. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32221. /**
  32222. * Remove a light for the list of scene's lights
  32223. * @param toRemove defines the light to remove
  32224. * @returns the index where the light was in the light list
  32225. */
  32226. removeLight(toRemove: Light): number;
  32227. /**
  32228. * Remove a camera for the list of scene's cameras
  32229. * @param toRemove defines the camera to remove
  32230. * @returns the index where the camera was in the camera list
  32231. */
  32232. removeCamera(toRemove: Camera): number;
  32233. /**
  32234. * Remove a particle system for the list of scene's particle systems
  32235. * @param toRemove defines the particle system to remove
  32236. * @returns the index where the particle system was in the particle system list
  32237. */
  32238. removeParticleSystem(toRemove: IParticleSystem): number;
  32239. /**
  32240. * Remove a animation for the list of scene's animations
  32241. * @param toRemove defines the animation to remove
  32242. * @returns the index where the animation was in the animation list
  32243. */
  32244. removeAnimation(toRemove: Animation): number;
  32245. /**
  32246. * Removes the given animation group from this scene.
  32247. * @param toRemove The animation group to remove
  32248. * @returns The index of the removed animation group
  32249. */
  32250. removeAnimationGroup(toRemove: AnimationGroup): number;
  32251. /**
  32252. * Removes the given multi-material from this scene.
  32253. * @param toRemove The multi-material to remove
  32254. * @returns The index of the removed multi-material
  32255. */
  32256. removeMultiMaterial(toRemove: MultiMaterial): number;
  32257. /**
  32258. * Removes the given material from this scene.
  32259. * @param toRemove The material to remove
  32260. * @returns The index of the removed material
  32261. */
  32262. removeMaterial(toRemove: Material): number;
  32263. /**
  32264. * Removes the given action manager from this scene.
  32265. * @param toRemove The action manager to remove
  32266. * @returns The index of the removed action manager
  32267. */
  32268. removeActionManager(toRemove: AbstractActionManager): number;
  32269. /**
  32270. * Removes the given texture from this scene.
  32271. * @param toRemove The texture to remove
  32272. * @returns The index of the removed texture
  32273. */
  32274. removeTexture(toRemove: BaseTexture): number;
  32275. /**
  32276. * Adds the given light to this scene
  32277. * @param newLight The light to add
  32278. */
  32279. addLight(newLight: Light): void;
  32280. /**
  32281. * Sorts the list list based on light priorities
  32282. */
  32283. sortLightsByPriority(): void;
  32284. /**
  32285. * Adds the given camera to this scene
  32286. * @param newCamera The camera to add
  32287. */
  32288. addCamera(newCamera: Camera): void;
  32289. /**
  32290. * Adds the given skeleton to this scene
  32291. * @param newSkeleton The skeleton to add
  32292. */
  32293. addSkeleton(newSkeleton: Skeleton): void;
  32294. /**
  32295. * Adds the given particle system to this scene
  32296. * @param newParticleSystem The particle system to add
  32297. */
  32298. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32299. /**
  32300. * Adds the given animation to this scene
  32301. * @param newAnimation The animation to add
  32302. */
  32303. addAnimation(newAnimation: Animation): void;
  32304. /**
  32305. * Adds the given animation group to this scene.
  32306. * @param newAnimationGroup The animation group to add
  32307. */
  32308. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32309. /**
  32310. * Adds the given multi-material to this scene
  32311. * @param newMultiMaterial The multi-material to add
  32312. */
  32313. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32314. /**
  32315. * Adds the given material to this scene
  32316. * @param newMaterial The material to add
  32317. */
  32318. addMaterial(newMaterial: Material): void;
  32319. /**
  32320. * Adds the given morph target to this scene
  32321. * @param newMorphTargetManager The morph target to add
  32322. */
  32323. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32324. /**
  32325. * Adds the given geometry to this scene
  32326. * @param newGeometry The geometry to add
  32327. */
  32328. addGeometry(newGeometry: Geometry): void;
  32329. /**
  32330. * Adds the given action manager to this scene
  32331. * @param newActionManager The action manager to add
  32332. */
  32333. addActionManager(newActionManager: AbstractActionManager): void;
  32334. /**
  32335. * Adds the given texture to this scene.
  32336. * @param newTexture The texture to add
  32337. */
  32338. addTexture(newTexture: BaseTexture): void;
  32339. /**
  32340. * Switch active camera
  32341. * @param newCamera defines the new active camera
  32342. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32343. */
  32344. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32345. /**
  32346. * sets the active camera of the scene using its ID
  32347. * @param id defines the camera's ID
  32348. * @return the new active camera or null if none found.
  32349. */
  32350. setActiveCameraByID(id: string): Nullable<Camera>;
  32351. /**
  32352. * sets the active camera of the scene using its name
  32353. * @param name defines the camera's name
  32354. * @returns the new active camera or null if none found.
  32355. */
  32356. setActiveCameraByName(name: string): Nullable<Camera>;
  32357. /**
  32358. * get an animation group using its name
  32359. * @param name defines the material's name
  32360. * @return the animation group or null if none found.
  32361. */
  32362. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32363. /**
  32364. * Get a material using its unique id
  32365. * @param uniqueId defines the material's unique id
  32366. * @return the material or null if none found.
  32367. */
  32368. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32369. /**
  32370. * get a material using its id
  32371. * @param id defines the material's ID
  32372. * @return the material or null if none found.
  32373. */
  32374. getMaterialByID(id: string): Nullable<Material>;
  32375. /**
  32376. * Gets a material using its name
  32377. * @param name defines the material's name
  32378. * @return the material or null if none found.
  32379. */
  32380. getMaterialByName(name: string): Nullable<Material>;
  32381. /**
  32382. * Gets a camera using its id
  32383. * @param id defines the id to look for
  32384. * @returns the camera or null if not found
  32385. */
  32386. getCameraByID(id: string): Nullable<Camera>;
  32387. /**
  32388. * Gets a camera using its unique id
  32389. * @param uniqueId defines the unique id to look for
  32390. * @returns the camera or null if not found
  32391. */
  32392. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32393. /**
  32394. * Gets a camera using its name
  32395. * @param name defines the camera's name
  32396. * @return the camera or null if none found.
  32397. */
  32398. getCameraByName(name: string): Nullable<Camera>;
  32399. /**
  32400. * Gets a bone using its id
  32401. * @param id defines the bone's id
  32402. * @return the bone or null if not found
  32403. */
  32404. getBoneByID(id: string): Nullable<Bone>;
  32405. /**
  32406. * Gets a bone using its id
  32407. * @param name defines the bone's name
  32408. * @return the bone or null if not found
  32409. */
  32410. getBoneByName(name: string): Nullable<Bone>;
  32411. /**
  32412. * Gets a light node using its name
  32413. * @param name defines the the light's name
  32414. * @return the light or null if none found.
  32415. */
  32416. getLightByName(name: string): Nullable<Light>;
  32417. /**
  32418. * Gets a light node using its id
  32419. * @param id defines the light's id
  32420. * @return the light or null if none found.
  32421. */
  32422. getLightByID(id: string): Nullable<Light>;
  32423. /**
  32424. * Gets a light node using its scene-generated unique ID
  32425. * @param uniqueId defines the light's unique id
  32426. * @return the light or null if none found.
  32427. */
  32428. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32429. /**
  32430. * Gets a particle system by id
  32431. * @param id defines the particle system id
  32432. * @return the corresponding system or null if none found
  32433. */
  32434. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32435. /**
  32436. * Gets a geometry using its ID
  32437. * @param id defines the geometry's id
  32438. * @return the geometry or null if none found.
  32439. */
  32440. getGeometryByID(id: string): Nullable<Geometry>;
  32441. private _getGeometryByUniqueID;
  32442. /**
  32443. * Add a new geometry to this scene
  32444. * @param geometry defines the geometry to be added to the scene.
  32445. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32446. * @return a boolean defining if the geometry was added or not
  32447. */
  32448. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32449. /**
  32450. * Removes an existing geometry
  32451. * @param geometry defines the geometry to be removed from the scene
  32452. * @return a boolean defining if the geometry was removed or not
  32453. */
  32454. removeGeometry(geometry: Geometry): boolean;
  32455. /**
  32456. * Gets the list of geometries attached to the scene
  32457. * @returns an array of Geometry
  32458. */
  32459. getGeometries(): Geometry[];
  32460. /**
  32461. * Gets the first added mesh found of a given ID
  32462. * @param id defines the id to search for
  32463. * @return the mesh found or null if not found at all
  32464. */
  32465. getMeshByID(id: string): Nullable<AbstractMesh>;
  32466. /**
  32467. * Gets a list of meshes using their id
  32468. * @param id defines the id to search for
  32469. * @returns a list of meshes
  32470. */
  32471. getMeshesByID(id: string): Array<AbstractMesh>;
  32472. /**
  32473. * Gets the first added transform node found of a given ID
  32474. * @param id defines the id to search for
  32475. * @return the found transform node or null if not found at all.
  32476. */
  32477. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32478. /**
  32479. * Gets a transform node with its auto-generated unique id
  32480. * @param uniqueId efines the unique id to search for
  32481. * @return the found transform node or null if not found at all.
  32482. */
  32483. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32484. /**
  32485. * Gets a list of transform nodes using their id
  32486. * @param id defines the id to search for
  32487. * @returns a list of transform nodes
  32488. */
  32489. getTransformNodesByID(id: string): Array<TransformNode>;
  32490. /**
  32491. * Gets a mesh with its auto-generated unique id
  32492. * @param uniqueId defines the unique id to search for
  32493. * @return the found mesh or null if not found at all.
  32494. */
  32495. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32496. /**
  32497. * Gets a the last added mesh using a given id
  32498. * @param id defines the id to search for
  32499. * @return the found mesh or null if not found at all.
  32500. */
  32501. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32502. /**
  32503. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32504. * @param id defines the id to search for
  32505. * @return the found node or null if not found at all
  32506. */
  32507. getLastEntryByID(id: string): Nullable<Node>;
  32508. /**
  32509. * Gets a node (Mesh, Camera, Light) using a given id
  32510. * @param id defines the id to search for
  32511. * @return the found node or null if not found at all
  32512. */
  32513. getNodeByID(id: string): Nullable<Node>;
  32514. /**
  32515. * Gets a node (Mesh, Camera, Light) using a given name
  32516. * @param name defines the name to search for
  32517. * @return the found node or null if not found at all.
  32518. */
  32519. getNodeByName(name: string): Nullable<Node>;
  32520. /**
  32521. * Gets a mesh using a given name
  32522. * @param name defines the name to search for
  32523. * @return the found mesh or null if not found at all.
  32524. */
  32525. getMeshByName(name: string): Nullable<AbstractMesh>;
  32526. /**
  32527. * Gets a transform node using a given name
  32528. * @param name defines the name to search for
  32529. * @return the found transform node or null if not found at all.
  32530. */
  32531. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32532. /**
  32533. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32534. * @param id defines the id to search for
  32535. * @return the found skeleton or null if not found at all.
  32536. */
  32537. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32538. /**
  32539. * Gets a skeleton using a given auto generated unique id
  32540. * @param uniqueId defines the unique id to search for
  32541. * @return the found skeleton or null if not found at all.
  32542. */
  32543. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32544. /**
  32545. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32546. * @param id defines the id to search for
  32547. * @return the found skeleton or null if not found at all.
  32548. */
  32549. getSkeletonById(id: string): Nullable<Skeleton>;
  32550. /**
  32551. * Gets a skeleton using a given name
  32552. * @param name defines the name to search for
  32553. * @return the found skeleton or null if not found at all.
  32554. */
  32555. getSkeletonByName(name: string): Nullable<Skeleton>;
  32556. /**
  32557. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32558. * @param id defines the id to search for
  32559. * @return the found morph target manager or null if not found at all.
  32560. */
  32561. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32562. /**
  32563. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32564. * @param id defines the id to search for
  32565. * @return the found morph target or null if not found at all.
  32566. */
  32567. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32568. /**
  32569. * Gets a boolean indicating if the given mesh is active
  32570. * @param mesh defines the mesh to look for
  32571. * @returns true if the mesh is in the active list
  32572. */
  32573. isActiveMesh(mesh: AbstractMesh): boolean;
  32574. /**
  32575. * Return a unique id as a string which can serve as an identifier for the scene
  32576. */
  32577. readonly uid: string;
  32578. /**
  32579. * Add an externaly attached data from its key.
  32580. * This method call will fail and return false, if such key already exists.
  32581. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32582. * @param key the unique key that identifies the data
  32583. * @param data the data object to associate to the key for this Engine instance
  32584. * @return true if no such key were already present and the data was added successfully, false otherwise
  32585. */
  32586. addExternalData<T>(key: string, data: T): boolean;
  32587. /**
  32588. * Get an externaly attached data from its key
  32589. * @param key the unique key that identifies the data
  32590. * @return the associated data, if present (can be null), or undefined if not present
  32591. */
  32592. getExternalData<T>(key: string): Nullable<T>;
  32593. /**
  32594. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32595. * @param key the unique key that identifies the data
  32596. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32597. * @return the associated data, can be null if the factory returned null.
  32598. */
  32599. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32600. /**
  32601. * Remove an externaly attached data from the Engine instance
  32602. * @param key the unique key that identifies the data
  32603. * @return true if the data was successfully removed, false if it doesn't exist
  32604. */
  32605. removeExternalData(key: string): boolean;
  32606. private _evaluateSubMesh;
  32607. /**
  32608. * Clear the processed materials smart array preventing retention point in material dispose.
  32609. */
  32610. freeProcessedMaterials(): void;
  32611. private _preventFreeActiveMeshesAndRenderingGroups;
  32612. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32613. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32614. * when disposing several meshes in a row or a hierarchy of meshes.
  32615. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32616. */
  32617. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32618. /**
  32619. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32620. */
  32621. freeActiveMeshes(): void;
  32622. /**
  32623. * Clear the info related to rendering groups preventing retention points during dispose.
  32624. */
  32625. freeRenderingGroups(): void;
  32626. /** @hidden */ isInIntermediateRendering(): boolean;
  32627. /**
  32628. * Lambda returning the list of potentially active meshes.
  32629. */
  32630. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32631. /**
  32632. * Lambda returning the list of potentially active sub meshes.
  32633. */
  32634. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32635. /**
  32636. * Lambda returning the list of potentially intersecting sub meshes.
  32637. */
  32638. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32639. /**
  32640. * Lambda returning the list of potentially colliding sub meshes.
  32641. */
  32642. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32643. private _activeMeshesFrozen;
  32644. /**
  32645. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32646. * @returns the current scene
  32647. */
  32648. freezeActiveMeshes(): Scene;
  32649. /**
  32650. * Use this function to restart evaluating active meshes on every frame
  32651. * @returns the current scene
  32652. */
  32653. unfreezeActiveMeshes(): Scene;
  32654. private _evaluateActiveMeshes;
  32655. private _activeMesh;
  32656. /**
  32657. * Update the transform matrix to update from the current active camera
  32658. * @param force defines a boolean used to force the update even if cache is up to date
  32659. */
  32660. updateTransformMatrix(force?: boolean): void;
  32661. private _bindFrameBuffer;
  32662. /** @hidden */ allowPostProcessClearColor: boolean;
  32663. /** @hidden */ renderForCamera(camera: Camera, rigParent?: Camera): void;
  32664. private _processSubCameras;
  32665. private _checkIntersections;
  32666. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  32667. /**
  32668. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32669. */
  32670. getDeterministicFrameTime: () => number;
  32671. /** @hidden */ animate(): void;
  32672. /** Execute all animations (for a frame) */
  32673. animate(): void;
  32674. /**
  32675. * Render the scene
  32676. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32677. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  32678. */
  32679. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  32680. /**
  32681. * Freeze all materials
  32682. * A frozen material will not be updatable but should be faster to render
  32683. */
  32684. freezeMaterials(): void;
  32685. /**
  32686. * Unfreeze all materials
  32687. * A frozen material will not be updatable but should be faster to render
  32688. */
  32689. unfreezeMaterials(): void;
  32690. /**
  32691. * Releases all held ressources
  32692. */
  32693. dispose(): void;
  32694. /**
  32695. * Gets if the scene is already disposed
  32696. */
  32697. readonly isDisposed: boolean;
  32698. /**
  32699. * Call this function to reduce memory footprint of the scene.
  32700. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32701. */
  32702. clearCachedVertexData(): void;
  32703. /**
  32704. * This function will remove the local cached buffer data from texture.
  32705. * It will save memory but will prevent the texture from being rebuilt
  32706. */
  32707. cleanCachedTextureBuffer(): void;
  32708. /**
  32709. * Get the world extend vectors with an optional filter
  32710. *
  32711. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32712. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32713. */
  32714. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32715. min: Vector3;
  32716. max: Vector3;
  32717. };
  32718. /**
  32719. * Creates a ray that can be used to pick in the scene
  32720. * @param x defines the x coordinate of the origin (on-screen)
  32721. * @param y defines the y coordinate of the origin (on-screen)
  32722. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32723. * @param camera defines the camera to use for the picking
  32724. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32725. * @returns a Ray
  32726. */
  32727. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32728. /**
  32729. * Creates a ray that can be used to pick in the scene
  32730. * @param x defines the x coordinate of the origin (on-screen)
  32731. * @param y defines the y coordinate of the origin (on-screen)
  32732. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32733. * @param result defines the ray where to store the picking ray
  32734. * @param camera defines the camera to use for the picking
  32735. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32736. * @returns the current scene
  32737. */
  32738. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32739. /**
  32740. * Creates a ray that can be used to pick in the scene
  32741. * @param x defines the x coordinate of the origin (on-screen)
  32742. * @param y defines the y coordinate of the origin (on-screen)
  32743. * @param camera defines the camera to use for the picking
  32744. * @returns a Ray
  32745. */
  32746. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32747. /**
  32748. * Creates a ray that can be used to pick in the scene
  32749. * @param x defines the x coordinate of the origin (on-screen)
  32750. * @param y defines the y coordinate of the origin (on-screen)
  32751. * @param result defines the ray where to store the picking ray
  32752. * @param camera defines the camera to use for the picking
  32753. * @returns the current scene
  32754. */
  32755. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32756. /** Launch a ray to try to pick a mesh in the scene
  32757. * @param x position on screen
  32758. * @param y position on screen
  32759. * @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
  32760. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32761. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32762. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32763. * @returns a PickingInfo
  32764. */
  32765. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  32766. /** Use the given ray to pick a mesh in the scene
  32767. * @param ray The ray to use to pick meshes
  32768. * @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
  32769. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32770. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32771. * @returns a PickingInfo
  32772. */
  32773. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  32774. /**
  32775. * Launch a ray to try to pick a mesh in the scene
  32776. * @param x X position on screen
  32777. * @param y Y position on screen
  32778. * @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
  32779. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32780. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32781. * @returns an array of PickingInfo
  32782. */
  32783. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32784. /**
  32785. * Launch a ray to try to pick a mesh in the scene
  32786. * @param ray Ray to use
  32787. * @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
  32788. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32789. * @returns an array of PickingInfo
  32790. */
  32791. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32792. /**
  32793. * Force the value of meshUnderPointer
  32794. * @param mesh defines the mesh to use
  32795. */
  32796. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32797. /**
  32798. * Gets the mesh under the pointer
  32799. * @returns a Mesh or null if no mesh is under the pointer
  32800. */
  32801. getPointerOverMesh(): Nullable<AbstractMesh>;
  32802. /** @hidden */ rebuildGeometries(): void;
  32803. /** @hidden */ rebuildTextures(): void;
  32804. private _getByTags;
  32805. /**
  32806. * Get a list of meshes by tags
  32807. * @param tagsQuery defines the tags query to use
  32808. * @param forEach defines a predicate used to filter results
  32809. * @returns an array of Mesh
  32810. */
  32811. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32812. /**
  32813. * Get a list of cameras by tags
  32814. * @param tagsQuery defines the tags query to use
  32815. * @param forEach defines a predicate used to filter results
  32816. * @returns an array of Camera
  32817. */
  32818. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32819. /**
  32820. * Get a list of lights by tags
  32821. * @param tagsQuery defines the tags query to use
  32822. * @param forEach defines a predicate used to filter results
  32823. * @returns an array of Light
  32824. */
  32825. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32826. /**
  32827. * Get a list of materials by tags
  32828. * @param tagsQuery defines the tags query to use
  32829. * @param forEach defines a predicate used to filter results
  32830. * @returns an array of Material
  32831. */
  32832. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32833. /**
  32834. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32835. * This allowed control for front to back rendering or reversly depending of the special needs.
  32836. *
  32837. * @param renderingGroupId The rendering group id corresponding to its index
  32838. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32839. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32840. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32841. */
  32842. 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;
  32843. /**
  32844. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32845. *
  32846. * @param renderingGroupId The rendering group id corresponding to its index
  32847. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32848. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32849. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32850. */
  32851. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32852. /**
  32853. * Gets the current auto clear configuration for one rendering group of the rendering
  32854. * manager.
  32855. * @param index the rendering group index to get the information for
  32856. * @returns The auto clear setup for the requested rendering group
  32857. */
  32858. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32859. private _blockMaterialDirtyMechanism;
  32860. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32861. blockMaterialDirtyMechanism: boolean;
  32862. /**
  32863. * Will flag all materials as dirty to trigger new shader compilation
  32864. * @param flag defines the flag used to specify which material part must be marked as dirty
  32865. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32866. */
  32867. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32868. /** @hidden */ loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  32869. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32870. }
  32871. }
  32872. declare module BABYLON {
  32873. /**
  32874. * Set of assets to keep when moving a scene into an asset container.
  32875. */
  32876. export class KeepAssets extends AbstractScene {
  32877. }
  32878. /**
  32879. * Container with a set of assets that can be added or removed from a scene.
  32880. */
  32881. export class AssetContainer extends AbstractScene {
  32882. /**
  32883. * The scene the AssetContainer belongs to.
  32884. */
  32885. scene: Scene;
  32886. /**
  32887. * Instantiates an AssetContainer.
  32888. * @param scene The scene the AssetContainer belongs to.
  32889. */
  32890. constructor(scene: Scene);
  32891. /**
  32892. * Adds all the assets from the container to the scene.
  32893. */
  32894. addAllToScene(): void;
  32895. /**
  32896. * Removes all the assets in the container from the scene
  32897. */
  32898. removeAllFromScene(): void;
  32899. /**
  32900. * Disposes all the assets in the container
  32901. */
  32902. dispose(): void;
  32903. private _moveAssets;
  32904. /**
  32905. * Removes all the assets contained in the scene and adds them to the container.
  32906. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32907. */
  32908. moveAllFromScene(keepAssets?: KeepAssets): void;
  32909. /**
  32910. * 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.
  32911. * @returns the root mesh
  32912. */
  32913. createRootMesh(): Mesh;
  32914. }
  32915. }
  32916. declare module BABYLON {
  32917. /**
  32918. * Defines how the parser contract is defined.
  32919. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32920. */
  32921. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32922. /**
  32923. * Defines how the individual parser contract is defined.
  32924. * These parser can parse an individual asset
  32925. */
  32926. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32927. /**
  32928. * Base class of the scene acting as a container for the different elements composing a scene.
  32929. * This class is dynamically extended by the different components of the scene increasing
  32930. * flexibility and reducing coupling
  32931. */
  32932. export abstract class AbstractScene {
  32933. /**
  32934. * Stores the list of available parsers in the application.
  32935. */
  32936. private static _BabylonFileParsers;
  32937. /**
  32938. * Stores the list of available individual parsers in the application.
  32939. */
  32940. private static _IndividualBabylonFileParsers;
  32941. /**
  32942. * Adds a parser in the list of available ones
  32943. * @param name Defines the name of the parser
  32944. * @param parser Defines the parser to add
  32945. */
  32946. static AddParser(name: string, parser: BabylonFileParser): void;
  32947. /**
  32948. * Gets a general parser from the list of avaialble ones
  32949. * @param name Defines the name of the parser
  32950. * @returns the requested parser or null
  32951. */
  32952. static GetParser(name: string): Nullable<BabylonFileParser>;
  32953. /**
  32954. * Adds n individual parser in the list of available ones
  32955. * @param name Defines the name of the parser
  32956. * @param parser Defines the parser to add
  32957. */
  32958. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32959. /**
  32960. * Gets an individual parser from the list of avaialble ones
  32961. * @param name Defines the name of the parser
  32962. * @returns the requested parser or null
  32963. */
  32964. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32965. /**
  32966. * Parser json data and populate both a scene and its associated container object
  32967. * @param jsonData Defines the data to parse
  32968. * @param scene Defines the scene to parse the data for
  32969. * @param container Defines the container attached to the parsing sequence
  32970. * @param rootUrl Defines the root url of the data
  32971. */
  32972. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32973. /**
  32974. * Gets the list of root nodes (ie. nodes with no parent)
  32975. */
  32976. rootNodes: Node[];
  32977. /** All of the cameras added to this scene
  32978. * @see http://doc.babylonjs.com/babylon101/cameras
  32979. */
  32980. cameras: Camera[];
  32981. /**
  32982. * All of the lights added to this scene
  32983. * @see http://doc.babylonjs.com/babylon101/lights
  32984. */
  32985. lights: Light[];
  32986. /**
  32987. * All of the (abstract) meshes added to this scene
  32988. */
  32989. meshes: AbstractMesh[];
  32990. /**
  32991. * The list of skeletons added to the scene
  32992. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32993. */
  32994. skeletons: Skeleton[];
  32995. /**
  32996. * All of the particle systems added to this scene
  32997. * @see http://doc.babylonjs.com/babylon101/particles
  32998. */
  32999. particleSystems: IParticleSystem[];
  33000. /**
  33001. * Gets a list of Animations associated with the scene
  33002. */
  33003. animations: Animation[];
  33004. /**
  33005. * All of the animation groups added to this scene
  33006. * @see http://doc.babylonjs.com/how_to/group
  33007. */
  33008. animationGroups: AnimationGroup[];
  33009. /**
  33010. * All of the multi-materials added to this scene
  33011. * @see http://doc.babylonjs.com/how_to/multi_materials
  33012. */
  33013. multiMaterials: MultiMaterial[];
  33014. /**
  33015. * All of the materials added to this scene
  33016. * In the context of a Scene, it is not supposed to be modified manually.
  33017. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33018. * Note also that the order of the Material wihin the array is not significant and might change.
  33019. * @see http://doc.babylonjs.com/babylon101/materials
  33020. */
  33021. materials: Material[];
  33022. /**
  33023. * The list of morph target managers added to the scene
  33024. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33025. */
  33026. morphTargetManagers: MorphTargetManager[];
  33027. /**
  33028. * The list of geometries used in the scene.
  33029. */
  33030. geometries: Geometry[];
  33031. /**
  33032. * All of the tranform nodes added to this scene
  33033. * In the context of a Scene, it is not supposed to be modified manually.
  33034. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33035. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33036. * @see http://doc.babylonjs.com/how_to/transformnode
  33037. */
  33038. transformNodes: TransformNode[];
  33039. /**
  33040. * ActionManagers available on the scene.
  33041. */
  33042. actionManagers: AbstractActionManager[];
  33043. /**
  33044. * Textures to keep.
  33045. */
  33046. textures: BaseTexture[];
  33047. /**
  33048. * Environment texture for the scene
  33049. */
  33050. environmentTexture: Nullable<BaseTexture>;
  33051. }
  33052. }
  33053. declare module BABYLON {
  33054. /**
  33055. * Defines a sound that can be played in the application.
  33056. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33058. */
  33059. export class Sound {
  33060. /**
  33061. * The name of the sound in the scene.
  33062. */
  33063. name: string;
  33064. /**
  33065. * Does the sound autoplay once loaded.
  33066. */
  33067. autoplay: boolean;
  33068. /**
  33069. * Does the sound loop after it finishes playing once.
  33070. */
  33071. loop: boolean;
  33072. /**
  33073. * Does the sound use a custom attenuation curve to simulate the falloff
  33074. * happening when the source gets further away from the camera.
  33075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33076. */
  33077. useCustomAttenuation: boolean;
  33078. /**
  33079. * The sound track id this sound belongs to.
  33080. */
  33081. soundTrackId: number;
  33082. /**
  33083. * Is this sound currently played.
  33084. */
  33085. isPlaying: boolean;
  33086. /**
  33087. * Is this sound currently paused.
  33088. */
  33089. isPaused: boolean;
  33090. /**
  33091. * Does this sound enables spatial sound.
  33092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33093. */
  33094. spatialSound: boolean;
  33095. /**
  33096. * Define the reference distance the sound should be heard perfectly.
  33097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33098. */
  33099. refDistance: number;
  33100. /**
  33101. * Define the roll off factor of spatial sounds.
  33102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33103. */
  33104. rolloffFactor: number;
  33105. /**
  33106. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33108. */
  33109. maxDistance: number;
  33110. /**
  33111. * Define the distance attenuation model the sound will follow.
  33112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33113. */
  33114. distanceModel: string;
  33115. /**
  33116. * @hidden
  33117. * Back Compat
  33118. **/
  33119. onended: () => any;
  33120. /**
  33121. * Observable event when the current playing sound finishes.
  33122. */
  33123. onEndedObservable: Observable<Sound>;
  33124. private _panningModel;
  33125. private _playbackRate;
  33126. private _streaming;
  33127. private _startTime;
  33128. private _startOffset;
  33129. private _position;
  33130. /** @hidden */ positionInEmitterSpace: boolean;
  33131. private _localDirection;
  33132. private _volume;
  33133. private _isReadyToPlay;
  33134. private _isDirectional;
  33135. private _readyToPlayCallback;
  33136. private _audioBuffer;
  33137. private _soundSource;
  33138. private _streamingSource;
  33139. private _soundPanner;
  33140. private _soundGain;
  33141. private _inputAudioNode;
  33142. private _outputAudioNode;
  33143. private _coneInnerAngle;
  33144. private _coneOuterAngle;
  33145. private _coneOuterGain;
  33146. private _scene;
  33147. private _connectedTransformNode;
  33148. private _customAttenuationFunction;
  33149. private _registerFunc;
  33150. private _isOutputConnected;
  33151. private _htmlAudioElement;
  33152. private _urlType;
  33153. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33154. /**
  33155. * Create a sound and attach it to a scene
  33156. * @param name Name of your sound
  33157. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33158. * @param scene defines the scene the sound belongs to
  33159. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33160. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33161. */
  33162. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33163. /**
  33164. * Release the sound and its associated resources
  33165. */
  33166. dispose(): void;
  33167. /**
  33168. * Gets if the sounds is ready to be played or not.
  33169. * @returns true if ready, otherwise false
  33170. */
  33171. isReady(): boolean;
  33172. private _soundLoaded;
  33173. /**
  33174. * Sets the data of the sound from an audiobuffer
  33175. * @param audioBuffer The audioBuffer containing the data
  33176. */
  33177. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33178. /**
  33179. * Updates the current sounds options such as maxdistance, loop...
  33180. * @param options A JSON object containing values named as the object properties
  33181. */
  33182. updateOptions(options: any): void;
  33183. private _createSpatialParameters;
  33184. private _updateSpatialParameters;
  33185. /**
  33186. * Switch the panning model to HRTF:
  33187. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33189. */
  33190. switchPanningModelToHRTF(): void;
  33191. /**
  33192. * Switch the panning model to Equal Power:
  33193. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33195. */
  33196. switchPanningModelToEqualPower(): void;
  33197. private _switchPanningModel;
  33198. /**
  33199. * Connect this sound to a sound track audio node like gain...
  33200. * @param soundTrackAudioNode the sound track audio node to connect to
  33201. */
  33202. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33203. /**
  33204. * Transform this sound into a directional source
  33205. * @param coneInnerAngle Size of the inner cone in degree
  33206. * @param coneOuterAngle Size of the outer cone in degree
  33207. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33208. */
  33209. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33210. /**
  33211. * Gets or sets the inner angle for the directional cone.
  33212. */
  33213. /**
  33214. * Gets or sets the inner angle for the directional cone.
  33215. */
  33216. directionalConeInnerAngle: number;
  33217. /**
  33218. * Gets or sets the outer angle for the directional cone.
  33219. */
  33220. /**
  33221. * Gets or sets the outer angle for the directional cone.
  33222. */
  33223. directionalConeOuterAngle: number;
  33224. /**
  33225. * Sets the position of the emitter if spatial sound is enabled
  33226. * @param newPosition Defines the new posisiton
  33227. */
  33228. setPosition(newPosition: Vector3): void;
  33229. /**
  33230. * Sets the local direction of the emitter if spatial sound is enabled
  33231. * @param newLocalDirection Defines the new local direction
  33232. */
  33233. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33234. private _updateDirection;
  33235. /** @hidden */
  33236. updateDistanceFromListener(): void;
  33237. /**
  33238. * Sets a new custom attenuation function for the sound.
  33239. * @param callback Defines the function used for the attenuation
  33240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33241. */
  33242. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33243. /**
  33244. * Play the sound
  33245. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33246. * @param offset (optional) Start the sound setting it at a specific time
  33247. */
  33248. play(time?: number, offset?: number): void;
  33249. private _onended;
  33250. /**
  33251. * Stop the sound
  33252. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33253. */
  33254. stop(time?: number): void;
  33255. /**
  33256. * Put the sound in pause
  33257. */
  33258. pause(): void;
  33259. /**
  33260. * Sets a dedicated volume for this sounds
  33261. * @param newVolume Define the new volume of the sound
  33262. * @param time Define in how long the sound should be at this value
  33263. */
  33264. setVolume(newVolume: number, time?: number): void;
  33265. /**
  33266. * Set the sound play back rate
  33267. * @param newPlaybackRate Define the playback rate the sound should be played at
  33268. */
  33269. setPlaybackRate(newPlaybackRate: number): void;
  33270. /**
  33271. * Gets the volume of the sound.
  33272. * @returns the volume of the sound
  33273. */
  33274. getVolume(): number;
  33275. /**
  33276. * Attach the sound to a dedicated mesh
  33277. * @param transformNode The transform node to connect the sound with
  33278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33279. */
  33280. attachToMesh(transformNode: TransformNode): void;
  33281. /**
  33282. * Detach the sound from the previously attached mesh
  33283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33284. */
  33285. detachFromMesh(): void;
  33286. private _onRegisterAfterWorldMatrixUpdate;
  33287. /**
  33288. * Clone the current sound in the scene.
  33289. * @returns the new sound clone
  33290. */
  33291. clone(): Nullable<Sound>;
  33292. /**
  33293. * Gets the current underlying audio buffer containing the data
  33294. * @returns the audio buffer
  33295. */
  33296. getAudioBuffer(): Nullable<AudioBuffer>;
  33297. /**
  33298. * Serializes the Sound in a JSON representation
  33299. * @returns the JSON representation of the sound
  33300. */
  33301. serialize(): any;
  33302. /**
  33303. * Parse a JSON representation of a sound to innstantiate in a given scene
  33304. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33305. * @param scene Define the scene the new parsed sound should be created in
  33306. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33307. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33308. * @returns the newly parsed sound
  33309. */
  33310. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33311. }
  33312. }
  33313. declare module BABYLON {
  33314. /**
  33315. * This defines an action helpful to play a defined sound on a triggered action.
  33316. */
  33317. export class PlaySoundAction extends Action {
  33318. private _sound;
  33319. /**
  33320. * Instantiate the action
  33321. * @param triggerOptions defines the trigger options
  33322. * @param sound defines the sound to play
  33323. * @param condition defines the trigger related conditions
  33324. */
  33325. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33326. /** @hidden */ prepare(): void;
  33327. /**
  33328. * Execute the action and play the sound.
  33329. */
  33330. execute(): void;
  33331. /**
  33332. * Serializes the actions and its related information.
  33333. * @param parent defines the object to serialize in
  33334. * @returns the serialized object
  33335. */
  33336. serialize(parent: any): any;
  33337. }
  33338. /**
  33339. * This defines an action helpful to stop a defined sound on a triggered action.
  33340. */
  33341. export class StopSoundAction extends Action {
  33342. private _sound;
  33343. /**
  33344. * Instantiate the action
  33345. * @param triggerOptions defines the trigger options
  33346. * @param sound defines the sound to stop
  33347. * @param condition defines the trigger related conditions
  33348. */
  33349. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33350. /** @hidden */ prepare(): void;
  33351. /**
  33352. * Execute the action and stop the sound.
  33353. */
  33354. execute(): void;
  33355. /**
  33356. * Serializes the actions and its related information.
  33357. * @param parent defines the object to serialize in
  33358. * @returns the serialized object
  33359. */
  33360. serialize(parent: any): any;
  33361. }
  33362. }
  33363. declare module BABYLON {
  33364. /**
  33365. * This defines an action responsible to change the value of a property
  33366. * by interpolating between its current value and the newly set one once triggered.
  33367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33368. */
  33369. export class InterpolateValueAction extends Action {
  33370. /**
  33371. * Defines the path of the property where the value should be interpolated
  33372. */
  33373. propertyPath: string;
  33374. /**
  33375. * Defines the target value at the end of the interpolation.
  33376. */
  33377. value: any;
  33378. /**
  33379. * Defines the time it will take for the property to interpolate to the value.
  33380. */
  33381. duration: number;
  33382. /**
  33383. * Defines if the other scene animations should be stopped when the action has been triggered
  33384. */
  33385. stopOtherAnimations?: boolean;
  33386. /**
  33387. * Defines a callback raised once the interpolation animation has been done.
  33388. */
  33389. onInterpolationDone?: () => void;
  33390. /**
  33391. * Observable triggered once the interpolation animation has been done.
  33392. */
  33393. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33394. private _target;
  33395. private _effectiveTarget;
  33396. private _property;
  33397. /**
  33398. * Instantiate the action
  33399. * @param triggerOptions defines the trigger options
  33400. * @param target defines the object containing the value to interpolate
  33401. * @param propertyPath defines the path to the property in the target object
  33402. * @param value defines the target value at the end of the interpolation
  33403. * @param duration deines the time it will take for the property to interpolate to the value.
  33404. * @param condition defines the trigger related conditions
  33405. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33406. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33407. */
  33408. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33409. /** @hidden */ prepare(): void;
  33410. /**
  33411. * Execute the action starts the value interpolation.
  33412. */
  33413. execute(): void;
  33414. /**
  33415. * Serializes the actions and its related information.
  33416. * @param parent defines the object to serialize in
  33417. * @returns the serialized object
  33418. */
  33419. serialize(parent: any): any;
  33420. }
  33421. }
  33422. declare module BABYLON {
  33423. /**
  33424. * Options allowed during the creation of a sound track.
  33425. */
  33426. export interface ISoundTrackOptions {
  33427. /**
  33428. * The volume the sound track should take during creation
  33429. */
  33430. volume?: number;
  33431. /**
  33432. * Define if the sound track is the main sound track of the scene
  33433. */
  33434. mainTrack?: boolean;
  33435. }
  33436. /**
  33437. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33438. * It will be also used in a future release to apply effects on a specific track.
  33439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33440. */
  33441. export class SoundTrack {
  33442. /**
  33443. * The unique identifier of the sound track in the scene.
  33444. */
  33445. id: number;
  33446. /**
  33447. * The list of sounds included in the sound track.
  33448. */
  33449. soundCollection: Array<Sound>;
  33450. private _outputAudioNode;
  33451. private _scene;
  33452. private _isMainTrack;
  33453. private _connectedAnalyser;
  33454. private _options;
  33455. private _isInitialized;
  33456. /**
  33457. * Creates a new sound track.
  33458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33459. * @param scene Define the scene the sound track belongs to
  33460. * @param options
  33461. */
  33462. constructor(scene: Scene, options?: ISoundTrackOptions);
  33463. private _initializeSoundTrackAudioGraph;
  33464. /**
  33465. * Release the sound track and its associated resources
  33466. */
  33467. dispose(): void;
  33468. /**
  33469. * Adds a sound to this sound track
  33470. * @param sound define the cound to add
  33471. * @ignoreNaming
  33472. */
  33473. AddSound(sound: Sound): void;
  33474. /**
  33475. * Removes a sound to this sound track
  33476. * @param sound define the cound to remove
  33477. * @ignoreNaming
  33478. */
  33479. RemoveSound(sound: Sound): void;
  33480. /**
  33481. * Set a global volume for the full sound track.
  33482. * @param newVolume Define the new volume of the sound track
  33483. */
  33484. setVolume(newVolume: number): void;
  33485. /**
  33486. * Switch the panning model to HRTF:
  33487. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33489. */
  33490. switchPanningModelToHRTF(): void;
  33491. /**
  33492. * Switch the panning model to Equal Power:
  33493. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33495. */
  33496. switchPanningModelToEqualPower(): void;
  33497. /**
  33498. * Connect the sound track to an audio analyser allowing some amazing
  33499. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33501. * @param analyser The analyser to connect to the engine
  33502. */
  33503. connectToAnalyser(analyser: Analyser): void;
  33504. }
  33505. }
  33506. declare module BABYLON {
  33507. interface AbstractScene {
  33508. /**
  33509. * The list of sounds used in the scene.
  33510. */
  33511. sounds: Nullable<Array<Sound>>;
  33512. }
  33513. interface Scene {
  33514. /**
  33515. * @hidden
  33516. * Backing field
  33517. */ mainSoundTrack: SoundTrack;
  33518. /**
  33519. * The main sound track played by the scene.
  33520. * It cotains your primary collection of sounds.
  33521. */
  33522. mainSoundTrack: SoundTrack;
  33523. /**
  33524. * The list of sound tracks added to the scene
  33525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33526. */
  33527. soundTracks: Nullable<Array<SoundTrack>>;
  33528. /**
  33529. * Gets a sound using a given name
  33530. * @param name defines the name to search for
  33531. * @return the found sound or null if not found at all.
  33532. */
  33533. getSoundByName(name: string): Nullable<Sound>;
  33534. /**
  33535. * Gets or sets if audio support is enabled
  33536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33537. */
  33538. audioEnabled: boolean;
  33539. /**
  33540. * Gets or sets if audio will be output to headphones
  33541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33542. */
  33543. headphone: boolean;
  33544. }
  33545. /**
  33546. * Defines the sound scene component responsible to manage any sounds
  33547. * in a given scene.
  33548. */
  33549. export class AudioSceneComponent implements ISceneSerializableComponent {
  33550. /**
  33551. * The component name helpfull to identify the component in the list of scene components.
  33552. */
  33553. readonly name: string;
  33554. /**
  33555. * The scene the component belongs to.
  33556. */
  33557. scene: Scene;
  33558. private _audioEnabled;
  33559. /**
  33560. * Gets whether audio is enabled or not.
  33561. * Please use related enable/disable method to switch state.
  33562. */
  33563. readonly audioEnabled: boolean;
  33564. private _headphone;
  33565. /**
  33566. * Gets whether audio is outputing to headphone or not.
  33567. * Please use the according Switch methods to change output.
  33568. */
  33569. readonly headphone: boolean;
  33570. /**
  33571. * Creates a new instance of the component for the given scene
  33572. * @param scene Defines the scene to register the component in
  33573. */
  33574. constructor(scene: Scene);
  33575. /**
  33576. * Registers the component in a given scene
  33577. */
  33578. register(): void;
  33579. /**
  33580. * Rebuilds the elements related to this component in case of
  33581. * context lost for instance.
  33582. */
  33583. rebuild(): void;
  33584. /**
  33585. * Serializes the component data to the specified json object
  33586. * @param serializationObject The object to serialize to
  33587. */
  33588. serialize(serializationObject: any): void;
  33589. /**
  33590. * Adds all the element from the container to the scene
  33591. * @param container the container holding the elements
  33592. */
  33593. addFromContainer(container: AbstractScene): void;
  33594. /**
  33595. * Removes all the elements in the container from the scene
  33596. * @param container contains the elements to remove
  33597. * @param dispose if the removed element should be disposed (default: false)
  33598. */
  33599. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  33600. /**
  33601. * Disposes the component and the associated ressources.
  33602. */
  33603. dispose(): void;
  33604. /**
  33605. * Disables audio in the associated scene.
  33606. */
  33607. disableAudio(): void;
  33608. /**
  33609. * Enables audio in the associated scene.
  33610. */
  33611. enableAudio(): void;
  33612. /**
  33613. * Switch audio to headphone output.
  33614. */
  33615. switchAudioModeForHeadphones(): void;
  33616. /**
  33617. * Switch audio to normal speakers.
  33618. */
  33619. switchAudioModeForNormalSpeakers(): void;
  33620. private _afterRender;
  33621. }
  33622. }
  33623. declare module BABYLON {
  33624. /**
  33625. * Wraps one or more Sound objects and selects one with random weight for playback.
  33626. */
  33627. export class WeightedSound {
  33628. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33629. loop: boolean;
  33630. private _coneInnerAngle;
  33631. private _coneOuterAngle;
  33632. private _volume;
  33633. /** A Sound is currently playing. */
  33634. isPlaying: boolean;
  33635. /** A Sound is currently paused. */
  33636. isPaused: boolean;
  33637. private _sounds;
  33638. private _weights;
  33639. private _currentIndex?;
  33640. /**
  33641. * Creates a new WeightedSound from the list of sounds given.
  33642. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33643. * @param sounds Array of Sounds that will be selected from.
  33644. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33645. */
  33646. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33647. /**
  33648. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33649. */
  33650. /**
  33651. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33652. */
  33653. directionalConeInnerAngle: number;
  33654. /**
  33655. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33656. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33657. */
  33658. /**
  33659. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33660. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33661. */
  33662. directionalConeOuterAngle: number;
  33663. /**
  33664. * Playback volume.
  33665. */
  33666. /**
  33667. * Playback volume.
  33668. */
  33669. volume: number;
  33670. private _onended;
  33671. /**
  33672. * Suspend playback
  33673. */
  33674. pause(): void;
  33675. /**
  33676. * Stop playback
  33677. */
  33678. stop(): void;
  33679. /**
  33680. * Start playback.
  33681. * @param startOffset Position the clip head at a specific time in seconds.
  33682. */
  33683. play(startOffset?: number): void;
  33684. }
  33685. }
  33686. declare module BABYLON {
  33687. /**
  33688. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33689. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33690. */
  33691. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33692. /**
  33693. * Gets the name of the behavior.
  33694. */
  33695. readonly name: string;
  33696. /**
  33697. * The easing function used by animations
  33698. */
  33699. static EasingFunction: BackEase;
  33700. /**
  33701. * The easing mode used by animations
  33702. */
  33703. static EasingMode: number;
  33704. /**
  33705. * The duration of the animation, in milliseconds
  33706. */
  33707. transitionDuration: number;
  33708. /**
  33709. * Length of the distance animated by the transition when lower radius is reached
  33710. */
  33711. lowerRadiusTransitionRange: number;
  33712. /**
  33713. * Length of the distance animated by the transition when upper radius is reached
  33714. */
  33715. upperRadiusTransitionRange: number;
  33716. private _autoTransitionRange;
  33717. /**
  33718. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33719. */
  33720. /**
  33721. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33722. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33723. */
  33724. autoTransitionRange: boolean;
  33725. private _attachedCamera;
  33726. private _onAfterCheckInputsObserver;
  33727. private _onMeshTargetChangedObserver;
  33728. /**
  33729. * Initializes the behavior.
  33730. */
  33731. init(): void;
  33732. /**
  33733. * Attaches the behavior to its arc rotate camera.
  33734. * @param camera Defines the camera to attach the behavior to
  33735. */
  33736. attach(camera: ArcRotateCamera): void;
  33737. /**
  33738. * Detaches the behavior from its current arc rotate camera.
  33739. */
  33740. detach(): void;
  33741. private _radiusIsAnimating;
  33742. private _radiusBounceTransition;
  33743. private _animatables;
  33744. private _cachedWheelPrecision;
  33745. /**
  33746. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33747. * @param radiusLimit The limit to check against.
  33748. * @return Bool to indicate if at limit.
  33749. */
  33750. private _isRadiusAtLimit;
  33751. /**
  33752. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33753. * @param radiusDelta The delta by which to animate to. Can be negative.
  33754. */
  33755. private _applyBoundRadiusAnimation;
  33756. /**
  33757. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33758. */
  33759. protected _clearAnimationLocks(): void;
  33760. /**
  33761. * Stops and removes all animations that have been applied to the camera
  33762. */
  33763. stopAllAnimations(): void;
  33764. }
  33765. }
  33766. declare module BABYLON {
  33767. /**
  33768. * 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.
  33769. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33770. */
  33771. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33772. /**
  33773. * Gets the name of the behavior.
  33774. */
  33775. readonly name: string;
  33776. private _mode;
  33777. private _radiusScale;
  33778. private _positionScale;
  33779. private _defaultElevation;
  33780. private _elevationReturnTime;
  33781. private _elevationReturnWaitTime;
  33782. private _zoomStopsAnimation;
  33783. private _framingTime;
  33784. /**
  33785. * The easing function used by animations
  33786. */
  33787. static EasingFunction: ExponentialEase;
  33788. /**
  33789. * The easing mode used by animations
  33790. */
  33791. static EasingMode: number;
  33792. /**
  33793. * Sets the current mode used by the behavior
  33794. */
  33795. /**
  33796. * Gets current mode used by the behavior.
  33797. */
  33798. mode: number;
  33799. /**
  33800. * Sets the scale applied to the radius (1 by default)
  33801. */
  33802. /**
  33803. * Gets the scale applied to the radius
  33804. */
  33805. radiusScale: number;
  33806. /**
  33807. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33808. */
  33809. /**
  33810. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33811. */
  33812. positionScale: number;
  33813. /**
  33814. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33815. * behaviour is triggered, in radians.
  33816. */
  33817. /**
  33818. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33819. * behaviour is triggered, in radians.
  33820. */
  33821. defaultElevation: number;
  33822. /**
  33823. * Sets the time (in milliseconds) taken to return to the default beta position.
  33824. * Negative value indicates camera should not return to default.
  33825. */
  33826. /**
  33827. * Gets the time (in milliseconds) taken to return to the default beta position.
  33828. * Negative value indicates camera should not return to default.
  33829. */
  33830. elevationReturnTime: number;
  33831. /**
  33832. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33833. */
  33834. /**
  33835. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33836. */
  33837. elevationReturnWaitTime: number;
  33838. /**
  33839. * Sets the flag that indicates if user zooming should stop animation.
  33840. */
  33841. /**
  33842. * Gets the flag that indicates if user zooming should stop animation.
  33843. */
  33844. zoomStopsAnimation: boolean;
  33845. /**
  33846. * Sets the transition time when framing the mesh, in milliseconds
  33847. */
  33848. /**
  33849. * Gets the transition time when framing the mesh, in milliseconds
  33850. */
  33851. framingTime: number;
  33852. /**
  33853. * Define if the behavior should automatically change the configured
  33854. * camera limits and sensibilities.
  33855. */
  33856. autoCorrectCameraLimitsAndSensibility: boolean;
  33857. private _onPrePointerObservableObserver;
  33858. private _onAfterCheckInputsObserver;
  33859. private _onMeshTargetChangedObserver;
  33860. private _attachedCamera;
  33861. private _isPointerDown;
  33862. private _lastInteractionTime;
  33863. /**
  33864. * Initializes the behavior.
  33865. */
  33866. init(): void;
  33867. /**
  33868. * Attaches the behavior to its arc rotate camera.
  33869. * @param camera Defines the camera to attach the behavior to
  33870. */
  33871. attach(camera: ArcRotateCamera): void;
  33872. /**
  33873. * Detaches the behavior from its current arc rotate camera.
  33874. */
  33875. detach(): void;
  33876. private _animatables;
  33877. private _betaIsAnimating;
  33878. private _betaTransition;
  33879. private _radiusTransition;
  33880. private _vectorTransition;
  33881. /**
  33882. * Targets the given mesh and updates zoom level accordingly.
  33883. * @param mesh The mesh to target.
  33884. * @param radius Optional. If a cached radius position already exists, overrides default.
  33885. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33886. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33887. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33888. */
  33889. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33890. /**
  33891. * Targets the given mesh with its children and updates zoom level accordingly.
  33892. * @param mesh The mesh to target.
  33893. * @param radius Optional. If a cached radius position already exists, overrides default.
  33894. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33895. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33896. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33897. */
  33898. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33899. /**
  33900. * Targets the given meshes with their children and updates zoom level accordingly.
  33901. * @param meshes The mesh to target.
  33902. * @param radius Optional. If a cached radius position already exists, overrides default.
  33903. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33904. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33905. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33906. */
  33907. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33908. /**
  33909. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33910. * @param minimumWorld Determines the smaller position of the bounding box extend
  33911. * @param maximumWorld Determines the bigger position of the bounding box extend
  33912. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33913. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33914. */
  33915. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33916. /**
  33917. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33918. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33919. * frustum width.
  33920. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33921. * to fully enclose the mesh in the viewing frustum.
  33922. */
  33923. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33924. /**
  33925. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33926. * is automatically returned to its default position (expected to be above ground plane).
  33927. */
  33928. private _maintainCameraAboveGround;
  33929. /**
  33930. * Returns the frustum slope based on the canvas ratio and camera FOV
  33931. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33932. */
  33933. private _getFrustumSlope;
  33934. /**
  33935. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33936. */
  33937. private _clearAnimationLocks;
  33938. /**
  33939. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33940. */
  33941. private _applyUserInteraction;
  33942. /**
  33943. * Stops and removes all animations that have been applied to the camera
  33944. */
  33945. stopAllAnimations(): void;
  33946. /**
  33947. * Gets a value indicating if the user is moving the camera
  33948. */
  33949. readonly isUserIsMoving: boolean;
  33950. /**
  33951. * The camera can move all the way towards the mesh.
  33952. */
  33953. static IgnoreBoundsSizeMode: number;
  33954. /**
  33955. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33956. */
  33957. static FitFrustumSidesMode: number;
  33958. }
  33959. }
  33960. declare module BABYLON {
  33961. /**
  33962. * Base class for Camera Pointer Inputs.
  33963. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  33964. * for example usage.
  33965. */
  33966. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  33967. /**
  33968. * Defines the camera the input is attached to.
  33969. */
  33970. abstract camera: Camera;
  33971. /**
  33972. * Whether keyboard modifier keys are pressed at time of last mouse event.
  33973. */
  33974. protected _altKey: boolean;
  33975. protected _ctrlKey: boolean;
  33976. protected _metaKey: boolean;
  33977. protected _shiftKey: boolean;
  33978. /**
  33979. * Which mouse buttons were pressed at time of last mouse event.
  33980. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  33981. */
  33982. protected _buttonsPressed: number;
  33983. /**
  33984. * Defines the buttons associated with the input to handle camera move.
  33985. */
  33986. buttons: number[];
  33987. /**
  33988. * Attach the input controls to a specific dom element to get the input from.
  33989. * @param element Defines the element the controls should be listened from
  33990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33991. */
  33992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33993. /**
  33994. * Detach the current controls from the specified dom element.
  33995. * @param element Defines the element to stop listening the inputs from
  33996. */
  33997. detachControl(element: Nullable<HTMLElement>): void;
  33998. /**
  33999. * Gets the class name of the current input.
  34000. * @returns the class name
  34001. */
  34002. getClassName(): string;
  34003. /**
  34004. * Get the friendly name associated with the input class.
  34005. * @returns the input friendly name
  34006. */
  34007. getSimpleName(): string;
  34008. /**
  34009. * Called on pointer POINTERDOUBLETAP event.
  34010. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34011. */
  34012. protected onDoubleTap(type: string): void;
  34013. /**
  34014. * Called on pointer POINTERMOVE event if only a single touch is active.
  34015. * Override this method to provide functionality.
  34016. */
  34017. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34018. /**
  34019. * Called on pointer POINTERMOVE event if multiple touches are active.
  34020. * Override this method to provide functionality.
  34021. */
  34022. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34023. /**
  34024. * Called on JS contextmenu event.
  34025. * Override this method to provide functionality.
  34026. */
  34027. protected onContextMenu(evt: PointerEvent): void;
  34028. /**
  34029. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34030. * press.
  34031. * Override this method to provide functionality.
  34032. */
  34033. protected onButtonDown(evt: PointerEvent): void;
  34034. /**
  34035. * Called each time a new POINTERUP event occurs. Ie, for each button
  34036. * release.
  34037. * Override this method to provide functionality.
  34038. */
  34039. protected onButtonUp(evt: PointerEvent): void;
  34040. /**
  34041. * Called when window becomes inactive.
  34042. * Override this method to provide functionality.
  34043. */
  34044. protected onLostFocus(): void;
  34045. private _pointerInput;
  34046. private _observer;
  34047. private _onLostFocus;
  34048. private pointA;
  34049. private pointB;
  34050. }
  34051. }
  34052. declare module BABYLON {
  34053. /**
  34054. * Manage the pointers inputs to control an arc rotate camera.
  34055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34056. */
  34057. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34058. /**
  34059. * Defines the camera the input is attached to.
  34060. */
  34061. camera: ArcRotateCamera;
  34062. /**
  34063. * Gets the class name of the current input.
  34064. * @returns the class name
  34065. */
  34066. getClassName(): string;
  34067. /**
  34068. * Defines the buttons associated with the input to handle camera move.
  34069. */
  34070. buttons: number[];
  34071. /**
  34072. * Defines the pointer angular sensibility along the X axis or how fast is
  34073. * the camera rotating.
  34074. */
  34075. angularSensibilityX: number;
  34076. /**
  34077. * Defines the pointer angular sensibility along the Y axis or how fast is
  34078. * the camera rotating.
  34079. */
  34080. angularSensibilityY: number;
  34081. /**
  34082. * Defines the pointer pinch precision or how fast is the camera zooming.
  34083. */
  34084. pinchPrecision: number;
  34085. /**
  34086. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34087. * from 0.
  34088. * It defines the percentage of current camera.radius to use as delta when
  34089. * pinch zoom is used.
  34090. */
  34091. pinchDeltaPercentage: number;
  34092. /**
  34093. * Defines the pointer panning sensibility or how fast is the camera moving.
  34094. */
  34095. panningSensibility: number;
  34096. /**
  34097. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34098. */
  34099. multiTouchPanning: boolean;
  34100. /**
  34101. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34102. * zoom (pinch) through multitouch.
  34103. */
  34104. multiTouchPanAndZoom: boolean;
  34105. /**
  34106. * Revers pinch action direction.
  34107. */
  34108. pinchInwards: boolean;
  34109. private _isPanClick;
  34110. private _twoFingerActivityCount;
  34111. private _isPinching;
  34112. /**
  34113. * Called on pointer POINTERMOVE event if only a single touch is active.
  34114. */
  34115. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34116. /**
  34117. * Called on pointer POINTERDOUBLETAP event.
  34118. */
  34119. protected onDoubleTap(type: string): void;
  34120. /**
  34121. * Called on pointer POINTERMOVE event if multiple touches are active.
  34122. */
  34123. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34124. /**
  34125. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34126. * press.
  34127. */
  34128. protected onButtonDown(evt: PointerEvent): void;
  34129. /**
  34130. * Called each time a new POINTERUP event occurs. Ie, for each button
  34131. * release.
  34132. */
  34133. protected onButtonUp(evt: PointerEvent): void;
  34134. /**
  34135. * Called when window becomes inactive.
  34136. */
  34137. protected onLostFocus(): void;
  34138. }
  34139. }
  34140. declare module BABYLON {
  34141. /**
  34142. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34144. */
  34145. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34146. /**
  34147. * Defines the camera the input is attached to.
  34148. */
  34149. camera: ArcRotateCamera;
  34150. /**
  34151. * Defines the list of key codes associated with the up action (increase alpha)
  34152. */
  34153. keysUp: number[];
  34154. /**
  34155. * Defines the list of key codes associated with the down action (decrease alpha)
  34156. */
  34157. keysDown: number[];
  34158. /**
  34159. * Defines the list of key codes associated with the left action (increase beta)
  34160. */
  34161. keysLeft: number[];
  34162. /**
  34163. * Defines the list of key codes associated with the right action (decrease beta)
  34164. */
  34165. keysRight: number[];
  34166. /**
  34167. * Defines the list of key codes associated with the reset action.
  34168. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34169. */
  34170. keysReset: number[];
  34171. /**
  34172. * Defines the panning sensibility of the inputs.
  34173. * (How fast is the camera paning)
  34174. */
  34175. panningSensibility: number;
  34176. /**
  34177. * Defines the zooming sensibility of the inputs.
  34178. * (How fast is the camera zooming)
  34179. */
  34180. zoomingSensibility: number;
  34181. /**
  34182. * Defines wether maintaining the alt key down switch the movement mode from
  34183. * orientation to zoom.
  34184. */
  34185. useAltToZoom: boolean;
  34186. /**
  34187. * Rotation speed of the camera
  34188. */
  34189. angularSpeed: number;
  34190. private _keys;
  34191. private _ctrlPressed;
  34192. private _altPressed;
  34193. private _onCanvasBlurObserver;
  34194. private _onKeyboardObserver;
  34195. private _engine;
  34196. private _scene;
  34197. /**
  34198. * Attach the input controls to a specific dom element to get the input from.
  34199. * @param element Defines the element the controls should be listened from
  34200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34201. */
  34202. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34203. /**
  34204. * Detach the current controls from the specified dom element.
  34205. * @param element Defines the element to stop listening the inputs from
  34206. */
  34207. detachControl(element: Nullable<HTMLElement>): void;
  34208. /**
  34209. * Update the current camera state depending on the inputs that have been used this frame.
  34210. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34211. */
  34212. checkInputs(): void;
  34213. /**
  34214. * Gets the class name of the current intput.
  34215. * @returns the class name
  34216. */
  34217. getClassName(): string;
  34218. /**
  34219. * Get the friendly name associated with the input class.
  34220. * @returns the input friendly name
  34221. */
  34222. getSimpleName(): string;
  34223. }
  34224. }
  34225. declare module BABYLON {
  34226. /**
  34227. * Manage the mouse wheel inputs to control an arc rotate camera.
  34228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34229. */
  34230. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34231. /**
  34232. * Defines the camera the input is attached to.
  34233. */
  34234. camera: ArcRotateCamera;
  34235. /**
  34236. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34237. */
  34238. wheelPrecision: number;
  34239. /**
  34240. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34241. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34242. */
  34243. wheelDeltaPercentage: number;
  34244. private _wheel;
  34245. private _observer;
  34246. /**
  34247. * Attach the input controls to a specific dom element to get the input from.
  34248. * @param element Defines the element the controls should be listened from
  34249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34250. */
  34251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34252. /**
  34253. * Detach the current controls from the specified dom element.
  34254. * @param element Defines the element to stop listening the inputs from
  34255. */
  34256. detachControl(element: Nullable<HTMLElement>): void;
  34257. /**
  34258. * Gets the class name of the current intput.
  34259. * @returns the class name
  34260. */
  34261. getClassName(): string;
  34262. /**
  34263. * Get the friendly name associated with the input class.
  34264. * @returns the input friendly name
  34265. */
  34266. getSimpleName(): string;
  34267. }
  34268. }
  34269. declare module BABYLON {
  34270. /**
  34271. * Default Inputs manager for the ArcRotateCamera.
  34272. * It groups all the default supported inputs for ease of use.
  34273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34274. */
  34275. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34276. /**
  34277. * Instantiates a new ArcRotateCameraInputsManager.
  34278. * @param camera Defines the camera the inputs belong to
  34279. */
  34280. constructor(camera: ArcRotateCamera);
  34281. /**
  34282. * Add mouse wheel input support to the input manager.
  34283. * @returns the current input manager
  34284. */
  34285. addMouseWheel(): ArcRotateCameraInputsManager;
  34286. /**
  34287. * Add pointers input support to the input manager.
  34288. * @returns the current input manager
  34289. */
  34290. addPointers(): ArcRotateCameraInputsManager;
  34291. /**
  34292. * Add keyboard input support to the input manager.
  34293. * @returns the current input manager
  34294. */
  34295. addKeyboard(): ArcRotateCameraInputsManager;
  34296. }
  34297. }
  34298. declare module BABYLON {
  34299. /**
  34300. * This represents an orbital type of camera.
  34301. *
  34302. * 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.
  34303. * 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.
  34304. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34305. */
  34306. export class ArcRotateCamera extends TargetCamera {
  34307. /**
  34308. * Defines the rotation angle of the camera along the longitudinal axis.
  34309. */
  34310. alpha: number;
  34311. /**
  34312. * Defines the rotation angle of the camera along the latitudinal axis.
  34313. */
  34314. beta: number;
  34315. /**
  34316. * Defines the radius of the camera from it s target point.
  34317. */
  34318. radius: number;
  34319. protected _target: Vector3;
  34320. protected _targetHost: Nullable<AbstractMesh>;
  34321. /**
  34322. * Defines the target point of the camera.
  34323. * The camera looks towards it form the radius distance.
  34324. */
  34325. target: Vector3;
  34326. /**
  34327. * Define the current local position of the camera in the scene
  34328. */
  34329. position: Vector3;
  34330. protected _upVector: Vector3;
  34331. protected _upToYMatrix: Matrix;
  34332. protected _YToUpMatrix: Matrix;
  34333. /**
  34334. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34335. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34336. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34337. */
  34338. upVector: Vector3;
  34339. /**
  34340. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34341. */
  34342. setMatUp(): void;
  34343. /**
  34344. * Current inertia value on the longitudinal axis.
  34345. * The bigger this number the longer it will take for the camera to stop.
  34346. */
  34347. inertialAlphaOffset: number;
  34348. /**
  34349. * Current inertia value on the latitudinal axis.
  34350. * The bigger this number the longer it will take for the camera to stop.
  34351. */
  34352. inertialBetaOffset: number;
  34353. /**
  34354. * Current inertia value on the radius axis.
  34355. * The bigger this number the longer it will take for the camera to stop.
  34356. */
  34357. inertialRadiusOffset: number;
  34358. /**
  34359. * Minimum allowed angle on the longitudinal axis.
  34360. * This can help limiting how the Camera is able to move in the scene.
  34361. */
  34362. lowerAlphaLimit: Nullable<number>;
  34363. /**
  34364. * Maximum allowed angle on the longitudinal axis.
  34365. * This can help limiting how the Camera is able to move in the scene.
  34366. */
  34367. upperAlphaLimit: Nullable<number>;
  34368. /**
  34369. * Minimum allowed angle on the latitudinal axis.
  34370. * This can help limiting how the Camera is able to move in the scene.
  34371. */
  34372. lowerBetaLimit: number;
  34373. /**
  34374. * Maximum allowed angle on the latitudinal axis.
  34375. * This can help limiting how the Camera is able to move in the scene.
  34376. */
  34377. upperBetaLimit: number;
  34378. /**
  34379. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34380. * This can help limiting how the Camera is able to move in the scene.
  34381. */
  34382. lowerRadiusLimit: Nullable<number>;
  34383. /**
  34384. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34385. * This can help limiting how the Camera is able to move in the scene.
  34386. */
  34387. upperRadiusLimit: Nullable<number>;
  34388. /**
  34389. * Defines the current inertia value used during panning of the camera along the X axis.
  34390. */
  34391. inertialPanningX: number;
  34392. /**
  34393. * Defines the current inertia value used during panning of the camera along the Y axis.
  34394. */
  34395. inertialPanningY: number;
  34396. /**
  34397. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34398. * Basically if your fingers moves away from more than this distance you will be considered
  34399. * in pinch mode.
  34400. */
  34401. pinchToPanMaxDistance: number;
  34402. /**
  34403. * Defines the maximum distance the camera can pan.
  34404. * This could help keeping the cammera always in your scene.
  34405. */
  34406. panningDistanceLimit: Nullable<number>;
  34407. /**
  34408. * Defines the target of the camera before paning.
  34409. */
  34410. panningOriginTarget: Vector3;
  34411. /**
  34412. * Defines the value of the inertia used during panning.
  34413. * 0 would mean stop inertia and one would mean no decelleration at all.
  34414. */
  34415. panningInertia: number;
  34416. /**
  34417. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34418. */
  34419. angularSensibilityX: number;
  34420. /**
  34421. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34422. */
  34423. angularSensibilityY: number;
  34424. /**
  34425. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34426. */
  34427. pinchPrecision: number;
  34428. /**
  34429. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34430. * It will be used instead of pinchDeltaPrecision if different from 0.
  34431. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34432. */
  34433. pinchDeltaPercentage: number;
  34434. /**
  34435. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34436. */
  34437. panningSensibility: number;
  34438. /**
  34439. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34440. */
  34441. keysUp: number[];
  34442. /**
  34443. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34444. */
  34445. keysDown: number[];
  34446. /**
  34447. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34448. */
  34449. keysLeft: number[];
  34450. /**
  34451. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34452. */
  34453. keysRight: number[];
  34454. /**
  34455. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34456. */
  34457. wheelPrecision: number;
  34458. /**
  34459. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34460. * It will be used instead of pinchDeltaPrecision if different from 0.
  34461. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34462. */
  34463. wheelDeltaPercentage: number;
  34464. /**
  34465. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34466. */
  34467. zoomOnFactor: number;
  34468. /**
  34469. * Defines a screen offset for the camera position.
  34470. */
  34471. targetScreenOffset: Vector2;
  34472. /**
  34473. * Allows the camera to be completely reversed.
  34474. * If false the camera can not arrive upside down.
  34475. */
  34476. allowUpsideDown: boolean;
  34477. /**
  34478. * Define if double tap/click is used to restore the previously saved state of the camera.
  34479. */
  34480. useInputToRestoreState: boolean;
  34481. /** @hidden */ viewMatrix: Matrix;
  34482. /** @hidden */ useCtrlForPanning: boolean;
  34483. /** @hidden */ panningMouseButton: number;
  34484. /**
  34485. * Defines the input associated to the camera.
  34486. */
  34487. inputs: ArcRotateCameraInputsManager;
  34488. /** @hidden */ reset: () => void;
  34489. /**
  34490. * Defines the allowed panning axis.
  34491. */
  34492. panningAxis: Vector3;
  34493. protected _localDirection: Vector3;
  34494. protected _transformedDirection: Vector3;
  34495. private _bouncingBehavior;
  34496. /**
  34497. * Gets the bouncing behavior of the camera if it has been enabled.
  34498. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34499. */
  34500. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34501. /**
  34502. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34503. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34504. */
  34505. useBouncingBehavior: boolean;
  34506. private _framingBehavior;
  34507. /**
  34508. * Gets the framing behavior of the camera if it has been enabled.
  34509. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34510. */
  34511. readonly framingBehavior: Nullable<FramingBehavior>;
  34512. /**
  34513. * Defines if the framing behavior of the camera is enabled on the camera.
  34514. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34515. */
  34516. useFramingBehavior: boolean;
  34517. private _autoRotationBehavior;
  34518. /**
  34519. * Gets the auto rotation behavior of the camera if it has been enabled.
  34520. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34521. */
  34522. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34523. /**
  34524. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34525. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34526. */
  34527. useAutoRotationBehavior: boolean;
  34528. /**
  34529. * Observable triggered when the mesh target has been changed on the camera.
  34530. */
  34531. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34532. /**
  34533. * Event raised when the camera is colliding with a mesh.
  34534. */
  34535. onCollide: (collidedMesh: AbstractMesh) => void;
  34536. /**
  34537. * Defines whether the camera should check collision with the objects oh the scene.
  34538. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34539. */
  34540. checkCollisions: boolean;
  34541. /**
  34542. * Defines the collision radius of the camera.
  34543. * This simulates a sphere around the camera.
  34544. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34545. */
  34546. collisionRadius: Vector3;
  34547. protected _collider: Collider;
  34548. protected _previousPosition: Vector3;
  34549. protected _collisionVelocity: Vector3;
  34550. protected _newPosition: Vector3;
  34551. protected _previousAlpha: number;
  34552. protected _previousBeta: number;
  34553. protected _previousRadius: number;
  34554. protected _collisionTriggered: boolean;
  34555. protected _targetBoundingCenter: Nullable<Vector3>;
  34556. private _computationVector;
  34557. /**
  34558. * Instantiates a new ArcRotateCamera in a given scene
  34559. * @param name Defines the name of the camera
  34560. * @param alpha Defines the camera rotation along the logitudinal axis
  34561. * @param beta Defines the camera rotation along the latitudinal axis
  34562. * @param radius Defines the camera distance from its target
  34563. * @param target Defines the camera target
  34564. * @param scene Defines the scene the camera belongs to
  34565. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34566. */
  34567. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34568. /** @hidden */ initCache(): void;
  34569. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  34570. protected _getTargetPosition(): Vector3;
  34571. private _storedAlpha;
  34572. private _storedBeta;
  34573. private _storedRadius;
  34574. private _storedTarget;
  34575. /**
  34576. * Stores the current state of the camera (alpha, beta, radius and target)
  34577. * @returns the camera itself
  34578. */
  34579. storeState(): Camera;
  34580. /**
  34581. * @hidden
  34582. * Restored camera state. You must call storeState() first
  34583. */ restoreStateValues(): boolean;
  34584. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  34585. /**
  34586. * Attached controls to the current camera.
  34587. * @param element Defines the element the controls should be listened from
  34588. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34589. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34590. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34591. */
  34592. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34593. /**
  34594. * Detach the current controls from the camera.
  34595. * The camera will stop reacting to inputs.
  34596. * @param element Defines the element to stop listening the inputs from
  34597. */
  34598. detachControl(element: HTMLElement): void;
  34599. /** @hidden */ checkInputs(): void;
  34600. protected _checkLimits(): void;
  34601. /**
  34602. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34603. */
  34604. rebuildAnglesAndRadius(): void;
  34605. /**
  34606. * Use a position to define the current camera related information like aplha, beta and radius
  34607. * @param position Defines the position to set the camera at
  34608. */
  34609. setPosition(position: Vector3): void;
  34610. /**
  34611. * Defines the target the camera should look at.
  34612. * This will automatically adapt alpha beta and radius to fit within the new target.
  34613. * @param target Defines the new target as a Vector or a mesh
  34614. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34615. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34616. */
  34617. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34618. /** @hidden */ getViewMatrix(): Matrix;
  34619. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34620. /**
  34621. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34622. * @param meshes Defines the mesh to zoom on
  34623. * @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)
  34624. */
  34625. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34626. /**
  34627. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34628. * The target will be changed but the radius
  34629. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34630. * @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)
  34631. */
  34632. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34633. min: Vector3;
  34634. max: Vector3;
  34635. distance: number;
  34636. }, doNotUpdateMaxZ?: boolean): void;
  34637. /**
  34638. * @override
  34639. * Override Camera.createRigCamera
  34640. */
  34641. createRigCamera(name: string, cameraIndex: number): Camera;
  34642. /**
  34643. * @hidden
  34644. * @override
  34645. * Override Camera._updateRigCameras
  34646. */ updateRigCameras(): void;
  34647. /**
  34648. * Destroy the camera and release the current resources hold by it.
  34649. */
  34650. dispose(): void;
  34651. /**
  34652. * Gets the current object class name.
  34653. * @return the class name
  34654. */
  34655. getClassName(): string;
  34656. }
  34657. }
  34658. declare module BABYLON {
  34659. /**
  34660. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34661. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34662. */
  34663. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34664. /**
  34665. * Gets the name of the behavior.
  34666. */
  34667. readonly name: string;
  34668. private _zoomStopsAnimation;
  34669. private _idleRotationSpeed;
  34670. private _idleRotationWaitTime;
  34671. private _idleRotationSpinupTime;
  34672. /**
  34673. * Sets the flag that indicates if user zooming should stop animation.
  34674. */
  34675. /**
  34676. * Gets the flag that indicates if user zooming should stop animation.
  34677. */
  34678. zoomStopsAnimation: boolean;
  34679. /**
  34680. * Sets the default speed at which the camera rotates around the model.
  34681. */
  34682. /**
  34683. * Gets the default speed at which the camera rotates around the model.
  34684. */
  34685. idleRotationSpeed: number;
  34686. /**
  34687. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34688. */
  34689. /**
  34690. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34691. */
  34692. idleRotationWaitTime: number;
  34693. /**
  34694. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34695. */
  34696. /**
  34697. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34698. */
  34699. idleRotationSpinupTime: number;
  34700. /**
  34701. * Gets a value indicating if the camera is currently rotating because of this behavior
  34702. */
  34703. readonly rotationInProgress: boolean;
  34704. private _onPrePointerObservableObserver;
  34705. private _onAfterCheckInputsObserver;
  34706. private _attachedCamera;
  34707. private _isPointerDown;
  34708. private _lastFrameTime;
  34709. private _lastInteractionTime;
  34710. private _cameraRotationSpeed;
  34711. /**
  34712. * Initializes the behavior.
  34713. */
  34714. init(): void;
  34715. /**
  34716. * Attaches the behavior to its arc rotate camera.
  34717. * @param camera Defines the camera to attach the behavior to
  34718. */
  34719. attach(camera: ArcRotateCamera): void;
  34720. /**
  34721. * Detaches the behavior from its current arc rotate camera.
  34722. */
  34723. detach(): void;
  34724. /**
  34725. * Returns true if user is scrolling.
  34726. * @return true if user is scrolling.
  34727. */
  34728. private _userIsZooming;
  34729. private _lastFrameRadius;
  34730. private _shouldAnimationStopForInteraction;
  34731. /**
  34732. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34733. */
  34734. private _applyUserInteraction;
  34735. private _userIsMoving;
  34736. }
  34737. }
  34738. declare module BABYLON {
  34739. /**
  34740. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34741. */
  34742. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34743. private ui;
  34744. /**
  34745. * The name of the behavior
  34746. */
  34747. name: string;
  34748. /**
  34749. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34750. */
  34751. distanceAwayFromFace: number;
  34752. /**
  34753. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34754. */
  34755. distanceAwayFromBottomOfFace: number;
  34756. private _faceVectors;
  34757. private _target;
  34758. private _scene;
  34759. private _onRenderObserver;
  34760. private _tmpMatrix;
  34761. private _tmpVector;
  34762. /**
  34763. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34764. * @param ui The transform node that should be attched to the mesh
  34765. */
  34766. constructor(ui: TransformNode);
  34767. /**
  34768. * Initializes the behavior
  34769. */
  34770. init(): void;
  34771. private _closestFace;
  34772. private _zeroVector;
  34773. private _lookAtTmpMatrix;
  34774. private _lookAtToRef;
  34775. /**
  34776. * Attaches the AttachToBoxBehavior to the passed in mesh
  34777. * @param target The mesh that the specified node will be attached to
  34778. */
  34779. attach(target: Mesh): void;
  34780. /**
  34781. * Detaches the behavior from the mesh
  34782. */
  34783. detach(): void;
  34784. }
  34785. }
  34786. declare module BABYLON {
  34787. /**
  34788. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34789. */
  34790. export class FadeInOutBehavior implements Behavior<Mesh> {
  34791. /**
  34792. * Time in milliseconds to delay before fading in (Default: 0)
  34793. */
  34794. delay: number;
  34795. /**
  34796. * Time in milliseconds for the mesh to fade in (Default: 300)
  34797. */
  34798. fadeInTime: number;
  34799. private _millisecondsPerFrame;
  34800. private _hovered;
  34801. private _hoverValue;
  34802. private _ownerNode;
  34803. /**
  34804. * Instatiates the FadeInOutBehavior
  34805. */
  34806. constructor();
  34807. /**
  34808. * The name of the behavior
  34809. */
  34810. readonly name: string;
  34811. /**
  34812. * Initializes the behavior
  34813. */
  34814. init(): void;
  34815. /**
  34816. * Attaches the fade behavior on the passed in mesh
  34817. * @param ownerNode The mesh that will be faded in/out once attached
  34818. */
  34819. attach(ownerNode: Mesh): void;
  34820. /**
  34821. * Detaches the behavior from the mesh
  34822. */
  34823. detach(): void;
  34824. /**
  34825. * Triggers the mesh to begin fading in or out
  34826. * @param value if the object should fade in or out (true to fade in)
  34827. */
  34828. fadeIn(value: boolean): void;
  34829. private _update;
  34830. private _setAllVisibility;
  34831. }
  34832. }
  34833. declare module BABYLON {
  34834. /**
  34835. * Class containing a set of static utilities functions for managing Pivots
  34836. * @hidden
  34837. */
  34838. export class PivotTools {
  34839. private static _PivotCached;
  34840. private static _OldPivotPoint;
  34841. private static _PivotTranslation;
  34842. private static _PivotTmpVector;
  34843. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34844. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  34845. }
  34846. }
  34847. declare module BABYLON {
  34848. /**
  34849. * Class containing static functions to help procedurally build meshes
  34850. */
  34851. export class PlaneBuilder {
  34852. /**
  34853. * Creates a plane mesh
  34854. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  34855. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  34856. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  34857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34858. * * If you create a double-sided mesh, you can choose what parts of 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
  34859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34860. * @param name defines the name of the mesh
  34861. * @param options defines the options used to create the mesh
  34862. * @param scene defines the hosting scene
  34863. * @returns the plane mesh
  34864. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  34865. */
  34866. static CreatePlane(name: string, options: {
  34867. size?: number;
  34868. width?: number;
  34869. height?: number;
  34870. sideOrientation?: number;
  34871. frontUVs?: Vector4;
  34872. backUVs?: Vector4;
  34873. updatable?: boolean;
  34874. sourcePlane?: Plane;
  34875. }, scene?: Nullable<Scene>): Mesh;
  34876. }
  34877. }
  34878. declare module BABYLON {
  34879. /**
  34880. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  34881. */
  34882. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  34883. private static _AnyMouseID;
  34884. private _attachedNode;
  34885. private _dragPlane;
  34886. private _scene;
  34887. private _pointerObserver;
  34888. private _beforeRenderObserver;
  34889. private static _planeScene;
  34890. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  34891. /**
  34892. * 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)
  34893. */
  34894. maxDragAngle: number;
  34895. /**
  34896. * @hidden
  34897. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  34898. /**
  34899. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34900. */
  34901. currentDraggingPointerID: number;
  34902. /**
  34903. * The last position where the pointer hit the drag plane in world space
  34904. */
  34905. lastDragPosition: Vector3;
  34906. /**
  34907. * If the behavior is currently in a dragging state
  34908. */
  34909. dragging: boolean;
  34910. /**
  34911. * 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)
  34912. */
  34913. dragDeltaRatio: number;
  34914. /**
  34915. * If the drag plane orientation should be updated during the dragging (Default: true)
  34916. */
  34917. updateDragPlane: boolean;
  34918. private _debugMode;
  34919. private _moving;
  34920. /**
  34921. * Fires each time the attached mesh is dragged with the pointer
  34922. * * delta between last drag position and current drag position in world space
  34923. * * dragDistance along the drag axis
  34924. * * dragPlaneNormal normal of the current drag plane used during the drag
  34925. * * dragPlanePoint in world space where the drag intersects the drag plane
  34926. */
  34927. onDragObservable: Observable<{
  34928. delta: Vector3;
  34929. dragPlanePoint: Vector3;
  34930. dragPlaneNormal: Vector3;
  34931. dragDistance: number;
  34932. pointerId: number;
  34933. }>;
  34934. /**
  34935. * Fires each time a drag begins (eg. mouse down on mesh)
  34936. */
  34937. onDragStartObservable: Observable<{
  34938. dragPlanePoint: Vector3;
  34939. pointerId: number;
  34940. }>;
  34941. /**
  34942. * Fires each time a drag ends (eg. mouse release after drag)
  34943. */
  34944. onDragEndObservable: Observable<{
  34945. dragPlanePoint: Vector3;
  34946. pointerId: number;
  34947. }>;
  34948. /**
  34949. * If the attached mesh should be moved when dragged
  34950. */
  34951. moveAttached: boolean;
  34952. /**
  34953. * If the drag behavior will react to drag events (Default: true)
  34954. */
  34955. enabled: boolean;
  34956. /**
  34957. * If camera controls should be detached during the drag
  34958. */
  34959. detachCameraControls: boolean;
  34960. /**
  34961. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34962. */
  34963. useObjectOrienationForDragging: boolean;
  34964. private _options;
  34965. /**
  34966. * Creates a pointer drag behavior that can be attached to a mesh
  34967. * @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)
  34968. */
  34969. constructor(options?: {
  34970. dragAxis?: Vector3;
  34971. dragPlaneNormal?: Vector3;
  34972. });
  34973. /**
  34974. * Predicate to determine if it is valid to move the object to a new position when it is moved
  34975. */
  34976. validateDrag: (targetPosition: Vector3) => boolean;
  34977. /**
  34978. * The name of the behavior
  34979. */
  34980. readonly name: string;
  34981. /**
  34982. * Initializes the behavior
  34983. */
  34984. init(): void;
  34985. private _tmpVector;
  34986. private _alternatePickedPoint;
  34987. private _worldDragAxis;
  34988. private _targetPosition;
  34989. private _attachedElement;
  34990. /**
  34991. * Attaches the drag behavior the passed in mesh
  34992. * @param ownerNode The mesh that will be dragged around once attached
  34993. */
  34994. attach(ownerNode: AbstractMesh): void;
  34995. /**
  34996. * Force relase the drag action by code.
  34997. */
  34998. releaseDrag(): void;
  34999. private _startDragRay;
  35000. private _lastPointerRay;
  35001. /**
  35002. * Simulates the start of a pointer drag event on the behavior
  35003. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35004. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35005. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35006. */
  35007. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35008. private _startDrag;
  35009. private _dragDelta;
  35010. private _moveDrag;
  35011. private _pickWithRayOnDragPlane;
  35012. private _pointA;
  35013. private _pointB;
  35014. private _pointC;
  35015. private _lineA;
  35016. private _lineB;
  35017. private _localAxis;
  35018. private _lookAt;
  35019. private _updateDragPlanePosition;
  35020. /**
  35021. * Detaches the behavior from the mesh
  35022. */
  35023. detach(): void;
  35024. }
  35025. }
  35026. declare module BABYLON {
  35027. /**
  35028. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35029. */
  35030. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35031. private _dragBehaviorA;
  35032. private _dragBehaviorB;
  35033. private _startDistance;
  35034. private _initialScale;
  35035. private _targetScale;
  35036. private _ownerNode;
  35037. private _sceneRenderObserver;
  35038. /**
  35039. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35040. */
  35041. constructor();
  35042. /**
  35043. * The name of the behavior
  35044. */
  35045. readonly name: string;
  35046. /**
  35047. * Initializes the behavior
  35048. */
  35049. init(): void;
  35050. private _getCurrentDistance;
  35051. /**
  35052. * Attaches the scale behavior the passed in mesh
  35053. * @param ownerNode The mesh that will be scaled around once attached
  35054. */
  35055. attach(ownerNode: Mesh): void;
  35056. /**
  35057. * Detaches the behavior from the mesh
  35058. */
  35059. detach(): void;
  35060. }
  35061. }
  35062. declare module BABYLON {
  35063. /**
  35064. * 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
  35065. */
  35066. export class SixDofDragBehavior implements Behavior<Mesh> {
  35067. private static _virtualScene;
  35068. private _ownerNode;
  35069. private _sceneRenderObserver;
  35070. private _scene;
  35071. private _targetPosition;
  35072. private _virtualOriginMesh;
  35073. private _virtualDragMesh;
  35074. private _pointerObserver;
  35075. private _moving;
  35076. private _startingOrientation;
  35077. /**
  35078. * 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)
  35079. */
  35080. private zDragFactor;
  35081. /**
  35082. * If the object should rotate to face the drag origin
  35083. */
  35084. rotateDraggedObject: boolean;
  35085. /**
  35086. * If the behavior is currently in a dragging state
  35087. */
  35088. dragging: boolean;
  35089. /**
  35090. * 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)
  35091. */
  35092. dragDeltaRatio: number;
  35093. /**
  35094. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35095. */
  35096. currentDraggingPointerID: number;
  35097. /**
  35098. * If camera controls should be detached during the drag
  35099. */
  35100. detachCameraControls: boolean;
  35101. /**
  35102. * Fires each time a drag starts
  35103. */
  35104. onDragStartObservable: Observable<{}>;
  35105. /**
  35106. * Fires each time a drag ends (eg. mouse release after drag)
  35107. */
  35108. onDragEndObservable: Observable<{}>;
  35109. /**
  35110. * 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
  35111. */
  35112. constructor();
  35113. /**
  35114. * The name of the behavior
  35115. */
  35116. readonly name: string;
  35117. /**
  35118. * Initializes the behavior
  35119. */
  35120. init(): void;
  35121. /**
  35122. * Attaches the scale behavior the passed in mesh
  35123. * @param ownerNode The mesh that will be scaled around once attached
  35124. */
  35125. attach(ownerNode: Mesh): void;
  35126. /**
  35127. * Detaches the behavior from the mesh
  35128. */
  35129. detach(): void;
  35130. }
  35131. }
  35132. declare module BABYLON {
  35133. /**
  35134. * Class used to apply inverse kinematics to bones
  35135. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35136. */
  35137. export class BoneIKController {
  35138. private static _tmpVecs;
  35139. private static _tmpQuat;
  35140. private static _tmpMats;
  35141. /**
  35142. * Gets or sets the target mesh
  35143. */
  35144. targetMesh: AbstractMesh;
  35145. /** Gets or sets the mesh used as pole */
  35146. poleTargetMesh: AbstractMesh;
  35147. /**
  35148. * Gets or sets the bone used as pole
  35149. */
  35150. poleTargetBone: Nullable<Bone>;
  35151. /**
  35152. * Gets or sets the target position
  35153. */
  35154. targetPosition: Vector3;
  35155. /**
  35156. * Gets or sets the pole target position
  35157. */
  35158. poleTargetPosition: Vector3;
  35159. /**
  35160. * Gets or sets the pole target local offset
  35161. */
  35162. poleTargetLocalOffset: Vector3;
  35163. /**
  35164. * Gets or sets the pole angle
  35165. */
  35166. poleAngle: number;
  35167. /**
  35168. * Gets or sets the mesh associated with the controller
  35169. */
  35170. mesh: AbstractMesh;
  35171. /**
  35172. * 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)
  35173. */
  35174. slerpAmount: number;
  35175. private _bone1Quat;
  35176. private _bone1Mat;
  35177. private _bone2Ang;
  35178. private _bone1;
  35179. private _bone2;
  35180. private _bone1Length;
  35181. private _bone2Length;
  35182. private _maxAngle;
  35183. private _maxReach;
  35184. private _rightHandedSystem;
  35185. private _bendAxis;
  35186. private _slerping;
  35187. private _adjustRoll;
  35188. /**
  35189. * Gets or sets maximum allowed angle
  35190. */
  35191. maxAngle: number;
  35192. /**
  35193. * Creates a new BoneIKController
  35194. * @param mesh defines the mesh to control
  35195. * @param bone defines the bone to control
  35196. * @param options defines options to set up the controller
  35197. */
  35198. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35199. targetMesh?: AbstractMesh;
  35200. poleTargetMesh?: AbstractMesh;
  35201. poleTargetBone?: Bone;
  35202. poleTargetLocalOffset?: Vector3;
  35203. poleAngle?: number;
  35204. bendAxis?: Vector3;
  35205. maxAngle?: number;
  35206. slerpAmount?: number;
  35207. });
  35208. private _setMaxAngle;
  35209. /**
  35210. * Force the controller to update the bones
  35211. */
  35212. update(): void;
  35213. }
  35214. }
  35215. declare module BABYLON {
  35216. /**
  35217. * Class used to make a bone look toward a point in space
  35218. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35219. */
  35220. export class BoneLookController {
  35221. private static _tmpVecs;
  35222. private static _tmpQuat;
  35223. private static _tmpMats;
  35224. /**
  35225. * The target Vector3 that the bone will look at
  35226. */
  35227. target: Vector3;
  35228. /**
  35229. * The mesh that the bone is attached to
  35230. */
  35231. mesh: AbstractMesh;
  35232. /**
  35233. * The bone that will be looking to the target
  35234. */
  35235. bone: Bone;
  35236. /**
  35237. * The up axis of the coordinate system that is used when the bone is rotated
  35238. */
  35239. upAxis: Vector3;
  35240. /**
  35241. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35242. */
  35243. upAxisSpace: Space;
  35244. /**
  35245. * Used to make an adjustment to the yaw of the bone
  35246. */
  35247. adjustYaw: number;
  35248. /**
  35249. * Used to make an adjustment to the pitch of the bone
  35250. */
  35251. adjustPitch: number;
  35252. /**
  35253. * Used to make an adjustment to the roll of the bone
  35254. */
  35255. adjustRoll: number;
  35256. /**
  35257. * 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)
  35258. */
  35259. slerpAmount: number;
  35260. private _minYaw;
  35261. private _maxYaw;
  35262. private _minPitch;
  35263. private _maxPitch;
  35264. private _minYawSin;
  35265. private _minYawCos;
  35266. private _maxYawSin;
  35267. private _maxYawCos;
  35268. private _midYawConstraint;
  35269. private _minPitchTan;
  35270. private _maxPitchTan;
  35271. private _boneQuat;
  35272. private _slerping;
  35273. private _transformYawPitch;
  35274. private _transformYawPitchInv;
  35275. private _firstFrameSkipped;
  35276. private _yawRange;
  35277. private _fowardAxis;
  35278. /**
  35279. * Gets or sets the minimum yaw angle that the bone can look to
  35280. */
  35281. minYaw: number;
  35282. /**
  35283. * Gets or sets the maximum yaw angle that the bone can look to
  35284. */
  35285. maxYaw: number;
  35286. /**
  35287. * Gets or sets the minimum pitch angle that the bone can look to
  35288. */
  35289. minPitch: number;
  35290. /**
  35291. * Gets or sets the maximum pitch angle that the bone can look to
  35292. */
  35293. maxPitch: number;
  35294. /**
  35295. * Create a BoneLookController
  35296. * @param mesh the mesh that the bone belongs to
  35297. * @param bone the bone that will be looking to the target
  35298. * @param target the target Vector3 to look at
  35299. * @param options optional settings:
  35300. * * maxYaw: the maximum angle the bone will yaw to
  35301. * * minYaw: the minimum angle the bone will yaw to
  35302. * * maxPitch: the maximum angle the bone will pitch to
  35303. * * minPitch: the minimum angle the bone will yaw to
  35304. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35305. * * upAxis: the up axis of the coordinate system
  35306. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35307. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35308. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35309. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35310. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35311. * * adjustRoll: used to make an adjustment to the roll of the bone
  35312. **/
  35313. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35314. maxYaw?: number;
  35315. minYaw?: number;
  35316. maxPitch?: number;
  35317. minPitch?: number;
  35318. slerpAmount?: number;
  35319. upAxis?: Vector3;
  35320. upAxisSpace?: Space;
  35321. yawAxis?: Vector3;
  35322. pitchAxis?: Vector3;
  35323. adjustYaw?: number;
  35324. adjustPitch?: number;
  35325. adjustRoll?: number;
  35326. });
  35327. /**
  35328. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35329. */
  35330. update(): void;
  35331. private _getAngleDiff;
  35332. private _getAngleBetween;
  35333. private _isAngleBetween;
  35334. }
  35335. }
  35336. declare module BABYLON {
  35337. /**
  35338. * Manage the gamepad inputs to control an arc rotate camera.
  35339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35340. */
  35341. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35342. /**
  35343. * Defines the camera the input is attached to.
  35344. */
  35345. camera: ArcRotateCamera;
  35346. /**
  35347. * Defines the gamepad the input is gathering event from.
  35348. */
  35349. gamepad: Nullable<Gamepad>;
  35350. /**
  35351. * Defines the gamepad rotation sensiblity.
  35352. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35353. */
  35354. gamepadRotationSensibility: number;
  35355. /**
  35356. * Defines the gamepad move sensiblity.
  35357. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35358. */
  35359. gamepadMoveSensibility: number;
  35360. private _onGamepadConnectedObserver;
  35361. private _onGamepadDisconnectedObserver;
  35362. /**
  35363. * Attach the input controls to a specific dom element to get the input from.
  35364. * @param element Defines the element the controls should be listened from
  35365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35366. */
  35367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35368. /**
  35369. * Detach the current controls from the specified dom element.
  35370. * @param element Defines the element to stop listening the inputs from
  35371. */
  35372. detachControl(element: Nullable<HTMLElement>): void;
  35373. /**
  35374. * Update the current camera state depending on the inputs that have been used this frame.
  35375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35376. */
  35377. checkInputs(): void;
  35378. /**
  35379. * Gets the class name of the current intput.
  35380. * @returns the class name
  35381. */
  35382. getClassName(): string;
  35383. /**
  35384. * Get the friendly name associated with the input class.
  35385. * @returns the input friendly name
  35386. */
  35387. getSimpleName(): string;
  35388. }
  35389. }
  35390. declare module BABYLON {
  35391. interface ArcRotateCameraInputsManager {
  35392. /**
  35393. * Add orientation input support to the input manager.
  35394. * @returns the current input manager
  35395. */
  35396. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35397. }
  35398. /**
  35399. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35401. */
  35402. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35403. /**
  35404. * Defines the camera the input is attached to.
  35405. */
  35406. camera: ArcRotateCamera;
  35407. /**
  35408. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35409. */
  35410. alphaCorrection: number;
  35411. /**
  35412. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35413. */
  35414. gammaCorrection: number;
  35415. private _alpha;
  35416. private _gamma;
  35417. private _dirty;
  35418. private _deviceOrientationHandler;
  35419. /**
  35420. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35421. */
  35422. constructor();
  35423. /**
  35424. * Attach the input controls to a specific dom element to get the input from.
  35425. * @param element Defines the element the controls should be listened from
  35426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35427. */
  35428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35429. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  35430. /**
  35431. * Update the current camera state depending on the inputs that have been used this frame.
  35432. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35433. */
  35434. checkInputs(): void;
  35435. /**
  35436. * Detach the current controls from the specified dom element.
  35437. * @param element Defines the element to stop listening the inputs from
  35438. */
  35439. detachControl(element: Nullable<HTMLElement>): void;
  35440. /**
  35441. * Gets the class name of the current intput.
  35442. * @returns the class name
  35443. */
  35444. getClassName(): string;
  35445. /**
  35446. * Get the friendly name associated with the input class.
  35447. * @returns the input friendly name
  35448. */
  35449. getSimpleName(): string;
  35450. }
  35451. }
  35452. declare module BABYLON {
  35453. /**
  35454. * Listen to mouse events to control the camera.
  35455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35456. */
  35457. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35458. /**
  35459. * Defines the camera the input is attached to.
  35460. */
  35461. camera: FlyCamera;
  35462. /**
  35463. * Defines if touch is enabled. (Default is true.)
  35464. */
  35465. touchEnabled: boolean;
  35466. /**
  35467. * Defines the buttons associated with the input to handle camera rotation.
  35468. */
  35469. buttons: number[];
  35470. /**
  35471. * Assign buttons for Yaw control.
  35472. */
  35473. buttonsYaw: number[];
  35474. /**
  35475. * Assign buttons for Pitch control.
  35476. */
  35477. buttonsPitch: number[];
  35478. /**
  35479. * Assign buttons for Roll control.
  35480. */
  35481. buttonsRoll: number[];
  35482. /**
  35483. * Detect if any button is being pressed while mouse is moved.
  35484. * -1 = Mouse locked.
  35485. * 0 = Left button.
  35486. * 1 = Middle Button.
  35487. * 2 = Right Button.
  35488. */
  35489. activeButton: number;
  35490. /**
  35491. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35492. * Higher values reduce its sensitivity.
  35493. */
  35494. angularSensibility: number;
  35495. private _mousemoveCallback;
  35496. private _observer;
  35497. private _rollObserver;
  35498. private previousPosition;
  35499. private noPreventDefault;
  35500. private element;
  35501. /**
  35502. * Listen to mouse events to control the camera.
  35503. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35504. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35505. */
  35506. constructor(touchEnabled?: boolean);
  35507. /**
  35508. * Attach the mouse control to the HTML DOM element.
  35509. * @param element Defines the element that listens to the input events.
  35510. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35511. */
  35512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35513. /**
  35514. * Detach the current controls from the specified dom element.
  35515. * @param element Defines the element to stop listening the inputs from
  35516. */
  35517. detachControl(element: Nullable<HTMLElement>): void;
  35518. /**
  35519. * Gets the class name of the current input.
  35520. * @returns the class name.
  35521. */
  35522. getClassName(): string;
  35523. /**
  35524. * Get the friendly name associated with the input class.
  35525. * @returns the input's friendly name.
  35526. */
  35527. getSimpleName(): string;
  35528. private _pointerInput;
  35529. private _onMouseMove;
  35530. /**
  35531. * Rotate camera by mouse offset.
  35532. */
  35533. private rotateCamera;
  35534. }
  35535. }
  35536. declare module BABYLON {
  35537. /**
  35538. * Default Inputs manager for the FlyCamera.
  35539. * It groups all the default supported inputs for ease of use.
  35540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35541. */
  35542. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35543. /**
  35544. * Instantiates a new FlyCameraInputsManager.
  35545. * @param camera Defines the camera the inputs belong to.
  35546. */
  35547. constructor(camera: FlyCamera);
  35548. /**
  35549. * Add keyboard input support to the input manager.
  35550. * @returns the new FlyCameraKeyboardMoveInput().
  35551. */
  35552. addKeyboard(): FlyCameraInputsManager;
  35553. /**
  35554. * Add mouse input support to the input manager.
  35555. * @param touchEnabled Enable touch screen support.
  35556. * @returns the new FlyCameraMouseInput().
  35557. */
  35558. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35559. }
  35560. }
  35561. declare module BABYLON {
  35562. /**
  35563. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35564. * such as in a 3D Space Shooter or a Flight Simulator.
  35565. */
  35566. export class FlyCamera extends TargetCamera {
  35567. /**
  35568. * Define the collision ellipsoid of the camera.
  35569. * This is helpful for simulating a camera body, like a player's body.
  35570. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35571. */
  35572. ellipsoid: Vector3;
  35573. /**
  35574. * Define an offset for the position of the ellipsoid around the camera.
  35575. * This can be helpful if the camera is attached away from the player's body center,
  35576. * such as at its head.
  35577. */
  35578. ellipsoidOffset: Vector3;
  35579. /**
  35580. * Enable or disable collisions of the camera with the rest of the scene objects.
  35581. */
  35582. checkCollisions: boolean;
  35583. /**
  35584. * Enable or disable gravity on the camera.
  35585. */
  35586. applyGravity: boolean;
  35587. /**
  35588. * Define the current direction the camera is moving to.
  35589. */
  35590. cameraDirection: Vector3;
  35591. /**
  35592. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35593. * This overrides and empties cameraRotation.
  35594. */
  35595. rotationQuaternion: Quaternion;
  35596. /**
  35597. * Track Roll to maintain the wanted Rolling when looking around.
  35598. */ trackRoll: number;
  35599. /**
  35600. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35601. */
  35602. rollCorrect: number;
  35603. /**
  35604. * Mimic a banked turn, Rolling the camera when Yawing.
  35605. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35606. */
  35607. bankedTurn: boolean;
  35608. /**
  35609. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35610. */
  35611. bankedTurnLimit: number;
  35612. /**
  35613. * Value of 0 disables the banked Roll.
  35614. * Value of 1 is equal to the Yaw angle in radians.
  35615. */
  35616. bankedTurnMultiplier: number;
  35617. /**
  35618. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35619. */
  35620. inputs: FlyCameraInputsManager;
  35621. /**
  35622. * Gets the input sensibility for mouse input.
  35623. * Higher values reduce sensitivity.
  35624. */
  35625. /**
  35626. * Sets the input sensibility for a mouse input.
  35627. * Higher values reduce sensitivity.
  35628. */
  35629. angularSensibility: number;
  35630. /**
  35631. * Get the keys for camera movement forward.
  35632. */
  35633. /**
  35634. * Set the keys for camera movement forward.
  35635. */
  35636. keysForward: number[];
  35637. /**
  35638. * Get the keys for camera movement backward.
  35639. */
  35640. keysBackward: number[];
  35641. /**
  35642. * Get the keys for camera movement up.
  35643. */
  35644. /**
  35645. * Set the keys for camera movement up.
  35646. */
  35647. keysUp: number[];
  35648. /**
  35649. * Get the keys for camera movement down.
  35650. */
  35651. /**
  35652. * Set the keys for camera movement down.
  35653. */
  35654. keysDown: number[];
  35655. /**
  35656. * Get the keys for camera movement left.
  35657. */
  35658. /**
  35659. * Set the keys for camera movement left.
  35660. */
  35661. keysLeft: number[];
  35662. /**
  35663. * Set the keys for camera movement right.
  35664. */
  35665. /**
  35666. * Set the keys for camera movement right.
  35667. */
  35668. keysRight: number[];
  35669. /**
  35670. * Event raised when the camera collides with a mesh in the scene.
  35671. */
  35672. onCollide: (collidedMesh: AbstractMesh) => void;
  35673. private _collider;
  35674. private _needMoveForGravity;
  35675. private _oldPosition;
  35676. private _diffPosition;
  35677. private _newPosition;
  35678. /** @hidden */ localDirection: Vector3;
  35679. /** @hidden */ transformedDirection: Vector3;
  35680. /**
  35681. * Instantiates a FlyCamera.
  35682. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35683. * such as in a 3D Space Shooter or a Flight Simulator.
  35684. * @param name Define the name of the camera in the scene.
  35685. * @param position Define the starting position of the camera in the scene.
  35686. * @param scene Define the scene the camera belongs to.
  35687. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35688. */
  35689. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35690. /**
  35691. * Attach a control to the HTML DOM element.
  35692. * @param element Defines the element that listens to the input events.
  35693. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35694. */
  35695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35696. /**
  35697. * Detach a control from the HTML DOM element.
  35698. * The camera will stop reacting to that input.
  35699. * @param element Defines the element that listens to the input events.
  35700. */
  35701. detachControl(element: HTMLElement): void;
  35702. private _collisionMask;
  35703. /**
  35704. * Get the mask that the camera ignores in collision events.
  35705. */
  35706. /**
  35707. * Set the mask that the camera ignores in collision events.
  35708. */
  35709. collisionMask: number;
  35710. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  35711. /** @hidden */
  35712. private _onCollisionPositionChange;
  35713. /** @hidden */ checkInputs(): void;
  35714. /** @hidden */ decideIfNeedsToMove(): boolean;
  35715. /** @hidden */ updatePosition(): void;
  35716. /**
  35717. * Restore the Roll to its target value at the rate specified.
  35718. * @param rate - Higher means slower restoring.
  35719. * @hidden
  35720. */
  35721. restoreRoll(rate: number): void;
  35722. /**
  35723. * Destroy the camera and release the current resources held by it.
  35724. */
  35725. dispose(): void;
  35726. /**
  35727. * Get the current object class name.
  35728. * @returns the class name.
  35729. */
  35730. getClassName(): string;
  35731. }
  35732. }
  35733. declare module BABYLON {
  35734. /**
  35735. * Listen to keyboard events to control the camera.
  35736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35737. */
  35738. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35739. /**
  35740. * Defines the camera the input is attached to.
  35741. */
  35742. camera: FlyCamera;
  35743. /**
  35744. * The list of keyboard keys used to control the forward move of the camera.
  35745. */
  35746. keysForward: number[];
  35747. /**
  35748. * The list of keyboard keys used to control the backward move of the camera.
  35749. */
  35750. keysBackward: number[];
  35751. /**
  35752. * The list of keyboard keys used to control the forward move of the camera.
  35753. */
  35754. keysUp: number[];
  35755. /**
  35756. * The list of keyboard keys used to control the backward move of the camera.
  35757. */
  35758. keysDown: number[];
  35759. /**
  35760. * The list of keyboard keys used to control the right strafe move of the camera.
  35761. */
  35762. keysRight: number[];
  35763. /**
  35764. * The list of keyboard keys used to control the left strafe move of the camera.
  35765. */
  35766. keysLeft: number[];
  35767. private _keys;
  35768. private _onCanvasBlurObserver;
  35769. private _onKeyboardObserver;
  35770. private _engine;
  35771. private _scene;
  35772. /**
  35773. * Attach the input controls to a specific dom element to get the input from.
  35774. * @param element Defines the element the controls should be listened from
  35775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35776. */
  35777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35778. /**
  35779. * Detach the current controls from the specified dom element.
  35780. * @param element Defines the element to stop listening the inputs from
  35781. */
  35782. detachControl(element: Nullable<HTMLElement>): void;
  35783. /**
  35784. * Gets the class name of the current intput.
  35785. * @returns the class name
  35786. */
  35787. getClassName(): string;
  35788. /** @hidden */ onLostFocus(e: FocusEvent): void;
  35789. /**
  35790. * Get the friendly name associated with the input class.
  35791. * @returns the input friendly name
  35792. */
  35793. getSimpleName(): string;
  35794. /**
  35795. * Update the current camera state depending on the inputs that have been used this frame.
  35796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35797. */
  35798. checkInputs(): void;
  35799. }
  35800. }
  35801. declare module BABYLON {
  35802. /**
  35803. * Manage the mouse wheel inputs to control a follow camera.
  35804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35805. */
  35806. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35807. /**
  35808. * Defines the camera the input is attached to.
  35809. */
  35810. camera: FollowCamera;
  35811. /**
  35812. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  35813. */
  35814. axisControlRadius: boolean;
  35815. /**
  35816. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  35817. */
  35818. axisControlHeight: boolean;
  35819. /**
  35820. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  35821. */
  35822. axisControlRotation: boolean;
  35823. /**
  35824. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35825. * relation to mouseWheel events.
  35826. */
  35827. wheelPrecision: number;
  35828. /**
  35829. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35830. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35831. */
  35832. wheelDeltaPercentage: number;
  35833. private _wheel;
  35834. private _observer;
  35835. /**
  35836. * Attach the input controls to a specific dom element to get the input from.
  35837. * @param element Defines the element the controls should be listened from
  35838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35839. */
  35840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35841. /**
  35842. * Detach the current controls from the specified dom element.
  35843. * @param element Defines the element to stop listening the inputs from
  35844. */
  35845. detachControl(element: Nullable<HTMLElement>): void;
  35846. /**
  35847. * Gets the class name of the current intput.
  35848. * @returns the class name
  35849. */
  35850. getClassName(): string;
  35851. /**
  35852. * Get the friendly name associated with the input class.
  35853. * @returns the input friendly name
  35854. */
  35855. getSimpleName(): string;
  35856. }
  35857. }
  35858. declare module BABYLON {
  35859. /**
  35860. * Manage the pointers inputs to control an follow camera.
  35861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35862. */
  35863. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  35864. /**
  35865. * Defines the camera the input is attached to.
  35866. */
  35867. camera: FollowCamera;
  35868. /**
  35869. * Gets the class name of the current input.
  35870. * @returns the class name
  35871. */
  35872. getClassName(): string;
  35873. /**
  35874. * Defines the pointer angular sensibility along the X axis or how fast is
  35875. * the camera rotating.
  35876. * A negative number will reverse the axis direction.
  35877. */
  35878. angularSensibilityX: number;
  35879. /**
  35880. * Defines the pointer angular sensibility along the Y axis or how fast is
  35881. * the camera rotating.
  35882. * A negative number will reverse the axis direction.
  35883. */
  35884. angularSensibilityY: number;
  35885. /**
  35886. * Defines the pointer pinch precision or how fast is the camera zooming.
  35887. * A negative number will reverse the axis direction.
  35888. */
  35889. pinchPrecision: number;
  35890. /**
  35891. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35892. * from 0.
  35893. * It defines the percentage of current camera.radius to use as delta when
  35894. * pinch zoom is used.
  35895. */
  35896. pinchDeltaPercentage: number;
  35897. /**
  35898. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  35899. */
  35900. axisXControlRadius: boolean;
  35901. /**
  35902. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  35903. */
  35904. axisXControlHeight: boolean;
  35905. /**
  35906. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  35907. */
  35908. axisXControlRotation: boolean;
  35909. /**
  35910. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  35911. */
  35912. axisYControlRadius: boolean;
  35913. /**
  35914. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  35915. */
  35916. axisYControlHeight: boolean;
  35917. /**
  35918. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  35919. */
  35920. axisYControlRotation: boolean;
  35921. /**
  35922. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  35923. */
  35924. axisPinchControlRadius: boolean;
  35925. /**
  35926. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  35927. */
  35928. axisPinchControlHeight: boolean;
  35929. /**
  35930. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  35931. */
  35932. axisPinchControlRotation: boolean;
  35933. /**
  35934. * Log error messages if basic misconfiguration has occurred.
  35935. */
  35936. warningEnable: boolean;
  35937. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35938. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35939. private _warningCounter;
  35940. private _warning;
  35941. }
  35942. }
  35943. declare module BABYLON {
  35944. /**
  35945. * Default Inputs manager for the FollowCamera.
  35946. * It groups all the default supported inputs for ease of use.
  35947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35948. */
  35949. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  35950. /**
  35951. * Instantiates a new FollowCameraInputsManager.
  35952. * @param camera Defines the camera the inputs belong to
  35953. */
  35954. constructor(camera: FollowCamera);
  35955. /**
  35956. * Add keyboard input support to the input manager.
  35957. * @returns the current input manager
  35958. */
  35959. addKeyboard(): FollowCameraInputsManager;
  35960. /**
  35961. * Add mouse wheel input support to the input manager.
  35962. * @returns the current input manager
  35963. */
  35964. addMouseWheel(): FollowCameraInputsManager;
  35965. /**
  35966. * Add pointers input support to the input manager.
  35967. * @returns the current input manager
  35968. */
  35969. addPointers(): FollowCameraInputsManager;
  35970. /**
  35971. * Add orientation input support to the input manager.
  35972. * @returns the current input manager
  35973. */
  35974. addVRDeviceOrientation(): FollowCameraInputsManager;
  35975. }
  35976. }
  35977. declare module BABYLON {
  35978. /**
  35979. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  35980. * an arc rotate version arcFollowCamera are available.
  35981. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35982. */
  35983. export class FollowCamera extends TargetCamera {
  35984. /**
  35985. * Distance the follow camera should follow an object at
  35986. */
  35987. radius: number;
  35988. /**
  35989. * Minimum allowed distance of the camera to the axis of rotation
  35990. * (The camera can not get closer).
  35991. * This can help limiting how the Camera is able to move in the scene.
  35992. */
  35993. lowerRadiusLimit: Nullable<number>;
  35994. /**
  35995. * Maximum allowed distance of the camera to the axis of rotation
  35996. * (The camera can not get further).
  35997. * This can help limiting how the Camera is able to move in the scene.
  35998. */
  35999. upperRadiusLimit: Nullable<number>;
  36000. /**
  36001. * Define a rotation offset between the camera and the object it follows
  36002. */
  36003. rotationOffset: number;
  36004. /**
  36005. * Minimum allowed angle to camera position relative to target object.
  36006. * This can help limiting how the Camera is able to move in the scene.
  36007. */
  36008. lowerRotationOffsetLimit: Nullable<number>;
  36009. /**
  36010. * Maximum allowed angle to camera position relative to target object.
  36011. * This can help limiting how the Camera is able to move in the scene.
  36012. */
  36013. upperRotationOffsetLimit: Nullable<number>;
  36014. /**
  36015. * Define a height offset between the camera and the object it follows.
  36016. * It can help following an object from the top (like a car chaing a plane)
  36017. */
  36018. heightOffset: number;
  36019. /**
  36020. * Minimum allowed height of camera position relative to target object.
  36021. * This can help limiting how the Camera is able to move in the scene.
  36022. */
  36023. lowerHeightOffsetLimit: Nullable<number>;
  36024. /**
  36025. * Maximum allowed height of camera position relative to target object.
  36026. * This can help limiting how the Camera is able to move in the scene.
  36027. */
  36028. upperHeightOffsetLimit: Nullable<number>;
  36029. /**
  36030. * Define how fast the camera can accelerate to follow it s target.
  36031. */
  36032. cameraAcceleration: number;
  36033. /**
  36034. * Define the speed limit of the camera following an object.
  36035. */
  36036. maxCameraSpeed: number;
  36037. /**
  36038. * Define the target of the camera.
  36039. */
  36040. lockedTarget: Nullable<AbstractMesh>;
  36041. /**
  36042. * Defines the input associated with the camera.
  36043. */
  36044. inputs: FollowCameraInputsManager;
  36045. /**
  36046. * Instantiates the follow camera.
  36047. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36048. * @param name Define the name of the camera in the scene
  36049. * @param position Define the position of the camera
  36050. * @param scene Define the scene the camera belong to
  36051. * @param lockedTarget Define the target of the camera
  36052. */
  36053. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36054. private _follow;
  36055. /**
  36056. * Attached controls to the current camera.
  36057. * @param element Defines the element the controls should be listened from
  36058. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36059. */
  36060. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36061. /**
  36062. * Detach the current controls from the camera.
  36063. * The camera will stop reacting to inputs.
  36064. * @param element Defines the element to stop listening the inputs from
  36065. */
  36066. detachControl(element: HTMLElement): void;
  36067. /** @hidden */ checkInputs(): void;
  36068. private _checkLimits;
  36069. /**
  36070. * Gets the camera class name.
  36071. * @returns the class name
  36072. */
  36073. getClassName(): string;
  36074. }
  36075. /**
  36076. * Arc Rotate version of the follow camera.
  36077. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36078. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36079. */
  36080. export class ArcFollowCamera extends TargetCamera {
  36081. /** The longitudinal angle of the camera */
  36082. alpha: number;
  36083. /** The latitudinal angle of the camera */
  36084. beta: number;
  36085. /** The radius of the camera from its target */
  36086. radius: number;
  36087. /** Define the camera target (the messh it should follow) */
  36088. target: Nullable<AbstractMesh>;
  36089. private _cartesianCoordinates;
  36090. /**
  36091. * Instantiates a new ArcFollowCamera
  36092. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36093. * @param name Define the name of the camera
  36094. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36095. * @param beta Define the rotation angle of the camera around the elevation axis
  36096. * @param radius Define the radius of the camera from its target point
  36097. * @param target Define the target of the camera
  36098. * @param scene Define the scene the camera belongs to
  36099. */
  36100. constructor(name: string,
  36101. /** The longitudinal angle of the camera */
  36102. alpha: number,
  36103. /** The latitudinal angle of the camera */
  36104. beta: number,
  36105. /** The radius of the camera from its target */
  36106. radius: number,
  36107. /** Define the camera target (the messh it should follow) */
  36108. target: Nullable<AbstractMesh>, scene: Scene);
  36109. private _follow;
  36110. /** @hidden */ checkInputs(): void;
  36111. /**
  36112. * Returns the class name of the object.
  36113. * It is mostly used internally for serialization purposes.
  36114. */
  36115. getClassName(): string;
  36116. }
  36117. }
  36118. declare module BABYLON {
  36119. /**
  36120. * Manage the keyboard inputs to control the movement of a follow camera.
  36121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36122. */
  36123. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36124. /**
  36125. * Defines the camera the input is attached to.
  36126. */
  36127. camera: FollowCamera;
  36128. /**
  36129. * Defines the list of key codes associated with the up action (increase heightOffset)
  36130. */
  36131. keysHeightOffsetIncr: number[];
  36132. /**
  36133. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36134. */
  36135. keysHeightOffsetDecr: number[];
  36136. /**
  36137. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36138. */
  36139. keysHeightOffsetModifierAlt: boolean;
  36140. /**
  36141. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36142. */
  36143. keysHeightOffsetModifierCtrl: boolean;
  36144. /**
  36145. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36146. */
  36147. keysHeightOffsetModifierShift: boolean;
  36148. /**
  36149. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36150. */
  36151. keysRotationOffsetIncr: number[];
  36152. /**
  36153. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36154. */
  36155. keysRotationOffsetDecr: number[];
  36156. /**
  36157. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36158. */
  36159. keysRotationOffsetModifierAlt: boolean;
  36160. /**
  36161. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36162. */
  36163. keysRotationOffsetModifierCtrl: boolean;
  36164. /**
  36165. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36166. */
  36167. keysRotationOffsetModifierShift: boolean;
  36168. /**
  36169. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36170. */
  36171. keysRadiusIncr: number[];
  36172. /**
  36173. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36174. */
  36175. keysRadiusDecr: number[];
  36176. /**
  36177. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36178. */
  36179. keysRadiusModifierAlt: boolean;
  36180. /**
  36181. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36182. */
  36183. keysRadiusModifierCtrl: boolean;
  36184. /**
  36185. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36186. */
  36187. keysRadiusModifierShift: boolean;
  36188. /**
  36189. * Defines the rate of change of heightOffset.
  36190. */
  36191. heightSensibility: number;
  36192. /**
  36193. * Defines the rate of change of rotationOffset.
  36194. */
  36195. rotationSensibility: number;
  36196. /**
  36197. * Defines the rate of change of radius.
  36198. */
  36199. radiusSensibility: number;
  36200. private _keys;
  36201. private _ctrlPressed;
  36202. private _altPressed;
  36203. private _shiftPressed;
  36204. private _onCanvasBlurObserver;
  36205. private _onKeyboardObserver;
  36206. private _engine;
  36207. private _scene;
  36208. /**
  36209. * Attach the input controls to a specific dom element to get the input from.
  36210. * @param element Defines the element the controls should be listened from
  36211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36212. */
  36213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36214. /**
  36215. * Detach the current controls from the specified dom element.
  36216. * @param element Defines the element to stop listening the inputs from
  36217. */
  36218. detachControl(element: Nullable<HTMLElement>): void;
  36219. /**
  36220. * Update the current camera state depending on the inputs that have been used this frame.
  36221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36222. */
  36223. checkInputs(): void;
  36224. /**
  36225. * Gets the class name of the current input.
  36226. * @returns the class name
  36227. */
  36228. getClassName(): string;
  36229. /**
  36230. * Get the friendly name associated with the input class.
  36231. * @returns the input friendly name
  36232. */
  36233. getSimpleName(): string;
  36234. /**
  36235. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36236. * allow modification of the heightOffset value.
  36237. */
  36238. private _modifierHeightOffset;
  36239. /**
  36240. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36241. * allow modification of the rotationOffset value.
  36242. */
  36243. private _modifierRotationOffset;
  36244. /**
  36245. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36246. * allow modification of the radius value.
  36247. */
  36248. private _modifierRadius;
  36249. }
  36250. }
  36251. declare module BABYLON {
  36252. interface FreeCameraInputsManager {
  36253. /**
  36254. * @hidden
  36255. */ deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36256. /**
  36257. * Add orientation input support to the input manager.
  36258. * @returns the current input manager
  36259. */
  36260. addDeviceOrientation(): FreeCameraInputsManager;
  36261. }
  36262. /**
  36263. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36264. * Screen rotation is taken into account.
  36265. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36266. */
  36267. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36268. private _camera;
  36269. private _screenOrientationAngle;
  36270. private _constantTranform;
  36271. private _screenQuaternion;
  36272. private _alpha;
  36273. private _beta;
  36274. private _gamma;
  36275. /**
  36276. * @hidden
  36277. */ onDeviceOrientationChangedObservable: Observable<void>;
  36278. /**
  36279. * Instantiates a new input
  36280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36281. */
  36282. constructor();
  36283. /**
  36284. * Define the camera controlled by the input.
  36285. */
  36286. camera: FreeCamera;
  36287. /**
  36288. * Attach the input controls to a specific dom element to get the input from.
  36289. * @param element Defines the element the controls should be listened from
  36290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36291. */
  36292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36293. private _orientationChanged;
  36294. private _deviceOrientation;
  36295. /**
  36296. * Detach the current controls from the specified dom element.
  36297. * @param element Defines the element to stop listening the inputs from
  36298. */
  36299. detachControl(element: Nullable<HTMLElement>): void;
  36300. /**
  36301. * Update the current camera state depending on the inputs that have been used this frame.
  36302. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36303. */
  36304. checkInputs(): void;
  36305. /**
  36306. * Gets the class name of the current intput.
  36307. * @returns the class name
  36308. */
  36309. getClassName(): string;
  36310. /**
  36311. * Get the friendly name associated with the input class.
  36312. * @returns the input friendly name
  36313. */
  36314. getSimpleName(): string;
  36315. }
  36316. }
  36317. declare module BABYLON {
  36318. /**
  36319. * Manage the gamepad inputs to control a free camera.
  36320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36321. */
  36322. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36323. /**
  36324. * Define the camera the input is attached to.
  36325. */
  36326. camera: FreeCamera;
  36327. /**
  36328. * Define the Gamepad controlling the input
  36329. */
  36330. gamepad: Nullable<Gamepad>;
  36331. /**
  36332. * Defines the gamepad rotation sensiblity.
  36333. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36334. */
  36335. gamepadAngularSensibility: number;
  36336. /**
  36337. * Defines the gamepad move sensiblity.
  36338. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36339. */
  36340. gamepadMoveSensibility: number;
  36341. private _onGamepadConnectedObserver;
  36342. private _onGamepadDisconnectedObserver;
  36343. private _cameraTransform;
  36344. private _deltaTransform;
  36345. private _vector3;
  36346. private _vector2;
  36347. /**
  36348. * Attach the input controls to a specific dom element to get the input from.
  36349. * @param element Defines the element the controls should be listened from
  36350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36351. */
  36352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36353. /**
  36354. * Detach the current controls from the specified dom element.
  36355. * @param element Defines the element to stop listening the inputs from
  36356. */
  36357. detachControl(element: Nullable<HTMLElement>): void;
  36358. /**
  36359. * Update the current camera state depending on the inputs that have been used this frame.
  36360. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36361. */
  36362. checkInputs(): void;
  36363. /**
  36364. * Gets the class name of the current intput.
  36365. * @returns the class name
  36366. */
  36367. getClassName(): string;
  36368. /**
  36369. * Get the friendly name associated with the input class.
  36370. * @returns the input friendly name
  36371. */
  36372. getSimpleName(): string;
  36373. }
  36374. }
  36375. declare module BABYLON {
  36376. /**
  36377. * Defines the potential axis of a Joystick
  36378. */
  36379. export enum JoystickAxis {
  36380. /** X axis */
  36381. X = 0,
  36382. /** Y axis */
  36383. Y = 1,
  36384. /** Z axis */
  36385. Z = 2
  36386. }
  36387. /**
  36388. * Class used to define virtual joystick (used in touch mode)
  36389. */
  36390. export class VirtualJoystick {
  36391. /**
  36392. * Gets or sets a boolean indicating that left and right values must be inverted
  36393. */
  36394. reverseLeftRight: boolean;
  36395. /**
  36396. * Gets or sets a boolean indicating that up and down values must be inverted
  36397. */
  36398. reverseUpDown: boolean;
  36399. /**
  36400. * Gets the offset value for the position (ie. the change of the position value)
  36401. */
  36402. deltaPosition: Vector3;
  36403. /**
  36404. * Gets a boolean indicating if the virtual joystick was pressed
  36405. */
  36406. pressed: boolean;
  36407. /**
  36408. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36409. */
  36410. static Canvas: Nullable<HTMLCanvasElement>;
  36411. private static _globalJoystickIndex;
  36412. private static vjCanvasContext;
  36413. private static vjCanvasWidth;
  36414. private static vjCanvasHeight;
  36415. private static halfWidth;
  36416. private _action;
  36417. private _axisTargetedByLeftAndRight;
  36418. private _axisTargetedByUpAndDown;
  36419. private _joystickSensibility;
  36420. private _inversedSensibility;
  36421. private _joystickPointerID;
  36422. private _joystickColor;
  36423. private _joystickPointerPos;
  36424. private _joystickPreviousPointerPos;
  36425. private _joystickPointerStartPos;
  36426. private _deltaJoystickVector;
  36427. private _leftJoystick;
  36428. private _touches;
  36429. private _onPointerDownHandlerRef;
  36430. private _onPointerMoveHandlerRef;
  36431. private _onPointerUpHandlerRef;
  36432. private _onResize;
  36433. /**
  36434. * Creates a new virtual joystick
  36435. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36436. */
  36437. constructor(leftJoystick?: boolean);
  36438. /**
  36439. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36440. * @param newJoystickSensibility defines the new sensibility
  36441. */
  36442. setJoystickSensibility(newJoystickSensibility: number): void;
  36443. private _onPointerDown;
  36444. private _onPointerMove;
  36445. private _onPointerUp;
  36446. /**
  36447. * Change the color of the virtual joystick
  36448. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36449. */
  36450. setJoystickColor(newColor: string): void;
  36451. /**
  36452. * Defines a callback to call when the joystick is touched
  36453. * @param action defines the callback
  36454. */
  36455. setActionOnTouch(action: () => any): void;
  36456. /**
  36457. * Defines which axis you'd like to control for left & right
  36458. * @param axis defines the axis to use
  36459. */
  36460. setAxisForLeftRight(axis: JoystickAxis): void;
  36461. /**
  36462. * Defines which axis you'd like to control for up & down
  36463. * @param axis defines the axis to use
  36464. */
  36465. setAxisForUpDown(axis: JoystickAxis): void;
  36466. private _drawVirtualJoystick;
  36467. /**
  36468. * Release internal HTML canvas
  36469. */
  36470. releaseCanvas(): void;
  36471. }
  36472. }
  36473. declare module BABYLON {
  36474. interface FreeCameraInputsManager {
  36475. /**
  36476. * Add virtual joystick input support to the input manager.
  36477. * @returns the current input manager
  36478. */
  36479. addVirtualJoystick(): FreeCameraInputsManager;
  36480. }
  36481. /**
  36482. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36484. */
  36485. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36486. /**
  36487. * Defines the camera the input is attached to.
  36488. */
  36489. camera: FreeCamera;
  36490. private _leftjoystick;
  36491. private _rightjoystick;
  36492. /**
  36493. * Gets the left stick of the virtual joystick.
  36494. * @returns The virtual Joystick
  36495. */
  36496. getLeftJoystick(): VirtualJoystick;
  36497. /**
  36498. * Gets the right stick of the virtual joystick.
  36499. * @returns The virtual Joystick
  36500. */
  36501. getRightJoystick(): VirtualJoystick;
  36502. /**
  36503. * Update the current camera state depending on the inputs that have been used this frame.
  36504. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36505. */
  36506. checkInputs(): void;
  36507. /**
  36508. * Attach the input controls to a specific dom element to get the input from.
  36509. * @param element Defines the element the controls should be listened from
  36510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36511. */
  36512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36513. /**
  36514. * Detach the current controls from the specified dom element.
  36515. * @param element Defines the element to stop listening the inputs from
  36516. */
  36517. detachControl(element: Nullable<HTMLElement>): void;
  36518. /**
  36519. * Gets the class name of the current intput.
  36520. * @returns the class name
  36521. */
  36522. getClassName(): string;
  36523. /**
  36524. * Get the friendly name associated with the input class.
  36525. * @returns the input friendly name
  36526. */
  36527. getSimpleName(): string;
  36528. }
  36529. }
  36530. declare module BABYLON {
  36531. /**
  36532. * This represents a FPS type of camera controlled by touch.
  36533. * This is like a universal camera minus the Gamepad controls.
  36534. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36535. */
  36536. export class TouchCamera extends FreeCamera {
  36537. /**
  36538. * Defines the touch sensibility for rotation.
  36539. * The higher the faster.
  36540. */
  36541. touchAngularSensibility: number;
  36542. /**
  36543. * Defines the touch sensibility for move.
  36544. * The higher the faster.
  36545. */
  36546. touchMoveSensibility: number;
  36547. /**
  36548. * Instantiates a new touch camera.
  36549. * This represents a FPS type of camera controlled by touch.
  36550. * This is like a universal camera minus the Gamepad controls.
  36551. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36552. * @param name Define the name of the camera in the scene
  36553. * @param position Define the start position of the camera in the scene
  36554. * @param scene Define the scene the camera belongs to
  36555. */
  36556. constructor(name: string, position: Vector3, scene: Scene);
  36557. /**
  36558. * Gets the current object class name.
  36559. * @return the class name
  36560. */
  36561. getClassName(): string;
  36562. /** @hidden */ setupInputs(): void;
  36563. }
  36564. }
  36565. declare module BABYLON {
  36566. /**
  36567. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36568. * being tilted forward or back and left or right.
  36569. */
  36570. export class DeviceOrientationCamera extends FreeCamera {
  36571. private _initialQuaternion;
  36572. private _quaternionCache;
  36573. private _tmpDragQuaternion;
  36574. /**
  36575. * Creates a new device orientation camera
  36576. * @param name The name of the camera
  36577. * @param position The start position camera
  36578. * @param scene The scene the camera belongs to
  36579. */
  36580. constructor(name: string, position: Vector3, scene: Scene);
  36581. /**
  36582. * Disabled pointer input on first orientation sensor update (Default: true)
  36583. */
  36584. disablePointerInputWhenUsingDeviceOrientation: boolean;
  36585. private _dragFactor;
  36586. /**
  36587. * Enabled turning on the y axis when the orientation sensor is active
  36588. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  36589. */
  36590. enableHorizontalDragging(dragFactor?: number): void;
  36591. /**
  36592. * Gets the current instance class name ("DeviceOrientationCamera").
  36593. * This helps avoiding instanceof at run time.
  36594. * @returns the class name
  36595. */
  36596. getClassName(): string;
  36597. /**
  36598. * @hidden
  36599. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36600. */ checkInputs(): void;
  36601. /**
  36602. * Reset the camera to its default orientation on the specified axis only.
  36603. * @param axis The axis to reset
  36604. */
  36605. resetToCurrentRotation(axis?: Axis): void;
  36606. }
  36607. }
  36608. declare module BABYLON {
  36609. /**
  36610. * 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,
  36611. * which still works and will still be found in many Playgrounds.
  36612. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36613. */
  36614. export class UniversalCamera extends TouchCamera {
  36615. /**
  36616. * Defines the gamepad rotation sensiblity.
  36617. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36618. */
  36619. gamepadAngularSensibility: number;
  36620. /**
  36621. * Defines the gamepad move sensiblity.
  36622. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36623. */
  36624. gamepadMoveSensibility: number;
  36625. /**
  36626. * 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,
  36627. * which still works and will still be found in many Playgrounds.
  36628. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36629. * @param name Define the name of the camera in the scene
  36630. * @param position Define the start position of the camera in the scene
  36631. * @param scene Define the scene the camera belongs to
  36632. */
  36633. constructor(name: string, position: Vector3, scene: Scene);
  36634. /**
  36635. * Gets the current object class name.
  36636. * @return the class name
  36637. */
  36638. getClassName(): string;
  36639. }
  36640. }
  36641. declare module BABYLON {
  36642. /**
  36643. * This represents a FPS type of camera. This is only here for back compat purpose.
  36644. * Please use the UniversalCamera instead as both are identical.
  36645. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36646. */
  36647. export class GamepadCamera extends UniversalCamera {
  36648. /**
  36649. * Instantiates a new Gamepad Camera
  36650. * This represents a FPS type of camera. This is only here for back compat purpose.
  36651. * Please use the UniversalCamera instead as both are identical.
  36652. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36653. * @param name Define the name of the camera in the scene
  36654. * @param position Define the start position of the camera in the scene
  36655. * @param scene Define the scene the camera belongs to
  36656. */
  36657. constructor(name: string, position: Vector3, scene: Scene);
  36658. /**
  36659. * Gets the current object class name.
  36660. * @return the class name
  36661. */
  36662. getClassName(): string;
  36663. }
  36664. }
  36665. declare module BABYLON {
  36666. /** @hidden */
  36667. export var passPixelShader: {
  36668. name: string;
  36669. shader: string;
  36670. };
  36671. }
  36672. declare module BABYLON {
  36673. /** @hidden */
  36674. export var passCubePixelShader: {
  36675. name: string;
  36676. shader: string;
  36677. };
  36678. }
  36679. declare module BABYLON {
  36680. /**
  36681. * PassPostProcess which produces an output the same as it's input
  36682. */
  36683. export class PassPostProcess extends PostProcess {
  36684. /**
  36685. * Creates the PassPostProcess
  36686. * @param name The name of the effect.
  36687. * @param options The required width/height ratio to downsize to before computing the render pass.
  36688. * @param camera The camera to apply the render pass to.
  36689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36690. * @param engine The engine which the post process will be applied. (default: current engine)
  36691. * @param reusable If the post process can be reused on the same frame. (default: false)
  36692. * @param textureType The type of texture to be used when performing the post processing.
  36693. * @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)
  36694. */
  36695. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36696. }
  36697. /**
  36698. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36699. */
  36700. export class PassCubePostProcess extends PostProcess {
  36701. private _face;
  36702. /**
  36703. * Gets or sets the cube face to display.
  36704. * * 0 is +X
  36705. * * 1 is -X
  36706. * * 2 is +Y
  36707. * * 3 is -Y
  36708. * * 4 is +Z
  36709. * * 5 is -Z
  36710. */
  36711. face: number;
  36712. /**
  36713. * Creates the PassCubePostProcess
  36714. * @param name The name of the effect.
  36715. * @param options The required width/height ratio to downsize to before computing the render pass.
  36716. * @param camera The camera to apply the render pass to.
  36717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36718. * @param engine The engine which the post process will be applied. (default: current engine)
  36719. * @param reusable If the post process can be reused on the same frame. (default: false)
  36720. * @param textureType The type of texture to be used when performing the post processing.
  36721. * @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)
  36722. */
  36723. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36724. }
  36725. }
  36726. declare module BABYLON {
  36727. /** @hidden */
  36728. export var anaglyphPixelShader: {
  36729. name: string;
  36730. shader: string;
  36731. };
  36732. }
  36733. declare module BABYLON {
  36734. /**
  36735. * Postprocess used to generate anaglyphic rendering
  36736. */
  36737. export class AnaglyphPostProcess extends PostProcess {
  36738. private _passedProcess;
  36739. /**
  36740. * Creates a new AnaglyphPostProcess
  36741. * @param name defines postprocess name
  36742. * @param options defines creation options or target ratio scale
  36743. * @param rigCameras defines cameras using this postprocess
  36744. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36745. * @param engine defines hosting engine
  36746. * @param reusable defines if the postprocess will be reused multiple times per frame
  36747. */
  36748. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36749. }
  36750. }
  36751. declare module BABYLON {
  36752. /**
  36753. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36754. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36755. */
  36756. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36757. /**
  36758. * Creates a new AnaglyphArcRotateCamera
  36759. * @param name defines camera name
  36760. * @param alpha defines alpha angle (in radians)
  36761. * @param beta defines beta angle (in radians)
  36762. * @param radius defines radius
  36763. * @param target defines camera target
  36764. * @param interaxialDistance defines distance between each color axis
  36765. * @param scene defines the hosting scene
  36766. */
  36767. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36768. /**
  36769. * Gets camera class name
  36770. * @returns AnaglyphArcRotateCamera
  36771. */
  36772. getClassName(): string;
  36773. }
  36774. }
  36775. declare module BABYLON {
  36776. /**
  36777. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36778. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36779. */
  36780. export class AnaglyphFreeCamera extends FreeCamera {
  36781. /**
  36782. * Creates a new AnaglyphFreeCamera
  36783. * @param name defines camera name
  36784. * @param position defines initial position
  36785. * @param interaxialDistance defines distance between each color axis
  36786. * @param scene defines the hosting scene
  36787. */
  36788. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36789. /**
  36790. * Gets camera class name
  36791. * @returns AnaglyphFreeCamera
  36792. */
  36793. getClassName(): string;
  36794. }
  36795. }
  36796. declare module BABYLON {
  36797. /**
  36798. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36799. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36800. */
  36801. export class AnaglyphGamepadCamera extends GamepadCamera {
  36802. /**
  36803. * Creates a new AnaglyphGamepadCamera
  36804. * @param name defines camera name
  36805. * @param position defines initial position
  36806. * @param interaxialDistance defines distance between each color axis
  36807. * @param scene defines the hosting scene
  36808. */
  36809. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36810. /**
  36811. * Gets camera class name
  36812. * @returns AnaglyphGamepadCamera
  36813. */
  36814. getClassName(): string;
  36815. }
  36816. }
  36817. declare module BABYLON {
  36818. /**
  36819. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36820. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36821. */
  36822. export class AnaglyphUniversalCamera extends UniversalCamera {
  36823. /**
  36824. * Creates a new AnaglyphUniversalCamera
  36825. * @param name defines camera name
  36826. * @param position defines initial position
  36827. * @param interaxialDistance defines distance between each color axis
  36828. * @param scene defines the hosting scene
  36829. */
  36830. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36831. /**
  36832. * Gets camera class name
  36833. * @returns AnaglyphUniversalCamera
  36834. */
  36835. getClassName(): string;
  36836. }
  36837. }
  36838. declare module BABYLON {
  36839. /** @hidden */
  36840. export var stereoscopicInterlacePixelShader: {
  36841. name: string;
  36842. shader: string;
  36843. };
  36844. }
  36845. declare module BABYLON {
  36846. /**
  36847. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36848. */
  36849. export class StereoscopicInterlacePostProcess extends PostProcess {
  36850. private _stepSize;
  36851. private _passedProcess;
  36852. /**
  36853. * Initializes a StereoscopicInterlacePostProcess
  36854. * @param name The name of the effect.
  36855. * @param rigCameras The rig cameras to be appled to the post process
  36856. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36858. * @param engine The engine which the post process will be applied. (default: current engine)
  36859. * @param reusable If the post process can be reused on the same frame. (default: false)
  36860. */
  36861. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36862. }
  36863. }
  36864. declare module BABYLON {
  36865. /**
  36866. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  36867. * @see http://doc.babylonjs.com/features/cameras
  36868. */
  36869. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  36870. /**
  36871. * Creates a new StereoscopicArcRotateCamera
  36872. * @param name defines camera name
  36873. * @param alpha defines alpha angle (in radians)
  36874. * @param beta defines beta angle (in radians)
  36875. * @param radius defines radius
  36876. * @param target defines camera target
  36877. * @param interaxialDistance defines distance between each color axis
  36878. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36879. * @param scene defines the hosting scene
  36880. */
  36881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36882. /**
  36883. * Gets camera class name
  36884. * @returns StereoscopicArcRotateCamera
  36885. */
  36886. getClassName(): string;
  36887. }
  36888. }
  36889. declare module BABYLON {
  36890. /**
  36891. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  36892. * @see http://doc.babylonjs.com/features/cameras
  36893. */
  36894. export class StereoscopicFreeCamera extends FreeCamera {
  36895. /**
  36896. * Creates a new StereoscopicFreeCamera
  36897. * @param name defines camera name
  36898. * @param position defines initial position
  36899. * @param interaxialDistance defines distance between each color axis
  36900. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36901. * @param scene defines the hosting scene
  36902. */
  36903. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36904. /**
  36905. * Gets camera class name
  36906. * @returns StereoscopicFreeCamera
  36907. */
  36908. getClassName(): string;
  36909. }
  36910. }
  36911. declare module BABYLON {
  36912. /**
  36913. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  36914. * @see http://doc.babylonjs.com/features/cameras
  36915. */
  36916. export class StereoscopicGamepadCamera extends GamepadCamera {
  36917. /**
  36918. * Creates a new StereoscopicGamepadCamera
  36919. * @param name defines camera name
  36920. * @param position defines initial position
  36921. * @param interaxialDistance defines distance between each color axis
  36922. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36923. * @param scene defines the hosting scene
  36924. */
  36925. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36926. /**
  36927. * Gets camera class name
  36928. * @returns StereoscopicGamepadCamera
  36929. */
  36930. getClassName(): string;
  36931. }
  36932. }
  36933. declare module BABYLON {
  36934. /**
  36935. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  36936. * @see http://doc.babylonjs.com/features/cameras
  36937. */
  36938. export class StereoscopicUniversalCamera extends UniversalCamera {
  36939. /**
  36940. * Creates a new StereoscopicUniversalCamera
  36941. * @param name defines camera name
  36942. * @param position defines initial position
  36943. * @param interaxialDistance defines distance between each color axis
  36944. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36945. * @param scene defines the hosting scene
  36946. */
  36947. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36948. /**
  36949. * Gets camera class name
  36950. * @returns StereoscopicUniversalCamera
  36951. */
  36952. getClassName(): string;
  36953. }
  36954. }
  36955. declare module BABYLON {
  36956. /**
  36957. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  36958. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36959. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36960. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36961. */
  36962. export class VirtualJoysticksCamera extends FreeCamera {
  36963. /**
  36964. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  36965. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36966. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36967. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36968. * @param name Define the name of the camera in the scene
  36969. * @param position Define the start position of the camera in the scene
  36970. * @param scene Define the scene the camera belongs to
  36971. */
  36972. constructor(name: string, position: Vector3, scene: Scene);
  36973. /**
  36974. * Gets the current object class name.
  36975. * @return the class name
  36976. */
  36977. getClassName(): string;
  36978. }
  36979. }
  36980. declare module BABYLON {
  36981. /**
  36982. * This represents all the required metrics to create a VR camera.
  36983. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  36984. */
  36985. export class VRCameraMetrics {
  36986. /**
  36987. * Define the horizontal resolution off the screen.
  36988. */
  36989. hResolution: number;
  36990. /**
  36991. * Define the vertical resolution off the screen.
  36992. */
  36993. vResolution: number;
  36994. /**
  36995. * Define the horizontal screen size.
  36996. */
  36997. hScreenSize: number;
  36998. /**
  36999. * Define the vertical screen size.
  37000. */
  37001. vScreenSize: number;
  37002. /**
  37003. * Define the vertical screen center position.
  37004. */
  37005. vScreenCenter: number;
  37006. /**
  37007. * Define the distance of the eyes to the screen.
  37008. */
  37009. eyeToScreenDistance: number;
  37010. /**
  37011. * Define the distance between both lenses
  37012. */
  37013. lensSeparationDistance: number;
  37014. /**
  37015. * Define the distance between both viewer's eyes.
  37016. */
  37017. interpupillaryDistance: number;
  37018. /**
  37019. * Define the distortion factor of the VR postprocess.
  37020. * Please, touch with care.
  37021. */
  37022. distortionK: number[];
  37023. /**
  37024. * Define the chromatic aberration correction factors for the VR post process.
  37025. */
  37026. chromaAbCorrection: number[];
  37027. /**
  37028. * Define the scale factor of the post process.
  37029. * The smaller the better but the slower.
  37030. */
  37031. postProcessScaleFactor: number;
  37032. /**
  37033. * Define an offset for the lens center.
  37034. */
  37035. lensCenterOffset: number;
  37036. /**
  37037. * Define if the current vr camera should compensate the distortion of the lense or not.
  37038. */
  37039. compensateDistortion: boolean;
  37040. /**
  37041. * Defines if multiview should be enabled when rendering (Default: false)
  37042. */
  37043. multiviewEnabled: boolean;
  37044. /**
  37045. * Gets the rendering aspect ratio based on the provided resolutions.
  37046. */
  37047. readonly aspectRatio: number;
  37048. /**
  37049. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37050. */
  37051. readonly aspectRatioFov: number;
  37052. /**
  37053. * @hidden
  37054. */
  37055. readonly leftHMatrix: Matrix;
  37056. /**
  37057. * @hidden
  37058. */
  37059. readonly rightHMatrix: Matrix;
  37060. /**
  37061. * @hidden
  37062. */
  37063. readonly leftPreViewMatrix: Matrix;
  37064. /**
  37065. * @hidden
  37066. */
  37067. readonly rightPreViewMatrix: Matrix;
  37068. /**
  37069. * Get the default VRMetrics based on the most generic setup.
  37070. * @returns the default vr metrics
  37071. */
  37072. static GetDefault(): VRCameraMetrics;
  37073. }
  37074. }
  37075. declare module BABYLON {
  37076. /** @hidden */
  37077. export var vrDistortionCorrectionPixelShader: {
  37078. name: string;
  37079. shader: string;
  37080. };
  37081. }
  37082. declare module BABYLON {
  37083. /**
  37084. * VRDistortionCorrectionPostProcess used for mobile VR
  37085. */
  37086. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37087. private _isRightEye;
  37088. private _distortionFactors;
  37089. private _postProcessScaleFactor;
  37090. private _lensCenterOffset;
  37091. private _scaleIn;
  37092. private _scaleFactor;
  37093. private _lensCenter;
  37094. /**
  37095. * Initializes the VRDistortionCorrectionPostProcess
  37096. * @param name The name of the effect.
  37097. * @param camera The camera to apply the render pass to.
  37098. * @param isRightEye If this is for the right eye distortion
  37099. * @param vrMetrics All the required metrics for the VR camera
  37100. */
  37101. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37102. }
  37103. }
  37104. declare module BABYLON {
  37105. /**
  37106. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37107. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37108. */
  37109. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37110. /**
  37111. * Creates a new VRDeviceOrientationArcRotateCamera
  37112. * @param name defines camera name
  37113. * @param alpha defines the camera rotation along the logitudinal axis
  37114. * @param beta defines the camera rotation along the latitudinal axis
  37115. * @param radius defines the camera distance from its target
  37116. * @param target defines the camera target
  37117. * @param scene defines the scene the camera belongs to
  37118. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37119. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37120. */
  37121. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37122. /**
  37123. * Gets camera class name
  37124. * @returns VRDeviceOrientationArcRotateCamera
  37125. */
  37126. getClassName(): string;
  37127. }
  37128. }
  37129. declare module BABYLON {
  37130. /**
  37131. * Camera used to simulate VR rendering (based on FreeCamera)
  37132. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37133. */
  37134. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37135. /**
  37136. * Creates a new VRDeviceOrientationFreeCamera
  37137. * @param name defines camera name
  37138. * @param position defines the start position of the camera
  37139. * @param scene defines the scene the camera belongs to
  37140. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37141. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37142. */
  37143. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37144. /**
  37145. * Gets camera class name
  37146. * @returns VRDeviceOrientationFreeCamera
  37147. */
  37148. getClassName(): string;
  37149. }
  37150. }
  37151. declare module BABYLON {
  37152. /**
  37153. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37154. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37155. */
  37156. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37157. /**
  37158. * Creates a new VRDeviceOrientationGamepadCamera
  37159. * @param name defines camera name
  37160. * @param position defines the start position of the camera
  37161. * @param scene defines the scene the camera belongs to
  37162. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37163. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37164. */
  37165. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37166. /**
  37167. * Gets camera class name
  37168. * @returns VRDeviceOrientationGamepadCamera
  37169. */
  37170. getClassName(): string;
  37171. }
  37172. }
  37173. declare module BABYLON {
  37174. /**
  37175. * Defines supported buttons for XBox360 compatible gamepads
  37176. */
  37177. export enum Xbox360Button {
  37178. /** A */
  37179. A = 0,
  37180. /** B */
  37181. B = 1,
  37182. /** X */
  37183. X = 2,
  37184. /** Y */
  37185. Y = 3,
  37186. /** Start */
  37187. Start = 4,
  37188. /** Back */
  37189. Back = 5,
  37190. /** Left button */
  37191. LB = 6,
  37192. /** Right button */
  37193. RB = 7,
  37194. /** Left stick */
  37195. LeftStick = 8,
  37196. /** Right stick */
  37197. RightStick = 9
  37198. }
  37199. /** Defines values for XBox360 DPad */
  37200. export enum Xbox360Dpad {
  37201. /** Up */
  37202. Up = 0,
  37203. /** Down */
  37204. Down = 1,
  37205. /** Left */
  37206. Left = 2,
  37207. /** Right */
  37208. Right = 3
  37209. }
  37210. /**
  37211. * Defines a XBox360 gamepad
  37212. */
  37213. export class Xbox360Pad extends Gamepad {
  37214. private _leftTrigger;
  37215. private _rightTrigger;
  37216. private _onlefttriggerchanged;
  37217. private _onrighttriggerchanged;
  37218. private _onbuttondown;
  37219. private _onbuttonup;
  37220. private _ondpaddown;
  37221. private _ondpadup;
  37222. /** Observable raised when a button is pressed */
  37223. onButtonDownObservable: Observable<Xbox360Button>;
  37224. /** Observable raised when a button is released */
  37225. onButtonUpObservable: Observable<Xbox360Button>;
  37226. /** Observable raised when a pad is pressed */
  37227. onPadDownObservable: Observable<Xbox360Dpad>;
  37228. /** Observable raised when a pad is released */
  37229. onPadUpObservable: Observable<Xbox360Dpad>;
  37230. private _buttonA;
  37231. private _buttonB;
  37232. private _buttonX;
  37233. private _buttonY;
  37234. private _buttonBack;
  37235. private _buttonStart;
  37236. private _buttonLB;
  37237. private _buttonRB;
  37238. private _buttonLeftStick;
  37239. private _buttonRightStick;
  37240. private _dPadUp;
  37241. private _dPadDown;
  37242. private _dPadLeft;
  37243. private _dPadRight;
  37244. private _isXboxOnePad;
  37245. /**
  37246. * Creates a new XBox360 gamepad object
  37247. * @param id defines the id of this gamepad
  37248. * @param index defines its index
  37249. * @param gamepad defines the internal HTML gamepad object
  37250. * @param xboxOne defines if it is a XBox One gamepad
  37251. */
  37252. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37253. /**
  37254. * Defines the callback to call when left trigger is pressed
  37255. * @param callback defines the callback to use
  37256. */
  37257. onlefttriggerchanged(callback: (value: number) => void): void;
  37258. /**
  37259. * Defines the callback to call when right trigger is pressed
  37260. * @param callback defines the callback to use
  37261. */
  37262. onrighttriggerchanged(callback: (value: number) => void): void;
  37263. /**
  37264. * Gets the left trigger value
  37265. */
  37266. /**
  37267. * Sets the left trigger value
  37268. */
  37269. leftTrigger: number;
  37270. /**
  37271. * Gets the right trigger value
  37272. */
  37273. /**
  37274. * Sets the right trigger value
  37275. */
  37276. rightTrigger: number;
  37277. /**
  37278. * Defines the callback to call when a button is pressed
  37279. * @param callback defines the callback to use
  37280. */
  37281. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37282. /**
  37283. * Defines the callback to call when a button is released
  37284. * @param callback defines the callback to use
  37285. */
  37286. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37287. /**
  37288. * Defines the callback to call when a pad is pressed
  37289. * @param callback defines the callback to use
  37290. */
  37291. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37292. /**
  37293. * Defines the callback to call when a pad is released
  37294. * @param callback defines the callback to use
  37295. */
  37296. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37297. private _setButtonValue;
  37298. private _setDPadValue;
  37299. /**
  37300. * Gets the value of the `A` button
  37301. */
  37302. /**
  37303. * Sets the value of the `A` button
  37304. */
  37305. buttonA: number;
  37306. /**
  37307. * Gets the value of the `B` button
  37308. */
  37309. /**
  37310. * Sets the value of the `B` button
  37311. */
  37312. buttonB: number;
  37313. /**
  37314. * Gets the value of the `X` button
  37315. */
  37316. /**
  37317. * Sets the value of the `X` button
  37318. */
  37319. buttonX: number;
  37320. /**
  37321. * Gets the value of the `Y` button
  37322. */
  37323. /**
  37324. * Sets the value of the `Y` button
  37325. */
  37326. buttonY: number;
  37327. /**
  37328. * Gets the value of the `Start` button
  37329. */
  37330. /**
  37331. * Sets the value of the `Start` button
  37332. */
  37333. buttonStart: number;
  37334. /**
  37335. * Gets the value of the `Back` button
  37336. */
  37337. /**
  37338. * Sets the value of the `Back` button
  37339. */
  37340. buttonBack: number;
  37341. /**
  37342. * Gets the value of the `Left` button
  37343. */
  37344. /**
  37345. * Sets the value of the `Left` button
  37346. */
  37347. buttonLB: number;
  37348. /**
  37349. * Gets the value of the `Right` button
  37350. */
  37351. /**
  37352. * Sets the value of the `Right` button
  37353. */
  37354. buttonRB: number;
  37355. /**
  37356. * Gets the value of the Left joystick
  37357. */
  37358. /**
  37359. * Sets the value of the Left joystick
  37360. */
  37361. buttonLeftStick: number;
  37362. /**
  37363. * Gets the value of the Right joystick
  37364. */
  37365. /**
  37366. * Sets the value of the Right joystick
  37367. */
  37368. buttonRightStick: number;
  37369. /**
  37370. * Gets the value of D-pad up
  37371. */
  37372. /**
  37373. * Sets the value of D-pad up
  37374. */
  37375. dPadUp: number;
  37376. /**
  37377. * Gets the value of D-pad down
  37378. */
  37379. /**
  37380. * Sets the value of D-pad down
  37381. */
  37382. dPadDown: number;
  37383. /**
  37384. * Gets the value of D-pad left
  37385. */
  37386. /**
  37387. * Sets the value of D-pad left
  37388. */
  37389. dPadLeft: number;
  37390. /**
  37391. * Gets the value of D-pad right
  37392. */
  37393. /**
  37394. * Sets the value of D-pad right
  37395. */
  37396. dPadRight: number;
  37397. /**
  37398. * Force the gamepad to synchronize with device values
  37399. */
  37400. update(): void;
  37401. /**
  37402. * Disposes the gamepad
  37403. */
  37404. dispose(): void;
  37405. }
  37406. }
  37407. declare module BABYLON {
  37408. /**
  37409. * Base class of materials working in push mode in babylon JS
  37410. * @hidden
  37411. */
  37412. export class PushMaterial extends Material {
  37413. protected _activeEffect: Effect;
  37414. protected _normalMatrix: Matrix;
  37415. /**
  37416. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37417. * This means that the material can keep using a previous shader while a new one is being compiled.
  37418. * This is mostly used when shader parallel compilation is supported (true by default)
  37419. */
  37420. allowShaderHotSwapping: boolean;
  37421. constructor(name: string, scene: Scene);
  37422. getEffect(): Effect;
  37423. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37424. /**
  37425. * Binds the given world matrix to the active effect
  37426. *
  37427. * @param world the matrix to bind
  37428. */
  37429. bindOnlyWorldMatrix(world: Matrix): void;
  37430. /**
  37431. * Binds the given normal matrix to the active effect
  37432. *
  37433. * @param normalMatrix the matrix to bind
  37434. */
  37435. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37436. bind(world: Matrix, mesh?: Mesh): void;
  37437. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37438. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37439. }
  37440. }
  37441. declare module BABYLON {
  37442. /**
  37443. * This groups all the flags used to control the materials channel.
  37444. */
  37445. export class MaterialFlags {
  37446. private static _DiffuseTextureEnabled;
  37447. /**
  37448. * Are diffuse textures enabled in the application.
  37449. */
  37450. static DiffuseTextureEnabled: boolean;
  37451. private static _AmbientTextureEnabled;
  37452. /**
  37453. * Are ambient textures enabled in the application.
  37454. */
  37455. static AmbientTextureEnabled: boolean;
  37456. private static _OpacityTextureEnabled;
  37457. /**
  37458. * Are opacity textures enabled in the application.
  37459. */
  37460. static OpacityTextureEnabled: boolean;
  37461. private static _ReflectionTextureEnabled;
  37462. /**
  37463. * Are reflection textures enabled in the application.
  37464. */
  37465. static ReflectionTextureEnabled: boolean;
  37466. private static _EmissiveTextureEnabled;
  37467. /**
  37468. * Are emissive textures enabled in the application.
  37469. */
  37470. static EmissiveTextureEnabled: boolean;
  37471. private static _SpecularTextureEnabled;
  37472. /**
  37473. * Are specular textures enabled in the application.
  37474. */
  37475. static SpecularTextureEnabled: boolean;
  37476. private static _BumpTextureEnabled;
  37477. /**
  37478. * Are bump textures enabled in the application.
  37479. */
  37480. static BumpTextureEnabled: boolean;
  37481. private static _LightmapTextureEnabled;
  37482. /**
  37483. * Are lightmap textures enabled in the application.
  37484. */
  37485. static LightmapTextureEnabled: boolean;
  37486. private static _RefractionTextureEnabled;
  37487. /**
  37488. * Are refraction textures enabled in the application.
  37489. */
  37490. static RefractionTextureEnabled: boolean;
  37491. private static _ColorGradingTextureEnabled;
  37492. /**
  37493. * Are color grading textures enabled in the application.
  37494. */
  37495. static ColorGradingTextureEnabled: boolean;
  37496. private static _FresnelEnabled;
  37497. /**
  37498. * Are fresnels enabled in the application.
  37499. */
  37500. static FresnelEnabled: boolean;
  37501. private static _ClearCoatTextureEnabled;
  37502. /**
  37503. * Are clear coat textures enabled in the application.
  37504. */
  37505. static ClearCoatTextureEnabled: boolean;
  37506. private static _ClearCoatBumpTextureEnabled;
  37507. /**
  37508. * Are clear coat bump textures enabled in the application.
  37509. */
  37510. static ClearCoatBumpTextureEnabled: boolean;
  37511. private static _ClearCoatTintTextureEnabled;
  37512. /**
  37513. * Are clear coat tint textures enabled in the application.
  37514. */
  37515. static ClearCoatTintTextureEnabled: boolean;
  37516. private static _SheenTextureEnabled;
  37517. /**
  37518. * Are sheen textures enabled in the application.
  37519. */
  37520. static SheenTextureEnabled: boolean;
  37521. private static _AnisotropicTextureEnabled;
  37522. /**
  37523. * Are anisotropic textures enabled in the application.
  37524. */
  37525. static AnisotropicTextureEnabled: boolean;
  37526. private static _ThicknessTextureEnabled;
  37527. /**
  37528. * Are thickness textures enabled in the application.
  37529. */
  37530. static ThicknessTextureEnabled: boolean;
  37531. }
  37532. }
  37533. declare module BABYLON {
  37534. /** @hidden */
  37535. export var defaultFragmentDeclaration: {
  37536. name: string;
  37537. shader: string;
  37538. };
  37539. }
  37540. declare module BABYLON {
  37541. /** @hidden */
  37542. export var defaultUboDeclaration: {
  37543. name: string;
  37544. shader: string;
  37545. };
  37546. }
  37547. declare module BABYLON {
  37548. /** @hidden */
  37549. export var lightFragmentDeclaration: {
  37550. name: string;
  37551. shader: string;
  37552. };
  37553. }
  37554. declare module BABYLON {
  37555. /** @hidden */
  37556. export var lightUboDeclaration: {
  37557. name: string;
  37558. shader: string;
  37559. };
  37560. }
  37561. declare module BABYLON {
  37562. /** @hidden */
  37563. export var lightsFragmentFunctions: {
  37564. name: string;
  37565. shader: string;
  37566. };
  37567. }
  37568. declare module BABYLON {
  37569. /** @hidden */
  37570. export var shadowsFragmentFunctions: {
  37571. name: string;
  37572. shader: string;
  37573. };
  37574. }
  37575. declare module BABYLON {
  37576. /** @hidden */
  37577. export var fresnelFunction: {
  37578. name: string;
  37579. shader: string;
  37580. };
  37581. }
  37582. declare module BABYLON {
  37583. /** @hidden */
  37584. export var reflectionFunction: {
  37585. name: string;
  37586. shader: string;
  37587. };
  37588. }
  37589. declare module BABYLON {
  37590. /** @hidden */
  37591. export var bumpFragmentFunctions: {
  37592. name: string;
  37593. shader: string;
  37594. };
  37595. }
  37596. declare module BABYLON {
  37597. /** @hidden */
  37598. export var logDepthDeclaration: {
  37599. name: string;
  37600. shader: string;
  37601. };
  37602. }
  37603. declare module BABYLON {
  37604. /** @hidden */
  37605. export var bumpFragment: {
  37606. name: string;
  37607. shader: string;
  37608. };
  37609. }
  37610. declare module BABYLON {
  37611. /** @hidden */
  37612. export var depthPrePass: {
  37613. name: string;
  37614. shader: string;
  37615. };
  37616. }
  37617. declare module BABYLON {
  37618. /** @hidden */
  37619. export var lightFragment: {
  37620. name: string;
  37621. shader: string;
  37622. };
  37623. }
  37624. declare module BABYLON {
  37625. /** @hidden */
  37626. export var logDepthFragment: {
  37627. name: string;
  37628. shader: string;
  37629. };
  37630. }
  37631. declare module BABYLON {
  37632. /** @hidden */
  37633. export var defaultPixelShader: {
  37634. name: string;
  37635. shader: string;
  37636. };
  37637. }
  37638. declare module BABYLON {
  37639. /** @hidden */
  37640. export var defaultVertexDeclaration: {
  37641. name: string;
  37642. shader: string;
  37643. };
  37644. }
  37645. declare module BABYLON {
  37646. /** @hidden */
  37647. export var bumpVertexDeclaration: {
  37648. name: string;
  37649. shader: string;
  37650. };
  37651. }
  37652. declare module BABYLON {
  37653. /** @hidden */
  37654. export var bumpVertex: {
  37655. name: string;
  37656. shader: string;
  37657. };
  37658. }
  37659. declare module BABYLON {
  37660. /** @hidden */
  37661. export var fogVertex: {
  37662. name: string;
  37663. shader: string;
  37664. };
  37665. }
  37666. declare module BABYLON {
  37667. /** @hidden */
  37668. export var shadowsVertex: {
  37669. name: string;
  37670. shader: string;
  37671. };
  37672. }
  37673. declare module BABYLON {
  37674. /** @hidden */
  37675. export var pointCloudVertex: {
  37676. name: string;
  37677. shader: string;
  37678. };
  37679. }
  37680. declare module BABYLON {
  37681. /** @hidden */
  37682. export var logDepthVertex: {
  37683. name: string;
  37684. shader: string;
  37685. };
  37686. }
  37687. declare module BABYLON {
  37688. /** @hidden */
  37689. export var defaultVertexShader: {
  37690. name: string;
  37691. shader: string;
  37692. };
  37693. }
  37694. declare module BABYLON {
  37695. /** @hidden */
  37696. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37697. MAINUV1: boolean;
  37698. MAINUV2: boolean;
  37699. DIFFUSE: boolean;
  37700. DIFFUSEDIRECTUV: number;
  37701. AMBIENT: boolean;
  37702. AMBIENTDIRECTUV: number;
  37703. OPACITY: boolean;
  37704. OPACITYDIRECTUV: number;
  37705. OPACITYRGB: boolean;
  37706. REFLECTION: boolean;
  37707. EMISSIVE: boolean;
  37708. EMISSIVEDIRECTUV: number;
  37709. SPECULAR: boolean;
  37710. SPECULARDIRECTUV: number;
  37711. BUMP: boolean;
  37712. BUMPDIRECTUV: number;
  37713. PARALLAX: boolean;
  37714. PARALLAXOCCLUSION: boolean;
  37715. SPECULAROVERALPHA: boolean;
  37716. CLIPPLANE: boolean;
  37717. CLIPPLANE2: boolean;
  37718. CLIPPLANE3: boolean;
  37719. CLIPPLANE4: boolean;
  37720. ALPHATEST: boolean;
  37721. DEPTHPREPASS: boolean;
  37722. ALPHAFROMDIFFUSE: boolean;
  37723. POINTSIZE: boolean;
  37724. FOG: boolean;
  37725. SPECULARTERM: boolean;
  37726. DIFFUSEFRESNEL: boolean;
  37727. OPACITYFRESNEL: boolean;
  37728. REFLECTIONFRESNEL: boolean;
  37729. REFRACTIONFRESNEL: boolean;
  37730. EMISSIVEFRESNEL: boolean;
  37731. FRESNEL: boolean;
  37732. NORMAL: boolean;
  37733. UV1: boolean;
  37734. UV2: boolean;
  37735. VERTEXCOLOR: boolean;
  37736. VERTEXALPHA: boolean;
  37737. NUM_BONE_INFLUENCERS: number;
  37738. BonesPerMesh: number;
  37739. BONETEXTURE: boolean;
  37740. INSTANCES: boolean;
  37741. GLOSSINESS: boolean;
  37742. ROUGHNESS: boolean;
  37743. EMISSIVEASILLUMINATION: boolean;
  37744. LINKEMISSIVEWITHDIFFUSE: boolean;
  37745. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37746. LIGHTMAP: boolean;
  37747. LIGHTMAPDIRECTUV: number;
  37748. OBJECTSPACE_NORMALMAP: boolean;
  37749. USELIGHTMAPASSHADOWMAP: boolean;
  37750. REFLECTIONMAP_3D: boolean;
  37751. REFLECTIONMAP_SPHERICAL: boolean;
  37752. REFLECTIONMAP_PLANAR: boolean;
  37753. REFLECTIONMAP_CUBIC: boolean;
  37754. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37755. REFLECTIONMAP_PROJECTION: boolean;
  37756. REFLECTIONMAP_SKYBOX: boolean;
  37757. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37758. REFLECTIONMAP_EXPLICIT: boolean;
  37759. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37760. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37761. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37762. INVERTCUBICMAP: boolean;
  37763. LOGARITHMICDEPTH: boolean;
  37764. REFRACTION: boolean;
  37765. REFRACTIONMAP_3D: boolean;
  37766. REFLECTIONOVERALPHA: boolean;
  37767. TWOSIDEDLIGHTING: boolean;
  37768. SHADOWFLOAT: boolean;
  37769. MORPHTARGETS: boolean;
  37770. MORPHTARGETS_NORMAL: boolean;
  37771. MORPHTARGETS_TANGENT: boolean;
  37772. NUM_MORPH_INFLUENCERS: number;
  37773. NONUNIFORMSCALING: boolean;
  37774. PREMULTIPLYALPHA: boolean;
  37775. IMAGEPROCESSING: boolean;
  37776. VIGNETTE: boolean;
  37777. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37778. VIGNETTEBLENDMODEOPAQUE: boolean;
  37779. TONEMAPPING: boolean;
  37780. TONEMAPPING_ACES: boolean;
  37781. CONTRAST: boolean;
  37782. COLORCURVES: boolean;
  37783. COLORGRADING: boolean;
  37784. COLORGRADING3D: boolean;
  37785. SAMPLER3DGREENDEPTH: boolean;
  37786. SAMPLER3DBGRMAP: boolean;
  37787. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37788. MULTIVIEW: boolean;
  37789. /**
  37790. * If the reflection texture on this material is in linear color space
  37791. * @hidden
  37792. */
  37793. IS_REFLECTION_LINEAR: boolean;
  37794. /**
  37795. * If the refraction texture on this material is in linear color space
  37796. * @hidden
  37797. */
  37798. IS_REFRACTION_LINEAR: boolean;
  37799. EXPOSURE: boolean;
  37800. constructor();
  37801. setReflectionMode(modeToEnable: string): void;
  37802. }
  37803. /**
  37804. * This is the default material used in Babylon. It is the best trade off between quality
  37805. * and performances.
  37806. * @see http://doc.babylonjs.com/babylon101/materials
  37807. */
  37808. export class StandardMaterial extends PushMaterial {
  37809. private _diffuseTexture;
  37810. /**
  37811. * The basic texture of the material as viewed under a light.
  37812. */
  37813. diffuseTexture: Nullable<BaseTexture>;
  37814. private _ambientTexture;
  37815. /**
  37816. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37817. */
  37818. ambientTexture: Nullable<BaseTexture>;
  37819. private _opacityTexture;
  37820. /**
  37821. * Define the transparency of the material from a texture.
  37822. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37823. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37824. */
  37825. opacityTexture: Nullable<BaseTexture>;
  37826. private _reflectionTexture;
  37827. /**
  37828. * Define the texture used to display the reflection.
  37829. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37830. */
  37831. reflectionTexture: Nullable<BaseTexture>;
  37832. private _emissiveTexture;
  37833. /**
  37834. * Define texture of the material as if self lit.
  37835. * This will be mixed in the final result even in the absence of light.
  37836. */
  37837. emissiveTexture: Nullable<BaseTexture>;
  37838. private _specularTexture;
  37839. /**
  37840. * Define how the color and intensity of the highlight given by the light in the material.
  37841. */
  37842. specularTexture: Nullable<BaseTexture>;
  37843. private _bumpTexture;
  37844. /**
  37845. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  37846. * 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.
  37847. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  37848. */
  37849. bumpTexture: Nullable<BaseTexture>;
  37850. private _lightmapTexture;
  37851. /**
  37852. * Complex lighting can be computationally expensive to compute at runtime.
  37853. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  37854. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  37855. */
  37856. lightmapTexture: Nullable<BaseTexture>;
  37857. private _refractionTexture;
  37858. /**
  37859. * Define the texture used to display the refraction.
  37860. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37861. */
  37862. refractionTexture: Nullable<BaseTexture>;
  37863. /**
  37864. * The color of the material lit by the environmental background lighting.
  37865. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  37866. */
  37867. ambientColor: Color3;
  37868. /**
  37869. * The basic color of the material as viewed under a light.
  37870. */
  37871. diffuseColor: Color3;
  37872. /**
  37873. * Define how the color and intensity of the highlight given by the light in the material.
  37874. */
  37875. specularColor: Color3;
  37876. /**
  37877. * Define the color of the material as if self lit.
  37878. * This will be mixed in the final result even in the absence of light.
  37879. */
  37880. emissiveColor: Color3;
  37881. /**
  37882. * Defines how sharp are the highlights in the material.
  37883. * The bigger the value the sharper giving a more glossy feeling to the result.
  37884. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  37885. */
  37886. specularPower: number;
  37887. private _useAlphaFromDiffuseTexture;
  37888. /**
  37889. * Does the transparency come from the diffuse texture alpha channel.
  37890. */
  37891. useAlphaFromDiffuseTexture: boolean;
  37892. private _useEmissiveAsIllumination;
  37893. /**
  37894. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  37895. */
  37896. useEmissiveAsIllumination: boolean;
  37897. private _linkEmissiveWithDiffuse;
  37898. /**
  37899. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  37900. * the emissive level when the final color is close to one.
  37901. */
  37902. linkEmissiveWithDiffuse: boolean;
  37903. private _useSpecularOverAlpha;
  37904. /**
  37905. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  37906. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  37907. */
  37908. useSpecularOverAlpha: boolean;
  37909. private _useReflectionOverAlpha;
  37910. /**
  37911. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  37912. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  37913. */
  37914. useReflectionOverAlpha: boolean;
  37915. private _disableLighting;
  37916. /**
  37917. * Does lights from the scene impacts this material.
  37918. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  37919. */
  37920. disableLighting: boolean;
  37921. private _useObjectSpaceNormalMap;
  37922. /**
  37923. * Allows using an object space normal map (instead of tangent space).
  37924. */
  37925. useObjectSpaceNormalMap: boolean;
  37926. private _useParallax;
  37927. /**
  37928. * Is parallax enabled or not.
  37929. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37930. */
  37931. useParallax: boolean;
  37932. private _useParallaxOcclusion;
  37933. /**
  37934. * Is parallax occlusion enabled or not.
  37935. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  37936. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37937. */
  37938. useParallaxOcclusion: boolean;
  37939. /**
  37940. * 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.
  37941. */
  37942. parallaxScaleBias: number;
  37943. private _roughness;
  37944. /**
  37945. * Helps to define how blurry the reflections should appears in the material.
  37946. */
  37947. roughness: number;
  37948. /**
  37949. * In case of refraction, define the value of the indice of refraction.
  37950. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37951. */
  37952. indexOfRefraction: number;
  37953. /**
  37954. * Invert the refraction texture alongside the y axis.
  37955. * It can be useful with procedural textures or probe for instance.
  37956. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37957. */
  37958. invertRefractionY: boolean;
  37959. /**
  37960. * Defines the alpha limits in alpha test mode.
  37961. */
  37962. alphaCutOff: number;
  37963. private _useLightmapAsShadowmap;
  37964. /**
  37965. * In case of light mapping, define whether the map contains light or shadow informations.
  37966. */
  37967. useLightmapAsShadowmap: boolean;
  37968. private _diffuseFresnelParameters;
  37969. /**
  37970. * Define the diffuse fresnel parameters of the material.
  37971. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37972. */
  37973. diffuseFresnelParameters: FresnelParameters;
  37974. private _opacityFresnelParameters;
  37975. /**
  37976. * Define the opacity fresnel parameters of the material.
  37977. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37978. */
  37979. opacityFresnelParameters: FresnelParameters;
  37980. private _reflectionFresnelParameters;
  37981. /**
  37982. * Define the reflection fresnel parameters of the material.
  37983. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37984. */
  37985. reflectionFresnelParameters: FresnelParameters;
  37986. private _refractionFresnelParameters;
  37987. /**
  37988. * Define the refraction fresnel parameters of the material.
  37989. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37990. */
  37991. refractionFresnelParameters: FresnelParameters;
  37992. private _emissiveFresnelParameters;
  37993. /**
  37994. * Define the emissive fresnel parameters of the material.
  37995. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37996. */
  37997. emissiveFresnelParameters: FresnelParameters;
  37998. private _useReflectionFresnelFromSpecular;
  37999. /**
  38000. * If true automatically deducts the fresnels values from the material specularity.
  38001. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38002. */
  38003. useReflectionFresnelFromSpecular: boolean;
  38004. private _useGlossinessFromSpecularMapAlpha;
  38005. /**
  38006. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38007. */
  38008. useGlossinessFromSpecularMapAlpha: boolean;
  38009. private _maxSimultaneousLights;
  38010. /**
  38011. * Defines the maximum number of lights that can be used in the material
  38012. */
  38013. maxSimultaneousLights: number;
  38014. private _invertNormalMapX;
  38015. /**
  38016. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38017. */
  38018. invertNormalMapX: boolean;
  38019. private _invertNormalMapY;
  38020. /**
  38021. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38022. */
  38023. invertNormalMapY: boolean;
  38024. private _twoSidedLighting;
  38025. /**
  38026. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38027. */
  38028. twoSidedLighting: boolean;
  38029. /**
  38030. * Default configuration related to image processing available in the standard Material.
  38031. */
  38032. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38033. /**
  38034. * Gets the image processing configuration used either in this material.
  38035. */
  38036. /**
  38037. * Sets the Default image processing configuration used either in the this material.
  38038. *
  38039. * If sets to null, the scene one is in use.
  38040. */
  38041. imageProcessingConfiguration: ImageProcessingConfiguration;
  38042. /**
  38043. * Keep track of the image processing observer to allow dispose and replace.
  38044. */
  38045. private _imageProcessingObserver;
  38046. /**
  38047. * Attaches a new image processing configuration to the Standard Material.
  38048. * @param configuration
  38049. */
  38050. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38051. /**
  38052. * Gets wether the color curves effect is enabled.
  38053. */
  38054. /**
  38055. * Sets wether the color curves effect is enabled.
  38056. */
  38057. cameraColorCurvesEnabled: boolean;
  38058. /**
  38059. * Gets wether the color grading effect is enabled.
  38060. */
  38061. /**
  38062. * Gets wether the color grading effect is enabled.
  38063. */
  38064. cameraColorGradingEnabled: boolean;
  38065. /**
  38066. * Gets wether tonemapping is enabled or not.
  38067. */
  38068. /**
  38069. * Sets wether tonemapping is enabled or not
  38070. */
  38071. cameraToneMappingEnabled: boolean;
  38072. /**
  38073. * The camera exposure used on this material.
  38074. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38075. * This corresponds to a photographic exposure.
  38076. */
  38077. /**
  38078. * The camera exposure used on this material.
  38079. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38080. * This corresponds to a photographic exposure.
  38081. */
  38082. cameraExposure: number;
  38083. /**
  38084. * Gets The camera contrast used on this material.
  38085. */
  38086. /**
  38087. * Sets The camera contrast used on this material.
  38088. */
  38089. cameraContrast: number;
  38090. /**
  38091. * Gets the Color Grading 2D Lookup Texture.
  38092. */
  38093. /**
  38094. * Sets the Color Grading 2D Lookup Texture.
  38095. */
  38096. cameraColorGradingTexture: Nullable<BaseTexture>;
  38097. /**
  38098. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38099. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38100. * 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;
  38101. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38102. */
  38103. /**
  38104. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38105. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38106. * 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;
  38107. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38108. */
  38109. cameraColorCurves: Nullable<ColorCurves>;
  38110. /**
  38111. * Custom callback helping to override the default shader used in the material.
  38112. */
  38113. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38114. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38115. protected _worldViewProjectionMatrix: Matrix;
  38116. protected _globalAmbientColor: Color3;
  38117. protected _useLogarithmicDepth: boolean;
  38118. /**
  38119. * Instantiates a new standard material.
  38120. * This is the default material used in Babylon. It is the best trade off between quality
  38121. * and performances.
  38122. * @see http://doc.babylonjs.com/babylon101/materials
  38123. * @param name Define the name of the material in the scene
  38124. * @param scene Define the scene the material belong to
  38125. */
  38126. constructor(name: string, scene: Scene);
  38127. /**
  38128. * Gets a boolean indicating that current material needs to register RTT
  38129. */
  38130. readonly hasRenderTargetTextures: boolean;
  38131. /**
  38132. * Gets the current class name of the material e.g. "StandardMaterial"
  38133. * Mainly use in serialization.
  38134. * @returns the class name
  38135. */
  38136. getClassName(): string;
  38137. /**
  38138. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38139. * You can try switching to logarithmic depth.
  38140. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38141. */
  38142. useLogarithmicDepth: boolean;
  38143. /**
  38144. * Specifies if the material will require alpha blending
  38145. * @returns a boolean specifying if alpha blending is needed
  38146. */
  38147. needAlphaBlending(): boolean;
  38148. /**
  38149. * Specifies if this material should be rendered in alpha test mode
  38150. * @returns a boolean specifying if an alpha test is needed.
  38151. */
  38152. needAlphaTesting(): boolean;
  38153. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38154. /**
  38155. * Get the texture used for alpha test purpose.
  38156. * @returns the diffuse texture in case of the standard material.
  38157. */
  38158. getAlphaTestTexture(): Nullable<BaseTexture>;
  38159. /**
  38160. * Get if the submesh is ready to be used and all its information available.
  38161. * Child classes can use it to update shaders
  38162. * @param mesh defines the mesh to check
  38163. * @param subMesh defines which submesh to check
  38164. * @param useInstances specifies that instances should be used
  38165. * @returns a boolean indicating that the submesh is ready or not
  38166. */
  38167. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38168. /**
  38169. * Builds the material UBO layouts.
  38170. * Used internally during the effect preparation.
  38171. */
  38172. buildUniformLayout(): void;
  38173. /**
  38174. * Unbinds the material from the mesh
  38175. */
  38176. unbind(): void;
  38177. /**
  38178. * Binds the submesh to this material by preparing the effect and shader to draw
  38179. * @param world defines the world transformation matrix
  38180. * @param mesh defines the mesh containing the submesh
  38181. * @param subMesh defines the submesh to bind the material to
  38182. */
  38183. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38184. /**
  38185. * Get the list of animatables in the material.
  38186. * @returns the list of animatables object used in the material
  38187. */
  38188. getAnimatables(): IAnimatable[];
  38189. /**
  38190. * Gets the active textures from the material
  38191. * @returns an array of textures
  38192. */
  38193. getActiveTextures(): BaseTexture[];
  38194. /**
  38195. * Specifies if the material uses a texture
  38196. * @param texture defines the texture to check against the material
  38197. * @returns a boolean specifying if the material uses the texture
  38198. */
  38199. hasTexture(texture: BaseTexture): boolean;
  38200. /**
  38201. * Disposes the material
  38202. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38203. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38204. */
  38205. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38206. /**
  38207. * Makes a duplicate of the material, and gives it a new name
  38208. * @param name defines the new name for the duplicated material
  38209. * @returns the cloned material
  38210. */
  38211. clone(name: string): StandardMaterial;
  38212. /**
  38213. * Serializes this material in a JSON representation
  38214. * @returns the serialized material object
  38215. */
  38216. serialize(): any;
  38217. /**
  38218. * Creates a standard material from parsed material data
  38219. * @param source defines the JSON representation of the material
  38220. * @param scene defines the hosting scene
  38221. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38222. * @returns a new standard material
  38223. */
  38224. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38225. /**
  38226. * Are diffuse textures enabled in the application.
  38227. */
  38228. static DiffuseTextureEnabled: boolean;
  38229. /**
  38230. * Are ambient textures enabled in the application.
  38231. */
  38232. static AmbientTextureEnabled: boolean;
  38233. /**
  38234. * Are opacity textures enabled in the application.
  38235. */
  38236. static OpacityTextureEnabled: boolean;
  38237. /**
  38238. * Are reflection textures enabled in the application.
  38239. */
  38240. static ReflectionTextureEnabled: boolean;
  38241. /**
  38242. * Are emissive textures enabled in the application.
  38243. */
  38244. static EmissiveTextureEnabled: boolean;
  38245. /**
  38246. * Are specular textures enabled in the application.
  38247. */
  38248. static SpecularTextureEnabled: boolean;
  38249. /**
  38250. * Are bump textures enabled in the application.
  38251. */
  38252. static BumpTextureEnabled: boolean;
  38253. /**
  38254. * Are lightmap textures enabled in the application.
  38255. */
  38256. static LightmapTextureEnabled: boolean;
  38257. /**
  38258. * Are refraction textures enabled in the application.
  38259. */
  38260. static RefractionTextureEnabled: boolean;
  38261. /**
  38262. * Are color grading textures enabled in the application.
  38263. */
  38264. static ColorGradingTextureEnabled: boolean;
  38265. /**
  38266. * Are fresnels enabled in the application.
  38267. */
  38268. static FresnelEnabled: boolean;
  38269. }
  38270. }
  38271. declare module BABYLON {
  38272. /**
  38273. * A class extending Texture allowing drawing on a texture
  38274. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38275. */
  38276. export class DynamicTexture extends Texture {
  38277. private _generateMipMaps;
  38278. private _canvas;
  38279. private _context;
  38280. private _engine;
  38281. /**
  38282. * Creates a DynamicTexture
  38283. * @param name defines the name of the texture
  38284. * @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
  38285. * @param scene defines the scene where you want the texture
  38286. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38287. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38288. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38289. */
  38290. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38291. /**
  38292. * Get the current class name of the texture useful for serialization or dynamic coding.
  38293. * @returns "DynamicTexture"
  38294. */
  38295. getClassName(): string;
  38296. /**
  38297. * Gets the current state of canRescale
  38298. */
  38299. readonly canRescale: boolean;
  38300. private _recreate;
  38301. /**
  38302. * Scales the texture
  38303. * @param ratio the scale factor to apply to both width and height
  38304. */
  38305. scale(ratio: number): void;
  38306. /**
  38307. * Resizes the texture
  38308. * @param width the new width
  38309. * @param height the new height
  38310. */
  38311. scaleTo(width: number, height: number): void;
  38312. /**
  38313. * Gets the context of the canvas used by the texture
  38314. * @returns the canvas context of the dynamic texture
  38315. */
  38316. getContext(): CanvasRenderingContext2D;
  38317. /**
  38318. * Clears the texture
  38319. */
  38320. clear(): void;
  38321. /**
  38322. * Updates the texture
  38323. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38324. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38325. */
  38326. update(invertY?: boolean, premulAlpha?: boolean): void;
  38327. /**
  38328. * Draws text onto the texture
  38329. * @param text defines the text to be drawn
  38330. * @param x defines the placement of the text from the left
  38331. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38332. * @param font defines the font to be used with font-style, font-size, font-name
  38333. * @param color defines the color used for the text
  38334. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38335. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38336. * @param update defines whether texture is immediately update (default is true)
  38337. */
  38338. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38339. /**
  38340. * Clones the texture
  38341. * @returns the clone of the texture.
  38342. */
  38343. clone(): DynamicTexture;
  38344. /**
  38345. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38346. * @returns a serialized dynamic texture object
  38347. */
  38348. serialize(): any;
  38349. /** @hidden */ rebuild(): void;
  38350. }
  38351. }
  38352. declare module BABYLON {
  38353. /** @hidden */
  38354. export var imageProcessingPixelShader: {
  38355. name: string;
  38356. shader: string;
  38357. };
  38358. }
  38359. declare module BABYLON {
  38360. /**
  38361. * ImageProcessingPostProcess
  38362. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38363. */
  38364. export class ImageProcessingPostProcess extends PostProcess {
  38365. /**
  38366. * Default configuration related to image processing available in the PBR Material.
  38367. */
  38368. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38369. /**
  38370. * Gets the image processing configuration used either in this material.
  38371. */
  38372. /**
  38373. * Sets the Default image processing configuration used either in the this material.
  38374. *
  38375. * If sets to null, the scene one is in use.
  38376. */
  38377. imageProcessingConfiguration: ImageProcessingConfiguration;
  38378. /**
  38379. * Keep track of the image processing observer to allow dispose and replace.
  38380. */
  38381. private _imageProcessingObserver;
  38382. /**
  38383. * Attaches a new image processing configuration to the PBR Material.
  38384. * @param configuration
  38385. */
  38386. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38387. /**
  38388. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38389. */
  38390. /**
  38391. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38392. */
  38393. colorCurves: Nullable<ColorCurves>;
  38394. /**
  38395. * Gets wether the color curves effect is enabled.
  38396. */
  38397. /**
  38398. * Sets wether the color curves effect is enabled.
  38399. */
  38400. colorCurvesEnabled: boolean;
  38401. /**
  38402. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38403. */
  38404. /**
  38405. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38406. */
  38407. colorGradingTexture: Nullable<BaseTexture>;
  38408. /**
  38409. * Gets wether the color grading effect is enabled.
  38410. */
  38411. /**
  38412. * Gets wether the color grading effect is enabled.
  38413. */
  38414. colorGradingEnabled: boolean;
  38415. /**
  38416. * Gets exposure used in the effect.
  38417. */
  38418. /**
  38419. * Sets exposure used in the effect.
  38420. */
  38421. exposure: number;
  38422. /**
  38423. * Gets wether tonemapping is enabled or not.
  38424. */
  38425. /**
  38426. * Sets wether tonemapping is enabled or not
  38427. */
  38428. toneMappingEnabled: boolean;
  38429. /**
  38430. * Gets the type of tone mapping effect.
  38431. */
  38432. /**
  38433. * Sets the type of tone mapping effect.
  38434. */
  38435. toneMappingType: number;
  38436. /**
  38437. * Gets contrast used in the effect.
  38438. */
  38439. /**
  38440. * Sets contrast used in the effect.
  38441. */
  38442. contrast: number;
  38443. /**
  38444. * Gets Vignette stretch size.
  38445. */
  38446. /**
  38447. * Sets Vignette stretch size.
  38448. */
  38449. vignetteStretch: number;
  38450. /**
  38451. * Gets Vignette centre X Offset.
  38452. */
  38453. /**
  38454. * Sets Vignette centre X Offset.
  38455. */
  38456. vignetteCentreX: number;
  38457. /**
  38458. * Gets Vignette centre Y Offset.
  38459. */
  38460. /**
  38461. * Sets Vignette centre Y Offset.
  38462. */
  38463. vignetteCentreY: number;
  38464. /**
  38465. * Gets Vignette weight or intensity of the vignette effect.
  38466. */
  38467. /**
  38468. * Sets Vignette weight or intensity of the vignette effect.
  38469. */
  38470. vignetteWeight: number;
  38471. /**
  38472. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38473. * if vignetteEnabled is set to true.
  38474. */
  38475. /**
  38476. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38477. * if vignetteEnabled is set to true.
  38478. */
  38479. vignetteColor: Color4;
  38480. /**
  38481. * Gets Camera field of view used by the Vignette effect.
  38482. */
  38483. /**
  38484. * Sets Camera field of view used by the Vignette effect.
  38485. */
  38486. vignetteCameraFov: number;
  38487. /**
  38488. * Gets the vignette blend mode allowing different kind of effect.
  38489. */
  38490. /**
  38491. * Sets the vignette blend mode allowing different kind of effect.
  38492. */
  38493. vignetteBlendMode: number;
  38494. /**
  38495. * Gets wether the vignette effect is enabled.
  38496. */
  38497. /**
  38498. * Sets wether the vignette effect is enabled.
  38499. */
  38500. vignetteEnabled: boolean;
  38501. private _fromLinearSpace;
  38502. /**
  38503. * Gets wether the input of the processing is in Gamma or Linear Space.
  38504. */
  38505. /**
  38506. * Sets wether the input of the processing is in Gamma or Linear Space.
  38507. */
  38508. fromLinearSpace: boolean;
  38509. /**
  38510. * Defines cache preventing GC.
  38511. */
  38512. private _defines;
  38513. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38514. /**
  38515. * "ImageProcessingPostProcess"
  38516. * @returns "ImageProcessingPostProcess"
  38517. */
  38518. getClassName(): string;
  38519. protected _updateParameters(): void;
  38520. dispose(camera?: Camera): void;
  38521. }
  38522. }
  38523. declare module BABYLON {
  38524. /**
  38525. * Class containing static functions to help procedurally build meshes
  38526. */
  38527. export class GroundBuilder {
  38528. /**
  38529. * Creates a ground mesh
  38530. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38531. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38533. * @param name defines the name of the mesh
  38534. * @param options defines the options used to create the mesh
  38535. * @param scene defines the hosting scene
  38536. * @returns the ground mesh
  38537. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38538. */
  38539. static CreateGround(name: string, options: {
  38540. width?: number;
  38541. height?: number;
  38542. subdivisions?: number;
  38543. subdivisionsX?: number;
  38544. subdivisionsY?: number;
  38545. updatable?: boolean;
  38546. }, scene: any): Mesh;
  38547. /**
  38548. * Creates a tiled ground mesh
  38549. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38550. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38551. * * 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
  38552. * * 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
  38553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38554. * @param name defines the name of the mesh
  38555. * @param options defines the options used to create the mesh
  38556. * @param scene defines the hosting scene
  38557. * @returns the tiled ground mesh
  38558. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38559. */
  38560. static CreateTiledGround(name: string, options: {
  38561. xmin: number;
  38562. zmin: number;
  38563. xmax: number;
  38564. zmax: number;
  38565. subdivisions?: {
  38566. w: number;
  38567. h: number;
  38568. };
  38569. precision?: {
  38570. w: number;
  38571. h: number;
  38572. };
  38573. updatable?: boolean;
  38574. }, scene?: Nullable<Scene>): Mesh;
  38575. /**
  38576. * Creates a ground mesh from a height map
  38577. * * The parameter `url` sets the URL of the height map image resource.
  38578. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38579. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38580. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38581. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38582. * * 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.
  38583. * * 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).
  38584. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38586. * @param name defines the name of the mesh
  38587. * @param url defines the url to the height map
  38588. * @param options defines the options used to create the mesh
  38589. * @param scene defines the hosting scene
  38590. * @returns the ground mesh
  38591. * @see https://doc.babylonjs.com/babylon101/height_map
  38592. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38593. */
  38594. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38595. width?: number;
  38596. height?: number;
  38597. subdivisions?: number;
  38598. minHeight?: number;
  38599. maxHeight?: number;
  38600. colorFilter?: Color3;
  38601. alphaFilter?: number;
  38602. updatable?: boolean;
  38603. onReady?: (mesh: GroundMesh) => void;
  38604. }, scene?: Nullable<Scene>): GroundMesh;
  38605. }
  38606. }
  38607. declare module BABYLON {
  38608. /**
  38609. * Class containing static functions to help procedurally build meshes
  38610. */
  38611. export class TorusBuilder {
  38612. /**
  38613. * Creates a torus mesh
  38614. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38615. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38616. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38618. * * If you create a double-sided mesh, you can choose what parts of 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
  38619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38620. * @param name defines the name of the mesh
  38621. * @param options defines the options used to create the mesh
  38622. * @param scene defines the hosting scene
  38623. * @returns the torus mesh
  38624. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38625. */
  38626. static CreateTorus(name: string, options: {
  38627. diameter?: number;
  38628. thickness?: number;
  38629. tessellation?: number;
  38630. updatable?: boolean;
  38631. sideOrientation?: number;
  38632. frontUVs?: Vector4;
  38633. backUVs?: Vector4;
  38634. }, scene: any): Mesh;
  38635. }
  38636. }
  38637. declare module BABYLON {
  38638. /**
  38639. * Class containing static functions to help procedurally build meshes
  38640. */
  38641. export class CylinderBuilder {
  38642. /**
  38643. * Creates a cylinder or a cone mesh
  38644. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38645. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38646. * * 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.
  38647. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38648. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38649. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38650. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38651. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38652. * * 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).
  38653. * * 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
  38654. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38655. * * 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
  38656. * * 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.
  38657. * * If `enclose` is false, a ring surface is one element.
  38658. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38659. * * 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
  38660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38661. * * If you create a double-sided mesh, you can choose what parts of 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
  38662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38663. * @param name defines the name of the mesh
  38664. * @param options defines the options used to create the mesh
  38665. * @param scene defines the hosting scene
  38666. * @returns the cylinder mesh
  38667. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38668. */
  38669. static CreateCylinder(name: string, options: {
  38670. height?: number;
  38671. diameterTop?: number;
  38672. diameterBottom?: number;
  38673. diameter?: number;
  38674. tessellation?: number;
  38675. subdivisions?: number;
  38676. arc?: number;
  38677. faceColors?: Color4[];
  38678. faceUV?: Vector4[];
  38679. updatable?: boolean;
  38680. hasRings?: boolean;
  38681. enclose?: boolean;
  38682. sideOrientation?: number;
  38683. frontUVs?: Vector4;
  38684. backUVs?: Vector4;
  38685. }, scene: any): Mesh;
  38686. }
  38687. }
  38688. declare module BABYLON {
  38689. /**
  38690. * Manager for handling gamepads
  38691. */
  38692. export class GamepadManager {
  38693. private _scene?;
  38694. private _babylonGamepads;
  38695. private _oneGamepadConnected;
  38696. /** @hidden */ isMonitoring: boolean;
  38697. private _gamepadEventSupported;
  38698. private _gamepadSupport;
  38699. /**
  38700. * observable to be triggered when the gamepad controller has been connected
  38701. */
  38702. onGamepadConnectedObservable: Observable<Gamepad>;
  38703. /**
  38704. * observable to be triggered when the gamepad controller has been disconnected
  38705. */
  38706. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38707. private _onGamepadConnectedEvent;
  38708. private _onGamepadDisconnectedEvent;
  38709. /**
  38710. * Initializes the gamepad manager
  38711. * @param _scene BabylonJS scene
  38712. */
  38713. constructor(_scene?: Scene | undefined);
  38714. /**
  38715. * The gamepads in the game pad manager
  38716. */
  38717. readonly gamepads: Gamepad[];
  38718. /**
  38719. * Get the gamepad controllers based on type
  38720. * @param type The type of gamepad controller
  38721. * @returns Nullable gamepad
  38722. */
  38723. getGamepadByType(type?: number): Nullable<Gamepad>;
  38724. /**
  38725. * Disposes the gamepad manager
  38726. */
  38727. dispose(): void;
  38728. private _addNewGamepad;
  38729. private _startMonitoringGamepads;
  38730. private _stopMonitoringGamepads;
  38731. /** @hidden */ checkGamepadsStatus(): void;
  38732. private _updateGamepadObjects;
  38733. }
  38734. }
  38735. declare module BABYLON {
  38736. interface Scene {
  38737. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  38738. /**
  38739. * Gets the gamepad manager associated with the scene
  38740. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38741. */
  38742. gamepadManager: GamepadManager;
  38743. }
  38744. /**
  38745. * Interface representing a free camera inputs manager
  38746. */
  38747. interface FreeCameraInputsManager {
  38748. /**
  38749. * Adds gamepad input support to the FreeCameraInputsManager.
  38750. * @returns the FreeCameraInputsManager
  38751. */
  38752. addGamepad(): FreeCameraInputsManager;
  38753. }
  38754. /**
  38755. * Interface representing an arc rotate camera inputs manager
  38756. */
  38757. interface ArcRotateCameraInputsManager {
  38758. /**
  38759. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38760. * @returns the camera inputs manager
  38761. */
  38762. addGamepad(): ArcRotateCameraInputsManager;
  38763. }
  38764. /**
  38765. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38766. */
  38767. export class GamepadSystemSceneComponent implements ISceneComponent {
  38768. /**
  38769. * The component name helpfull to identify the component in the list of scene components.
  38770. */
  38771. readonly name: string;
  38772. /**
  38773. * The scene the component belongs to.
  38774. */
  38775. scene: Scene;
  38776. /**
  38777. * Creates a new instance of the component for the given scene
  38778. * @param scene Defines the scene to register the component in
  38779. */
  38780. constructor(scene: Scene);
  38781. /**
  38782. * Registers the component in a given scene
  38783. */
  38784. register(): void;
  38785. /**
  38786. * Rebuilds the elements related to this component in case of
  38787. * context lost for instance.
  38788. */
  38789. rebuild(): void;
  38790. /**
  38791. * Disposes the component and the associated ressources
  38792. */
  38793. dispose(): void;
  38794. private _beforeCameraUpdate;
  38795. }
  38796. }
  38797. declare module BABYLON {
  38798. /**
  38799. * Options to modify the vr teleportation behavior.
  38800. */
  38801. export interface VRTeleportationOptions {
  38802. /**
  38803. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38804. */
  38805. floorMeshName?: string;
  38806. /**
  38807. * A list of meshes to be used as the teleportation floor. (default: empty)
  38808. */
  38809. floorMeshes?: Mesh[];
  38810. }
  38811. /**
  38812. * Options to modify the vr experience helper's behavior.
  38813. */
  38814. export interface VRExperienceHelperOptions extends WebVROptions {
  38815. /**
  38816. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38817. */
  38818. createDeviceOrientationCamera?: boolean;
  38819. /**
  38820. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38821. */
  38822. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38823. /**
  38824. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38825. */
  38826. laserToggle?: boolean;
  38827. /**
  38828. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38829. */
  38830. floorMeshes?: Mesh[];
  38831. /**
  38832. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  38833. */
  38834. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  38835. }
  38836. /**
  38837. * Event containing information after VR has been entered
  38838. */
  38839. export class OnAfterEnteringVRObservableEvent {
  38840. /**
  38841. * If entering vr was successful
  38842. */
  38843. success: boolean;
  38844. }
  38845. /**
  38846. * Helps to quickly add VR support to an existing scene.
  38847. * See http://doc.babylonjs.com/how_to/webvr_helper
  38848. */
  38849. export class VRExperienceHelper {
  38850. /** Options to modify the vr experience helper's behavior. */
  38851. webVROptions: VRExperienceHelperOptions;
  38852. private _scene;
  38853. private _position;
  38854. private _btnVR;
  38855. private _btnVRDisplayed;
  38856. private _webVRsupported;
  38857. private _webVRready;
  38858. private _webVRrequesting;
  38859. private _webVRpresenting;
  38860. private _hasEnteredVR;
  38861. private _fullscreenVRpresenting;
  38862. private _canvas;
  38863. private _webVRCamera;
  38864. private _vrDeviceOrientationCamera;
  38865. private _deviceOrientationCamera;
  38866. private _existingCamera;
  38867. private _onKeyDown;
  38868. private _onVrDisplayPresentChange;
  38869. private _onVRDisplayChanged;
  38870. private _onVRRequestPresentStart;
  38871. private _onVRRequestPresentComplete;
  38872. /**
  38873. * Observable raised right before entering VR.
  38874. */
  38875. onEnteringVRObservable: Observable<VRExperienceHelper>;
  38876. /**
  38877. * Observable raised when entering VR has completed.
  38878. */
  38879. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  38880. /**
  38881. * Observable raised when exiting VR.
  38882. */
  38883. onExitingVRObservable: Observable<VRExperienceHelper>;
  38884. /**
  38885. * Observable raised when controller mesh is loaded.
  38886. */
  38887. onControllerMeshLoadedObservable: Observable<WebVRController>;
  38888. /** Return this.onEnteringVRObservable
  38889. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  38890. */
  38891. readonly onEnteringVR: Observable<VRExperienceHelper>;
  38892. /** Return this.onExitingVRObservable
  38893. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  38894. */
  38895. readonly onExitingVR: Observable<VRExperienceHelper>;
  38896. /** Return this.onControllerMeshLoadedObservable
  38897. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  38898. */
  38899. readonly onControllerMeshLoaded: Observable<WebVRController>;
  38900. private _rayLength;
  38901. private _useCustomVRButton;
  38902. private _teleportationRequested;
  38903. private _teleportActive;
  38904. private _floorMeshName;
  38905. private _floorMeshesCollection;
  38906. private _rotationAllowed;
  38907. private _teleportBackwardsVector;
  38908. private _teleportationTarget;
  38909. private _isDefaultTeleportationTarget;
  38910. private _postProcessMove;
  38911. private _teleportationFillColor;
  38912. private _teleportationBorderColor;
  38913. private _rotationAngle;
  38914. private _haloCenter;
  38915. private _cameraGazer;
  38916. private _padSensibilityUp;
  38917. private _padSensibilityDown;
  38918. private _leftController;
  38919. private _rightController;
  38920. /**
  38921. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  38922. */
  38923. onNewMeshSelected: Observable<AbstractMesh>;
  38924. /**
  38925. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  38926. */
  38927. onNewMeshPicked: Observable<PickingInfo>;
  38928. private _circleEase;
  38929. /**
  38930. * Observable raised before camera teleportation
  38931. */
  38932. onBeforeCameraTeleport: Observable<Vector3>;
  38933. /**
  38934. * Observable raised after camera teleportation
  38935. */
  38936. onAfterCameraTeleport: Observable<Vector3>;
  38937. /**
  38938. * Observable raised when current selected mesh gets unselected
  38939. */
  38940. onSelectedMeshUnselected: Observable<AbstractMesh>;
  38941. private _raySelectionPredicate;
  38942. /**
  38943. * To be optionaly changed by user to define custom ray selection
  38944. */
  38945. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  38946. /**
  38947. * To be optionaly changed by user to define custom selection logic (after ray selection)
  38948. */
  38949. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  38950. /**
  38951. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  38952. */
  38953. teleportationEnabled: boolean;
  38954. private _defaultHeight;
  38955. private _teleportationInitialized;
  38956. private _interactionsEnabled;
  38957. private _interactionsRequested;
  38958. private _displayGaze;
  38959. private _displayLaserPointer;
  38960. /**
  38961. * The mesh used to display where the user is going to teleport.
  38962. */
  38963. /**
  38964. * Sets the mesh to be used to display where the user is going to teleport.
  38965. */
  38966. teleportationTarget: Mesh;
  38967. /**
  38968. * 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
  38969. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  38970. * See http://doc.babylonjs.com/resources/baking_transformations
  38971. */
  38972. gazeTrackerMesh: Mesh;
  38973. /**
  38974. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  38975. */
  38976. updateGazeTrackerScale: boolean;
  38977. /**
  38978. * If the gaze trackers color should be updated when selecting meshes
  38979. */
  38980. updateGazeTrackerColor: boolean;
  38981. /**
  38982. * The gaze tracking mesh corresponding to the left controller
  38983. */
  38984. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  38985. /**
  38986. * The gaze tracking mesh corresponding to the right controller
  38987. */
  38988. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  38989. /**
  38990. * If the ray of the gaze should be displayed.
  38991. */
  38992. /**
  38993. * Sets if the ray of the gaze should be displayed.
  38994. */
  38995. displayGaze: boolean;
  38996. /**
  38997. * If the ray of the LaserPointer should be displayed.
  38998. */
  38999. /**
  39000. * Sets if the ray of the LaserPointer should be displayed.
  39001. */
  39002. displayLaserPointer: boolean;
  39003. /**
  39004. * The deviceOrientationCamera used as the camera when not in VR.
  39005. */
  39006. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39007. /**
  39008. * Based on the current WebVR support, returns the current VR camera used.
  39009. */
  39010. readonly currentVRCamera: Nullable<Camera>;
  39011. /**
  39012. * The webVRCamera which is used when in VR.
  39013. */
  39014. readonly webVRCamera: WebVRFreeCamera;
  39015. /**
  39016. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39017. */
  39018. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39019. private readonly _teleportationRequestInitiated;
  39020. /**
  39021. * Defines wether or not Pointer lock should be requested when switching to
  39022. * full screen.
  39023. */
  39024. requestPointerLockOnFullScreen: boolean;
  39025. /**
  39026. * Instantiates a VRExperienceHelper.
  39027. * Helps to quickly add VR support to an existing scene.
  39028. * @param scene The scene the VRExperienceHelper belongs to.
  39029. * @param webVROptions Options to modify the vr experience helper's behavior.
  39030. */
  39031. constructor(scene: Scene,
  39032. /** Options to modify the vr experience helper's behavior. */
  39033. webVROptions?: VRExperienceHelperOptions);
  39034. private _onDefaultMeshLoaded;
  39035. private _onResize;
  39036. private _onFullscreenChange;
  39037. /**
  39038. * Gets a value indicating if we are currently in VR mode.
  39039. */
  39040. readonly isInVRMode: boolean;
  39041. private onVrDisplayPresentChange;
  39042. private onVRDisplayChanged;
  39043. private moveButtonToBottomRight;
  39044. private displayVRButton;
  39045. private updateButtonVisibility;
  39046. private _cachedAngularSensibility;
  39047. /**
  39048. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39049. * Otherwise, will use the fullscreen API.
  39050. */
  39051. enterVR(): void;
  39052. /**
  39053. * Attempt to exit VR, or fullscreen.
  39054. */
  39055. exitVR(): void;
  39056. /**
  39057. * The position of the vr experience helper.
  39058. */
  39059. /**
  39060. * Sets the position of the vr experience helper.
  39061. */
  39062. position: Vector3;
  39063. /**
  39064. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39065. */
  39066. enableInteractions(): void;
  39067. private readonly _noControllerIsActive;
  39068. private beforeRender;
  39069. private _isTeleportationFloor;
  39070. /**
  39071. * Adds a floor mesh to be used for teleportation.
  39072. * @param floorMesh the mesh to be used for teleportation.
  39073. */
  39074. addFloorMesh(floorMesh: Mesh): void;
  39075. /**
  39076. * Removes a floor mesh from being used for teleportation.
  39077. * @param floorMesh the mesh to be removed.
  39078. */
  39079. removeFloorMesh(floorMesh: Mesh): void;
  39080. /**
  39081. * Enables interactions and teleportation using the VR controllers and gaze.
  39082. * @param vrTeleportationOptions options to modify teleportation behavior.
  39083. */
  39084. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39085. private _onNewGamepadConnected;
  39086. private _tryEnableInteractionOnController;
  39087. private _onNewGamepadDisconnected;
  39088. private _enableInteractionOnController;
  39089. private _checkTeleportWithRay;
  39090. private _checkRotate;
  39091. private _checkTeleportBackwards;
  39092. private _enableTeleportationOnController;
  39093. private _createTeleportationCircles;
  39094. private _displayTeleportationTarget;
  39095. private _hideTeleportationTarget;
  39096. private _rotateCamera;
  39097. private _moveTeleportationSelectorTo;
  39098. private _workingVector;
  39099. private _workingQuaternion;
  39100. private _workingMatrix;
  39101. /**
  39102. * Teleports the users feet to the desired location
  39103. * @param location The location where the user's feet should be placed
  39104. */
  39105. teleportCamera(location: Vector3): void;
  39106. private _convertNormalToDirectionOfRay;
  39107. private _castRayAndSelectObject;
  39108. private _notifySelectedMeshUnselected;
  39109. /**
  39110. * Sets the color of the laser ray from the vr controllers.
  39111. * @param color new color for the ray.
  39112. */
  39113. changeLaserColor(color: Color3): void;
  39114. /**
  39115. * Sets the color of the ray from the vr headsets gaze.
  39116. * @param color new color for the ray.
  39117. */
  39118. changeGazeColor(color: Color3): void;
  39119. /**
  39120. * Exits VR and disposes of the vr experience helper
  39121. */
  39122. dispose(): void;
  39123. /**
  39124. * Gets the name of the VRExperienceHelper class
  39125. * @returns "VRExperienceHelper"
  39126. */
  39127. getClassName(): string;
  39128. }
  39129. }
  39130. declare module BABYLON {
  39131. /**
  39132. * Manages an XRSession
  39133. * @see https://doc.babylonjs.com/how_to/webxr
  39134. */
  39135. export class WebXRSessionManager implements IDisposable {
  39136. private scene;
  39137. /**
  39138. * Fires every time a new xrFrame arrives which can be used to update the camera
  39139. */
  39140. onXRFrameObservable: Observable<any>;
  39141. /**
  39142. * Fires when the xr session is ended either by the device or manually done
  39143. */
  39144. onXRSessionEnded: Observable<any>;
  39145. /** @hidden */ xrSession: XRSession;
  39146. /** @hidden */ frameOfReference: XRFrameOfReference;
  39147. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39148. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  39149. private _xrNavigator;
  39150. private _xrDevice;
  39151. private _tmpMatrix;
  39152. /**
  39153. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39154. * @param scene The scene which the session should be created for
  39155. */
  39156. constructor(scene: Scene);
  39157. /**
  39158. * Initializes the manager
  39159. * After initialization enterXR can be called to start an XR session
  39160. * @returns Promise which resolves after it is initialized
  39161. */
  39162. initializeAsync(): Promise<void>;
  39163. /**
  39164. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39165. * @param sessionCreationOptions xr options to create the session with
  39166. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39167. * @returns Promise which resolves after it enters XR
  39168. */
  39169. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39170. /**
  39171. * Stops the xrSession and restores the renderloop
  39172. * @returns Promise which resolves after it exits XR
  39173. */
  39174. exitXRAsync(): Promise<void>;
  39175. /**
  39176. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39177. * @param ray ray to cast into the environment
  39178. * @returns Promise which resolves with a collision point in the environment if it exists
  39179. */
  39180. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39181. /**
  39182. * Checks if a session would be supported for the creation options specified
  39183. * @param options creation options to check if they are supported
  39184. * @returns true if supported
  39185. */
  39186. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39187. /**
  39188. * @hidden
  39189. * Converts the render layer of xrSession to a render target
  39190. * @param session session to create render target for
  39191. * @param scene scene the new render target should be created for
  39192. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39193. /**
  39194. * Disposes of the session manager
  39195. */
  39196. dispose(): void;
  39197. }
  39198. }
  39199. declare module BABYLON {
  39200. /**
  39201. * WebXR Camera which holds the views for the xrSession
  39202. * @see https://doc.babylonjs.com/how_to/webxr
  39203. */
  39204. export class WebXRCamera extends FreeCamera {
  39205. private static _TmpMatrix;
  39206. /**
  39207. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39208. * @param name the name of the camera
  39209. * @param scene the scene to add the camera to
  39210. */
  39211. constructor(name: string, scene: Scene);
  39212. private _updateNumberOfRigCameras;
  39213. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  39214. /**
  39215. * Updates the cameras position from the current pose information of the XR session
  39216. * @param xrSessionManager the session containing pose information
  39217. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39218. */
  39219. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39220. }
  39221. }
  39222. declare module BABYLON {
  39223. /**
  39224. * States of the webXR experience
  39225. */
  39226. export enum WebXRState {
  39227. /**
  39228. * Transitioning to being in XR mode
  39229. */
  39230. ENTERING_XR = 0,
  39231. /**
  39232. * Transitioning to non XR mode
  39233. */
  39234. EXITING_XR = 1,
  39235. /**
  39236. * In XR mode and presenting
  39237. */
  39238. IN_XR = 2,
  39239. /**
  39240. * Not entered XR mode
  39241. */
  39242. NOT_IN_XR = 3
  39243. }
  39244. /**
  39245. * Helper class used to enable XR
  39246. * @see https://doc.babylonjs.com/how_to/webxr
  39247. */
  39248. export class WebXRExperienceHelper implements IDisposable {
  39249. private scene;
  39250. /**
  39251. * 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
  39252. */
  39253. container: AbstractMesh;
  39254. /**
  39255. * Camera used to render xr content
  39256. */
  39257. camera: WebXRCamera;
  39258. /**
  39259. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39260. */
  39261. state: WebXRState;
  39262. private _setState;
  39263. private static _TmpVector;
  39264. /**
  39265. * Fires when the state of the experience helper has changed
  39266. */
  39267. onStateChangedObservable: Observable<WebXRState>;
  39268. /** @hidden */ sessionManager: WebXRSessionManager;
  39269. private _nonVRCamera;
  39270. private _originalSceneAutoClear;
  39271. private _supported;
  39272. /**
  39273. * Creates the experience helper
  39274. * @param scene the scene to attach the experience helper to
  39275. * @returns a promise for the experience helper
  39276. */
  39277. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39278. /**
  39279. * Creates a WebXRExperienceHelper
  39280. * @param scene The scene the helper should be created in
  39281. */
  39282. private constructor();
  39283. /**
  39284. * Exits XR mode and returns the scene to its original state
  39285. * @returns promise that resolves after xr mode has exited
  39286. */
  39287. exitXRAsync(): Promise<void>;
  39288. /**
  39289. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39290. * @param sessionCreationOptions options for the XR session
  39291. * @param frameOfReference frame of reference of the XR session
  39292. * @returns promise that resolves after xr mode has entered
  39293. */
  39294. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39295. /**
  39296. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39297. * @param ray ray to cast into the environment
  39298. * @returns Promise which resolves with a collision point in the environment if it exists
  39299. */
  39300. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39301. /**
  39302. * Updates the global position of the camera by moving the camera's container
  39303. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39304. * @param position The desired global position of the camera
  39305. */
  39306. setPositionOfCameraUsingContainer(position: Vector3): void;
  39307. /**
  39308. * Rotates the xr camera by rotating the camera's container around the camera's position
  39309. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39310. * @param rotation the desired quaternion rotation to apply to the camera
  39311. */
  39312. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39313. /**
  39314. * Checks if the creation options are supported by the xr session
  39315. * @param options creation options
  39316. * @returns true if supported
  39317. */
  39318. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39319. /**
  39320. * Disposes of the experience helper
  39321. */
  39322. dispose(): void;
  39323. }
  39324. }
  39325. declare module BABYLON {
  39326. /**
  39327. * Button which can be used to enter a different mode of XR
  39328. */
  39329. export class WebXREnterExitUIButton {
  39330. /** button element */
  39331. element: HTMLElement;
  39332. /** XR initialization options for the button */
  39333. initializationOptions: XRSessionCreationOptions;
  39334. /**
  39335. * Creates a WebXREnterExitUIButton
  39336. * @param element button element
  39337. * @param initializationOptions XR initialization options for the button
  39338. */
  39339. constructor(
  39340. /** button element */
  39341. element: HTMLElement,
  39342. /** XR initialization options for the button */
  39343. initializationOptions: XRSessionCreationOptions);
  39344. /**
  39345. * Overwritable function which can be used to update the button's visuals when the state changes
  39346. * @param activeButton the current active button in the UI
  39347. */
  39348. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39349. }
  39350. /**
  39351. * Options to create the webXR UI
  39352. */
  39353. export class WebXREnterExitUIOptions {
  39354. /**
  39355. * Context to enter xr with
  39356. */
  39357. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39358. /**
  39359. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39360. */
  39361. customButtons?: Array<WebXREnterExitUIButton>;
  39362. }
  39363. /**
  39364. * UI to allow the user to enter/exit XR mode
  39365. */
  39366. export class WebXREnterExitUI implements IDisposable {
  39367. private scene;
  39368. private _overlay;
  39369. private _buttons;
  39370. private _activeButton;
  39371. /**
  39372. * Fired every time the active button is changed.
  39373. *
  39374. * When xr is entered via a button that launches xr that button will be the callback parameter
  39375. *
  39376. * When exiting xr the callback parameter will be null)
  39377. */
  39378. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39379. /**
  39380. * Creates UI to allow the user to enter/exit XR mode
  39381. * @param scene the scene to add the ui to
  39382. * @param helper the xr experience helper to enter/exit xr with
  39383. * @param options options to configure the UI
  39384. * @returns the created ui
  39385. */
  39386. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39387. private constructor();
  39388. private _updateButtons;
  39389. /**
  39390. * Disposes of the object
  39391. */
  39392. dispose(): void;
  39393. }
  39394. }
  39395. declare module BABYLON {
  39396. /**
  39397. * Represents an XR input
  39398. */
  39399. export class WebXRController {
  39400. /**
  39401. * 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
  39402. */
  39403. grip?: AbstractMesh;
  39404. /**
  39405. * Pointer which can be used to select objects or attach a visible laser to
  39406. */
  39407. pointer: AbstractMesh;
  39408. /**
  39409. * Creates the controller
  39410. * @see https://doc.babylonjs.com/how_to/webxr
  39411. * @param scene the scene which the controller should be associated to
  39412. */
  39413. constructor(scene: Scene);
  39414. /**
  39415. * Disposes of the object
  39416. */
  39417. dispose(): void;
  39418. }
  39419. /**
  39420. * XR input used to track XR inputs such as controllers/rays
  39421. */
  39422. export class WebXRInput implements IDisposable {
  39423. private helper;
  39424. /**
  39425. * XR controllers being tracked
  39426. */
  39427. controllers: Array<WebXRController>;
  39428. private _tmpMatrix;
  39429. private _frameObserver;
  39430. /**
  39431. * Initializes the WebXRInput
  39432. * @param helper experience helper which the input should be created for
  39433. */
  39434. constructor(helper: WebXRExperienceHelper);
  39435. /**
  39436. * Disposes of the object
  39437. */
  39438. dispose(): void;
  39439. }
  39440. }
  39441. declare module BABYLON {
  39442. /**
  39443. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39444. */
  39445. export class WebXRManagedOutputCanvas implements IDisposable {
  39446. private _canvas;
  39447. /**
  39448. * xrpresent context of the canvas which can be used to display/mirror xr content
  39449. */
  39450. canvasContext: Nullable<WebGLRenderingContext>;
  39451. /**
  39452. * Initializes the canvas to be added/removed upon entering/exiting xr
  39453. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39454. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39455. */
  39456. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39457. /**
  39458. * Disposes of the object
  39459. */
  39460. dispose(): void;
  39461. private _setManagedOutputCanvas;
  39462. private _addCanvas;
  39463. private _removeCanvas;
  39464. }
  39465. }
  39466. declare module BABYLON {
  39467. /**
  39468. * Contains an array of blocks representing the octree
  39469. */
  39470. export interface IOctreeContainer<T> {
  39471. /**
  39472. * Blocks within the octree
  39473. */
  39474. blocks: Array<OctreeBlock<T>>;
  39475. }
  39476. /**
  39477. * Class used to store a cell in an octree
  39478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39479. */
  39480. export class OctreeBlock<T> {
  39481. /**
  39482. * Gets the content of the current block
  39483. */
  39484. entries: T[];
  39485. /**
  39486. * Gets the list of block children
  39487. */
  39488. blocks: Array<OctreeBlock<T>>;
  39489. private _depth;
  39490. private _maxDepth;
  39491. private _capacity;
  39492. private _minPoint;
  39493. private _maxPoint;
  39494. private _boundingVectors;
  39495. private _creationFunc;
  39496. /**
  39497. * Creates a new block
  39498. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39499. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39500. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39501. * @param depth defines the current depth of this block in the octree
  39502. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39503. * @param creationFunc defines a callback to call when an element is added to the block
  39504. */
  39505. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39506. /**
  39507. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39508. */
  39509. readonly capacity: number;
  39510. /**
  39511. * Gets the minimum vector (in world space) of the block's bounding box
  39512. */
  39513. readonly minPoint: Vector3;
  39514. /**
  39515. * Gets the maximum vector (in world space) of the block's bounding box
  39516. */
  39517. readonly maxPoint: Vector3;
  39518. /**
  39519. * Add a new element to this block
  39520. * @param entry defines the element to add
  39521. */
  39522. addEntry(entry: T): void;
  39523. /**
  39524. * Remove an element from this block
  39525. * @param entry defines the element to remove
  39526. */
  39527. removeEntry(entry: T): void;
  39528. /**
  39529. * Add an array of elements to this block
  39530. * @param entries defines the array of elements to add
  39531. */
  39532. addEntries(entries: T[]): void;
  39533. /**
  39534. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39535. * @param frustumPlanes defines the frustum planes to test
  39536. * @param selection defines the array to store current content if selection is positive
  39537. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39538. */
  39539. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39540. /**
  39541. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39542. * @param sphereCenter defines the bounding sphere center
  39543. * @param sphereRadius defines the bounding sphere radius
  39544. * @param selection defines the array to store current content if selection is positive
  39545. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39546. */
  39547. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39548. /**
  39549. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39550. * @param ray defines the ray to test with
  39551. * @param selection defines the array to store current content if selection is positive
  39552. */
  39553. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39554. /**
  39555. * Subdivide the content into child blocks (this block will then be empty)
  39556. */
  39557. createInnerBlocks(): void;
  39558. /**
  39559. * @hidden
  39560. */ 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;
  39561. }
  39562. }
  39563. declare module BABYLON {
  39564. /**
  39565. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39566. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39567. */
  39568. export class Octree<T> {
  39569. /** 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.) */
  39570. maxDepth: number;
  39571. /**
  39572. * Blocks within the octree containing objects
  39573. */
  39574. blocks: Array<OctreeBlock<T>>;
  39575. /**
  39576. * Content stored in the octree
  39577. */
  39578. dynamicContent: T[];
  39579. private _maxBlockCapacity;
  39580. private _selectionContent;
  39581. private _creationFunc;
  39582. /**
  39583. * Creates a octree
  39584. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39585. * @param creationFunc function to be used to instatiate the octree
  39586. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39587. * @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.)
  39588. */
  39589. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39590. /** 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.) */
  39591. maxDepth?: number);
  39592. /**
  39593. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39594. * @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);
  39595. * @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);
  39596. * @param entries meshes to be added to the octree blocks
  39597. */
  39598. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39599. /**
  39600. * Adds a mesh to the octree
  39601. * @param entry Mesh to add to the octree
  39602. */
  39603. addMesh(entry: T): void;
  39604. /**
  39605. * Remove an element from the octree
  39606. * @param entry defines the element to remove
  39607. */
  39608. removeMesh(entry: T): void;
  39609. /**
  39610. * Selects an array of meshes within the frustum
  39611. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39612. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39613. * @returns array of meshes within the frustum
  39614. */
  39615. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39616. /**
  39617. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39618. * @param sphereCenter defines the bounding sphere center
  39619. * @param sphereRadius defines the bounding sphere radius
  39620. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39621. * @returns an array of objects that intersect the sphere
  39622. */
  39623. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39624. /**
  39625. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39626. * @param ray defines the ray to test with
  39627. * @returns array of intersected objects
  39628. */
  39629. intersectsRay(ray: Ray): SmartArray<T>;
  39630. /**
  39631. * Adds a mesh into the octree block if it intersects the block
  39632. */
  39633. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39634. /**
  39635. * Adds a submesh into the octree block if it intersects the block
  39636. */
  39637. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39638. }
  39639. }
  39640. declare module BABYLON {
  39641. interface Scene {
  39642. /**
  39643. * @hidden
  39644. * Backing Filed
  39645. */ selectionOctree: Octree<AbstractMesh>;
  39646. /**
  39647. * Gets the octree used to boost mesh selection (picking)
  39648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39649. */
  39650. selectionOctree: Octree<AbstractMesh>;
  39651. /**
  39652. * Creates or updates the octree used to boost selection (picking)
  39653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39654. * @param maxCapacity defines the maximum capacity per leaf
  39655. * @param maxDepth defines the maximum depth of the octree
  39656. * @returns an octree of AbstractMesh
  39657. */
  39658. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39659. }
  39660. interface AbstractMesh {
  39661. /**
  39662. * @hidden
  39663. * Backing Field
  39664. */ submeshesOctree: Octree<SubMesh>;
  39665. /**
  39666. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39667. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39668. * @param maxCapacity defines the maximum size of each block (64 by default)
  39669. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39670. * @returns the new octree
  39671. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39672. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39673. */
  39674. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39675. }
  39676. /**
  39677. * Defines the octree scene component responsible to manage any octrees
  39678. * in a given scene.
  39679. */
  39680. export class OctreeSceneComponent {
  39681. /**
  39682. * The component name helpfull to identify the component in the list of scene components.
  39683. */
  39684. readonly name: string;
  39685. /**
  39686. * The scene the component belongs to.
  39687. */
  39688. scene: Scene;
  39689. /**
  39690. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39691. */
  39692. readonly checksIsEnabled: boolean;
  39693. /**
  39694. * Creates a new instance of the component for the given scene
  39695. * @param scene Defines the scene to register the component in
  39696. */
  39697. constructor(scene: Scene);
  39698. /**
  39699. * Registers the component in a given scene
  39700. */
  39701. register(): void;
  39702. /**
  39703. * Return the list of active meshes
  39704. * @returns the list of active meshes
  39705. */
  39706. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39707. /**
  39708. * Return the list of active sub meshes
  39709. * @param mesh The mesh to get the candidates sub meshes from
  39710. * @returns the list of active sub meshes
  39711. */
  39712. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39713. private _tempRay;
  39714. /**
  39715. * Return the list of sub meshes intersecting with a given local ray
  39716. * @param mesh defines the mesh to find the submesh for
  39717. * @param localRay defines the ray in local space
  39718. * @returns the list of intersecting sub meshes
  39719. */
  39720. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39721. /**
  39722. * Return the list of sub meshes colliding with a collider
  39723. * @param mesh defines the mesh to find the submesh for
  39724. * @param collider defines the collider to evaluate the collision against
  39725. * @returns the list of colliding sub meshes
  39726. */
  39727. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39728. /**
  39729. * Rebuilds the elements related to this component in case of
  39730. * context lost for instance.
  39731. */
  39732. rebuild(): void;
  39733. /**
  39734. * Disposes the component and the associated ressources.
  39735. */
  39736. dispose(): void;
  39737. }
  39738. }
  39739. declare module BABYLON {
  39740. /**
  39741. * Renders a layer on top of an existing scene
  39742. */
  39743. export class UtilityLayerRenderer implements IDisposable {
  39744. /** the original scene that will be rendered on top of */
  39745. originalScene: Scene;
  39746. private _pointerCaptures;
  39747. private _lastPointerEvents;
  39748. private static _DefaultUtilityLayer;
  39749. private static _DefaultKeepDepthUtilityLayer;
  39750. private _sharedGizmoLight;
  39751. /**
  39752. * @hidden
  39753. * Light which used by gizmos to get light shading
  39754. */ getSharedGizmoLight(): HemisphericLight;
  39755. /**
  39756. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39757. */
  39758. pickUtilitySceneFirst: boolean;
  39759. /**
  39760. * 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)
  39761. */
  39762. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39763. /**
  39764. * 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)
  39765. */
  39766. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39767. /**
  39768. * The scene that is rendered on top of the original scene
  39769. */
  39770. utilityLayerScene: Scene;
  39771. /**
  39772. * If the utility layer should automatically be rendered on top of existing scene
  39773. */
  39774. shouldRender: boolean;
  39775. /**
  39776. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39777. */
  39778. onlyCheckPointerDownEvents: boolean;
  39779. /**
  39780. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39781. */
  39782. processAllEvents: boolean;
  39783. /**
  39784. * Observable raised when the pointer move from the utility layer scene to the main scene
  39785. */
  39786. onPointerOutObservable: Observable<number>;
  39787. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39788. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39789. private _afterRenderObserver;
  39790. private _sceneDisposeObserver;
  39791. private _originalPointerObserver;
  39792. /**
  39793. * Instantiates a UtilityLayerRenderer
  39794. * @param originalScene the original scene that will be rendered on top of
  39795. * @param handleEvents boolean indicating if the utility layer should handle events
  39796. */
  39797. constructor(
  39798. /** the original scene that will be rendered on top of */
  39799. originalScene: Scene, handleEvents?: boolean);
  39800. private _notifyObservers;
  39801. /**
  39802. * Renders the utility layers scene on top of the original scene
  39803. */
  39804. render(): void;
  39805. /**
  39806. * Disposes of the renderer
  39807. */
  39808. dispose(): void;
  39809. private _updateCamera;
  39810. }
  39811. }
  39812. declare module BABYLON {
  39813. /**
  39814. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39815. */
  39816. export class Gizmo implements IDisposable {
  39817. /** The utility layer the gizmo will be added to */
  39818. gizmoLayer: UtilityLayerRenderer;
  39819. /**
  39820. * The root mesh of the gizmo
  39821. */ rootMesh: Mesh;
  39822. private _attachedMesh;
  39823. /**
  39824. * Ratio for the scale of the gizmo (Default: 1)
  39825. */
  39826. scaleRatio: number;
  39827. private _tmpMatrix;
  39828. /**
  39829. * If a custom mesh has been set (Default: false)
  39830. */
  39831. protected _customMeshSet: boolean;
  39832. /**
  39833. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39834. * * When set, interactions will be enabled
  39835. */
  39836. attachedMesh: Nullable<AbstractMesh>;
  39837. /**
  39838. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39839. * @param mesh The mesh to replace the default mesh of the gizmo
  39840. */
  39841. setCustomMesh(mesh: Mesh): void;
  39842. /**
  39843. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39844. */
  39845. updateGizmoRotationToMatchAttachedMesh: boolean;
  39846. /**
  39847. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39848. */
  39849. updateGizmoPositionToMatchAttachedMesh: boolean;
  39850. /**
  39851. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39852. */
  39853. protected _updateScale: boolean;
  39854. protected _interactionsEnabled: boolean;
  39855. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39856. private _beforeRenderObserver;
  39857. /**
  39858. * Creates a gizmo
  39859. * @param gizmoLayer The utility layer the gizmo will be added to
  39860. */
  39861. constructor(
  39862. /** The utility layer the gizmo will be added to */
  39863. gizmoLayer?: UtilityLayerRenderer);
  39864. private _tempVector;
  39865. /**
  39866. * @hidden
  39867. * Updates the gizmo to match the attached mesh's position/rotation
  39868. */
  39869. protected _update(): void;
  39870. /**
  39871. * Disposes of the gizmo
  39872. */
  39873. dispose(): void;
  39874. }
  39875. }
  39876. declare module BABYLON {
  39877. /**
  39878. * Single axis drag gizmo
  39879. */
  39880. export class AxisDragGizmo extends Gizmo {
  39881. /**
  39882. * Drag behavior responsible for the gizmos dragging interactions
  39883. */
  39884. dragBehavior: PointerDragBehavior;
  39885. private _pointerObserver;
  39886. /**
  39887. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39888. */
  39889. snapDistance: number;
  39890. /**
  39891. * Event that fires each time the gizmo snaps to a new location.
  39892. * * snapDistance is the the change in distance
  39893. */
  39894. onSnapObservable: Observable<{
  39895. snapDistance: number;
  39896. }>;
  39897. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  39898. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  39899. /**
  39900. * Creates an AxisDragGizmo
  39901. * @param gizmoLayer The utility layer the gizmo will be added to
  39902. * @param dragAxis The axis which the gizmo will be able to drag on
  39903. * @param color The color of the gizmo
  39904. */
  39905. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  39906. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39907. /**
  39908. * Disposes of the gizmo
  39909. */
  39910. dispose(): void;
  39911. }
  39912. }
  39913. declare module BABYLON.Debug {
  39914. /**
  39915. * The Axes viewer will show 3 axes in a specific point in space
  39916. */
  39917. export class AxesViewer {
  39918. private _xAxis;
  39919. private _yAxis;
  39920. private _zAxis;
  39921. private _scaleLinesFactor;
  39922. private _instanced;
  39923. /**
  39924. * Gets the hosting scene
  39925. */
  39926. scene: Scene;
  39927. /**
  39928. * Gets or sets a number used to scale line length
  39929. */
  39930. scaleLines: number;
  39931. /** Gets the node hierarchy used to render x-axis */
  39932. readonly xAxis: TransformNode;
  39933. /** Gets the node hierarchy used to render y-axis */
  39934. readonly yAxis: TransformNode;
  39935. /** Gets the node hierarchy used to render z-axis */
  39936. readonly zAxis: TransformNode;
  39937. /**
  39938. * Creates a new AxesViewer
  39939. * @param scene defines the hosting scene
  39940. * @param scaleLines defines a number used to scale line length (1 by default)
  39941. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  39942. * @param xAxis defines the node hierarchy used to render the x-axis
  39943. * @param yAxis defines the node hierarchy used to render the y-axis
  39944. * @param zAxis defines the node hierarchy used to render the z-axis
  39945. */
  39946. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  39947. /**
  39948. * Force the viewer to update
  39949. * @param position defines the position of the viewer
  39950. * @param xaxis defines the x axis of the viewer
  39951. * @param yaxis defines the y axis of the viewer
  39952. * @param zaxis defines the z axis of the viewer
  39953. */
  39954. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  39955. /**
  39956. * Creates an instance of this axes viewer.
  39957. * @returns a new axes viewer with instanced meshes
  39958. */
  39959. createInstance(): AxesViewer;
  39960. /** Releases resources */
  39961. dispose(): void;
  39962. private static _SetRenderingGroupId;
  39963. }
  39964. }
  39965. declare module BABYLON.Debug {
  39966. /**
  39967. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  39968. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  39969. */
  39970. export class BoneAxesViewer extends AxesViewer {
  39971. /**
  39972. * Gets or sets the target mesh where to display the axes viewer
  39973. */
  39974. mesh: Nullable<Mesh>;
  39975. /**
  39976. * Gets or sets the target bone where to display the axes viewer
  39977. */
  39978. bone: Nullable<Bone>;
  39979. /** Gets current position */
  39980. pos: Vector3;
  39981. /** Gets direction of X axis */
  39982. xaxis: Vector3;
  39983. /** Gets direction of Y axis */
  39984. yaxis: Vector3;
  39985. /** Gets direction of Z axis */
  39986. zaxis: Vector3;
  39987. /**
  39988. * Creates a new BoneAxesViewer
  39989. * @param scene defines the hosting scene
  39990. * @param bone defines the target bone
  39991. * @param mesh defines the target mesh
  39992. * @param scaleLines defines a scaling factor for line length (1 by default)
  39993. */
  39994. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  39995. /**
  39996. * Force the viewer to update
  39997. */
  39998. update(): void;
  39999. /** Releases resources */
  40000. dispose(): void;
  40001. }
  40002. }
  40003. declare module BABYLON {
  40004. /**
  40005. * Interface used to define scene explorer extensibility option
  40006. */
  40007. export interface IExplorerExtensibilityOption {
  40008. /**
  40009. * Define the option label
  40010. */
  40011. label: string;
  40012. /**
  40013. * Defines the action to execute on click
  40014. */
  40015. action: (entity: any) => void;
  40016. }
  40017. /**
  40018. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40019. */
  40020. export interface IExplorerExtensibilityGroup {
  40021. /**
  40022. * Defines a predicate to test if a given type mut be extended
  40023. */
  40024. predicate: (entity: any) => boolean;
  40025. /**
  40026. * Gets the list of options added to a type
  40027. */
  40028. entries: IExplorerExtensibilityOption[];
  40029. }
  40030. /**
  40031. * Interface used to define the options to use to create the Inspector
  40032. */
  40033. export interface IInspectorOptions {
  40034. /**
  40035. * Display in overlay mode (default: false)
  40036. */
  40037. overlay?: boolean;
  40038. /**
  40039. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40040. */
  40041. globalRoot?: HTMLElement;
  40042. /**
  40043. * Display the Scene explorer
  40044. */
  40045. showExplorer?: boolean;
  40046. /**
  40047. * Display the property inspector
  40048. */
  40049. showInspector?: boolean;
  40050. /**
  40051. * Display in embed mode (both panes on the right)
  40052. */
  40053. embedMode?: boolean;
  40054. /**
  40055. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40056. */
  40057. handleResize?: boolean;
  40058. /**
  40059. * Allow the panes to popup (default: true)
  40060. */
  40061. enablePopup?: boolean;
  40062. /**
  40063. * Allow the panes to be closed by users (default: true)
  40064. */
  40065. enableClose?: boolean;
  40066. /**
  40067. * Optional list of extensibility entries
  40068. */
  40069. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40070. /**
  40071. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40072. */
  40073. inspectorURL?: string;
  40074. }
  40075. interface Scene {
  40076. /**
  40077. * @hidden
  40078. * Backing field
  40079. */ debugLayer: DebugLayer;
  40080. /**
  40081. * Gets the debug layer (aka Inspector) associated with the scene
  40082. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40083. */
  40084. debugLayer: DebugLayer;
  40085. }
  40086. /**
  40087. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40088. * what is happening in your scene
  40089. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40090. */
  40091. export class DebugLayer {
  40092. /**
  40093. * Define the url to get the inspector script from.
  40094. * By default it uses the babylonjs CDN.
  40095. * @ignoreNaming
  40096. */
  40097. static InspectorURL: string;
  40098. private _scene;
  40099. private BJSINSPECTOR;
  40100. /**
  40101. * Observable triggered when a property is changed through the inspector.
  40102. */
  40103. onPropertyChangedObservable: Observable<{
  40104. object: any;
  40105. property: string;
  40106. value: any;
  40107. initialValue: any;
  40108. }>;
  40109. /**
  40110. * Instantiates a new debug layer.
  40111. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40112. * what is happening in your scene
  40113. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40114. * @param scene Defines the scene to inspect
  40115. */
  40116. constructor(scene: Scene);
  40117. /** Creates the inspector window. */
  40118. private _createInspector;
  40119. /**
  40120. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40121. * @param entity defines the entity to select
  40122. * @param lineContainerTitle defines the specific block to highlight
  40123. */
  40124. select(entity: any, lineContainerTitle?: string): void;
  40125. /** Get the inspector from bundle or global */
  40126. private _getGlobalInspector;
  40127. /**
  40128. * Get if the inspector is visible or not.
  40129. * @returns true if visible otherwise, false
  40130. */
  40131. isVisible(): boolean;
  40132. /**
  40133. * Hide the inspector and close its window.
  40134. */
  40135. hide(): void;
  40136. /**
  40137. * Launch the debugLayer.
  40138. * @param config Define the configuration of the inspector
  40139. * @return a promise fulfilled when the debug layer is visible
  40140. */
  40141. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40142. }
  40143. }
  40144. declare module BABYLON {
  40145. /**
  40146. * Class containing static functions to help procedurally build meshes
  40147. */
  40148. export class BoxBuilder {
  40149. /**
  40150. * Creates a box mesh
  40151. * * The parameter `size` sets the size (float) of each box side (default 1)
  40152. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40153. * * 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)
  40154. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40156. * * If you create a double-sided mesh, you can choose what parts of 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
  40157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40158. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40159. * @param name defines the name of the mesh
  40160. * @param options defines the options used to create the mesh
  40161. * @param scene defines the hosting scene
  40162. * @returns the box mesh
  40163. */
  40164. static CreateBox(name: string, options: {
  40165. size?: number;
  40166. width?: number;
  40167. height?: number;
  40168. depth?: number;
  40169. faceUV?: Vector4[];
  40170. faceColors?: Color4[];
  40171. sideOrientation?: number;
  40172. frontUVs?: Vector4;
  40173. backUVs?: Vector4;
  40174. wrap?: boolean;
  40175. topBaseAt?: number;
  40176. bottomBaseAt?: number;
  40177. updatable?: boolean;
  40178. }, scene?: Nullable<Scene>): Mesh;
  40179. }
  40180. }
  40181. declare module BABYLON {
  40182. /**
  40183. * Class containing static functions to help procedurally build meshes
  40184. */
  40185. export class SphereBuilder {
  40186. /**
  40187. * Creates a sphere mesh
  40188. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40189. * * 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`)
  40190. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40191. * * 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
  40192. * * 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)
  40193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40194. * * If you create a double-sided mesh, you can choose what parts of 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
  40195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40196. * @param name defines the name of the mesh
  40197. * @param options defines the options used to create the mesh
  40198. * @param scene defines the hosting scene
  40199. * @returns the sphere mesh
  40200. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40201. */
  40202. static CreateSphere(name: string, options: {
  40203. segments?: number;
  40204. diameter?: number;
  40205. diameterX?: number;
  40206. diameterY?: number;
  40207. diameterZ?: number;
  40208. arc?: number;
  40209. slice?: number;
  40210. sideOrientation?: number;
  40211. frontUVs?: Vector4;
  40212. backUVs?: Vector4;
  40213. updatable?: boolean;
  40214. }, scene: any): Mesh;
  40215. }
  40216. }
  40217. declare module BABYLON.Debug {
  40218. /**
  40219. * Used to show the physics impostor around the specific mesh
  40220. */
  40221. export class PhysicsViewer {
  40222. /** @hidden */
  40223. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40224. /** @hidden */
  40225. protected _meshes: Array<Nullable<AbstractMesh>>;
  40226. /** @hidden */
  40227. protected _scene: Nullable<Scene>;
  40228. /** @hidden */
  40229. protected _numMeshes: number;
  40230. /** @hidden */
  40231. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40232. private _renderFunction;
  40233. private _utilityLayer;
  40234. private _debugBoxMesh;
  40235. private _debugSphereMesh;
  40236. private _debugCylinderMesh;
  40237. private _debugMaterial;
  40238. private _debugMeshMeshes;
  40239. /**
  40240. * Creates a new PhysicsViewer
  40241. * @param scene defines the hosting scene
  40242. */
  40243. constructor(scene: Scene);
  40244. /** @hidden */
  40245. protected _updateDebugMeshes(): void;
  40246. /**
  40247. * Renders a specified physic impostor
  40248. * @param impostor defines the impostor to render
  40249. * @param targetMesh defines the mesh represented by the impostor
  40250. * @returns the new debug mesh used to render the impostor
  40251. */
  40252. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40253. /**
  40254. * Hides a specified physic impostor
  40255. * @param impostor defines the impostor to hide
  40256. */
  40257. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40258. private _getDebugMaterial;
  40259. private _getDebugBoxMesh;
  40260. private _getDebugSphereMesh;
  40261. private _getDebugCylinderMesh;
  40262. private _getDebugMeshMesh;
  40263. private _getDebugMesh;
  40264. /** Releases all resources */
  40265. dispose(): void;
  40266. }
  40267. }
  40268. declare module BABYLON {
  40269. /**
  40270. * Class containing static functions to help procedurally build meshes
  40271. */
  40272. export class LinesBuilder {
  40273. /**
  40274. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40275. * * 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
  40276. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40277. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40278. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40279. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40280. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40281. * * 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
  40282. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40284. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40285. * @param name defines the name of the new line system
  40286. * @param options defines the options used to create the line system
  40287. * @param scene defines the hosting scene
  40288. * @returns a new line system mesh
  40289. */
  40290. static CreateLineSystem(name: string, options: {
  40291. lines: Vector3[][];
  40292. updatable?: boolean;
  40293. instance?: Nullable<LinesMesh>;
  40294. colors?: Nullable<Color4[][]>;
  40295. useVertexAlpha?: boolean;
  40296. }, scene: Nullable<Scene>): LinesMesh;
  40297. /**
  40298. * Creates a line mesh
  40299. * 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
  40300. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40301. * * The parameter `points` is an array successive Vector3
  40302. * * 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
  40303. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40304. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40305. * * When updating an instance, remember that only point positions can change, not the number of points
  40306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40308. * @param name defines the name of the new line system
  40309. * @param options defines the options used to create the line system
  40310. * @param scene defines the hosting scene
  40311. * @returns a new line mesh
  40312. */
  40313. static CreateLines(name: string, options: {
  40314. points: Vector3[];
  40315. updatable?: boolean;
  40316. instance?: Nullable<LinesMesh>;
  40317. colors?: Color4[];
  40318. useVertexAlpha?: boolean;
  40319. }, scene?: Nullable<Scene>): LinesMesh;
  40320. /**
  40321. * Creates a dashed line mesh
  40322. * * 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
  40323. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40324. * * The parameter `points` is an array successive Vector3
  40325. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40326. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40327. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40328. * * 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
  40329. * * When updating an instance, remember that only point positions can change, not the number of points
  40330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40331. * @param name defines the name of the mesh
  40332. * @param options defines the options used to create the mesh
  40333. * @param scene defines the hosting scene
  40334. * @returns the dashed line mesh
  40335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40336. */
  40337. static CreateDashedLines(name: string, options: {
  40338. points: Vector3[];
  40339. dashSize?: number;
  40340. gapSize?: number;
  40341. dashNb?: number;
  40342. updatable?: boolean;
  40343. instance?: LinesMesh;
  40344. }, scene?: Nullable<Scene>): LinesMesh;
  40345. }
  40346. }
  40347. declare module BABYLON {
  40348. /**
  40349. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40350. * in order to better appreciate the issue one might have.
  40351. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40352. */
  40353. export class RayHelper {
  40354. /**
  40355. * Defines the ray we are currently tryin to visualize.
  40356. */
  40357. ray: Nullable<Ray>;
  40358. private _renderPoints;
  40359. private _renderLine;
  40360. private _renderFunction;
  40361. private _scene;
  40362. private _updateToMeshFunction;
  40363. private _attachedToMesh;
  40364. private _meshSpaceDirection;
  40365. private _meshSpaceOrigin;
  40366. /**
  40367. * Helper function to create a colored helper in a scene in one line.
  40368. * @param ray Defines the ray we are currently tryin to visualize
  40369. * @param scene Defines the scene the ray is used in
  40370. * @param color Defines the color we want to see the ray in
  40371. * @returns The newly created ray helper.
  40372. */
  40373. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40374. /**
  40375. * Instantiate a new ray helper.
  40376. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40377. * in order to better appreciate the issue one might have.
  40378. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40379. * @param ray Defines the ray we are currently tryin to visualize
  40380. */
  40381. constructor(ray: Ray);
  40382. /**
  40383. * Shows the ray we are willing to debug.
  40384. * @param scene Defines the scene the ray needs to be rendered in
  40385. * @param color Defines the color the ray needs to be rendered in
  40386. */
  40387. show(scene: Scene, color?: Color3): void;
  40388. /**
  40389. * Hides the ray we are debugging.
  40390. */
  40391. hide(): void;
  40392. private _render;
  40393. /**
  40394. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40395. * @param mesh Defines the mesh we want the helper attached to
  40396. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40397. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40398. * @param length Defines the length of the ray
  40399. */
  40400. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40401. /**
  40402. * Detach the ray helper from the mesh it has previously been attached to.
  40403. */
  40404. detachFromMesh(): void;
  40405. private _updateToMesh;
  40406. /**
  40407. * Dispose the helper and release its associated resources.
  40408. */
  40409. dispose(): void;
  40410. }
  40411. }
  40412. declare module BABYLON.Debug {
  40413. /**
  40414. * Class used to render a debug view of a given skeleton
  40415. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40416. */
  40417. export class SkeletonViewer {
  40418. /** defines the skeleton to render */
  40419. skeleton: Skeleton;
  40420. /** defines the mesh attached to the skeleton */
  40421. mesh: AbstractMesh;
  40422. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40423. autoUpdateBonesMatrices: boolean;
  40424. /** defines the rendering group id to use with the viewer */
  40425. renderingGroupId: number;
  40426. /** Gets or sets the color used to render the skeleton */
  40427. color: Color3;
  40428. private _scene;
  40429. private _debugLines;
  40430. private _debugMesh;
  40431. private _isEnabled;
  40432. private _renderFunction;
  40433. private _utilityLayer;
  40434. /**
  40435. * Returns the mesh used to render the bones
  40436. */
  40437. readonly debugMesh: Nullable<LinesMesh>;
  40438. /**
  40439. * Creates a new SkeletonViewer
  40440. * @param skeleton defines the skeleton to render
  40441. * @param mesh defines the mesh attached to the skeleton
  40442. * @param scene defines the hosting scene
  40443. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40444. * @param renderingGroupId defines the rendering group id to use with the viewer
  40445. */
  40446. constructor(
  40447. /** defines the skeleton to render */
  40448. skeleton: Skeleton,
  40449. /** defines the mesh attached to the skeleton */
  40450. mesh: AbstractMesh, scene: Scene,
  40451. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40452. autoUpdateBonesMatrices?: boolean,
  40453. /** defines the rendering group id to use with the viewer */
  40454. renderingGroupId?: number);
  40455. /** Gets or sets a boolean indicating if the viewer is enabled */
  40456. isEnabled: boolean;
  40457. private _getBonePosition;
  40458. private _getLinesForBonesWithLength;
  40459. private _getLinesForBonesNoLength;
  40460. /** Update the viewer to sync with current skeleton state */
  40461. update(): void;
  40462. /** Release associated resources */
  40463. dispose(): void;
  40464. }
  40465. }
  40466. declare module BABYLON {
  40467. /**
  40468. * Options to create the null engine
  40469. */
  40470. export class NullEngineOptions {
  40471. /**
  40472. * Render width (Default: 512)
  40473. */
  40474. renderWidth: number;
  40475. /**
  40476. * Render height (Default: 256)
  40477. */
  40478. renderHeight: number;
  40479. /**
  40480. * Texture size (Default: 512)
  40481. */
  40482. textureSize: number;
  40483. /**
  40484. * If delta time between frames should be constant
  40485. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40486. */
  40487. deterministicLockstep: boolean;
  40488. /**
  40489. * Maximum about of steps between frames (Default: 4)
  40490. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40491. */
  40492. lockstepMaxSteps: number;
  40493. }
  40494. /**
  40495. * The null engine class provides support for headless version of babylon.js.
  40496. * This can be used in server side scenario or for testing purposes
  40497. */
  40498. export class NullEngine extends Engine {
  40499. private _options;
  40500. /**
  40501. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40502. */
  40503. isDeterministicLockStep(): boolean;
  40504. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40505. getLockstepMaxSteps(): number;
  40506. /**
  40507. * Sets hardware scaling, used to save performance if needed
  40508. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40509. */
  40510. getHardwareScalingLevel(): number;
  40511. constructor(options?: NullEngineOptions);
  40512. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40513. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  40514. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40515. getRenderWidth(useScreen?: boolean): number;
  40516. getRenderHeight(useScreen?: boolean): number;
  40517. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40518. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40519. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  40520. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  40521. bindSamplers(effect: Effect): void;
  40522. enableEffect(effect: Effect): void;
  40523. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40524. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40525. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40526. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40527. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40528. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40529. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40530. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40531. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40532. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40533. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40534. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40535. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40536. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40537. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40538. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40539. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40540. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40541. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40542. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40543. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40544. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40545. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40546. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40547. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40548. bindBuffers(vertexBuffers: {
  40549. [key: string]: VertexBuffer;
  40550. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  40551. wipeCaches(bruteForce?: boolean): void;
  40552. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40553. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40554. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40555. /** @hidden */ createTexture(): WebGLTexture;
  40556. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  40557. 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;
  40558. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40559. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40560. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40561. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40562. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40563. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40564. areAllEffectsReady(): boolean;
  40565. /**
  40566. * @hidden
  40567. * Get the current error code of the webGL context
  40568. * @returns the error code
  40569. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40570. */
  40571. getError(): number;
  40572. /** @hidden */ getUnpackAlignement(): number;
  40573. /** @hidden */ unpackFlipY(value: boolean): void;
  40574. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40575. /**
  40576. * Updates a dynamic vertex buffer.
  40577. * @param vertexBuffer the vertex buffer to update
  40578. * @param data the data used to update the vertex buffer
  40579. * @param byteOffset the byte offset of the data (optional)
  40580. * @param byteLength the byte length of the data (optional)
  40581. */
  40582. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40583. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  40584. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  40585. releaseEffects(): void;
  40586. displayLoadingUI(): void;
  40587. hideLoadingUI(): void;
  40588. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40589. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40590. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40591. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40592. }
  40593. }
  40594. declare module BABYLON {
  40595. /** @hidden */
  40596. export class _OcclusionDataStorage {
  40597. /** @hidden */
  40598. occlusionInternalRetryCounter: number;
  40599. /** @hidden */
  40600. isOcclusionQueryInProgress: boolean;
  40601. /** @hidden */
  40602. isOccluded: boolean;
  40603. /** @hidden */
  40604. occlusionRetryCount: number;
  40605. /** @hidden */
  40606. occlusionType: number;
  40607. /** @hidden */
  40608. occlusionQueryAlgorithmType: number;
  40609. }
  40610. interface Engine {
  40611. /**
  40612. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40613. * @return the new query
  40614. */
  40615. createQuery(): WebGLQuery;
  40616. /**
  40617. * Delete and release a webGL query
  40618. * @param query defines the query to delete
  40619. * @return the current engine
  40620. */
  40621. deleteQuery(query: WebGLQuery): Engine;
  40622. /**
  40623. * Check if a given query has resolved and got its value
  40624. * @param query defines the query to check
  40625. * @returns true if the query got its value
  40626. */
  40627. isQueryResultAvailable(query: WebGLQuery): boolean;
  40628. /**
  40629. * Gets the value of a given query
  40630. * @param query defines the query to check
  40631. * @returns the value of the query
  40632. */
  40633. getQueryResult(query: WebGLQuery): number;
  40634. /**
  40635. * Initiates an occlusion query
  40636. * @param algorithmType defines the algorithm to use
  40637. * @param query defines the query to use
  40638. * @returns the current engine
  40639. * @see http://doc.babylonjs.com/features/occlusionquery
  40640. */
  40641. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40642. /**
  40643. * Ends an occlusion query
  40644. * @see http://doc.babylonjs.com/features/occlusionquery
  40645. * @param algorithmType defines the algorithm to use
  40646. * @returns the current engine
  40647. */
  40648. endOcclusionQuery(algorithmType: number): Engine;
  40649. /**
  40650. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40651. * Please note that only one query can be issued at a time
  40652. * @returns a time token used to track the time span
  40653. */
  40654. startTimeQuery(): Nullable<_TimeToken>;
  40655. /**
  40656. * Ends a time query
  40657. * @param token defines the token used to measure the time span
  40658. * @returns the time spent (in ns)
  40659. */
  40660. endTimeQuery(token: _TimeToken): int;
  40661. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  40662. /** @hidden */ createTimeQuery(): WebGLQuery;
  40663. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  40664. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  40665. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  40666. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  40667. }
  40668. interface AbstractMesh {
  40669. /**
  40670. * Backing filed
  40671. * @hidden
  40672. */ private _occlusionDataStorage: _OcclusionDataStorage;
  40673. /**
  40674. * Access property
  40675. * @hidden
  40676. */ occlusionDataStorage: _OcclusionDataStorage;
  40677. /**
  40678. * 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.
  40679. * The default value is -1 which means don't break the query and wait till the result
  40680. * @see http://doc.babylonjs.com/features/occlusionquery
  40681. */
  40682. occlusionRetryCount: number;
  40683. /**
  40684. * 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:
  40685. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40686. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40687. * * 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.
  40688. * @see http://doc.babylonjs.com/features/occlusionquery
  40689. */
  40690. occlusionType: number;
  40691. /**
  40692. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40693. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40694. * * 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.
  40695. * @see http://doc.babylonjs.com/features/occlusionquery
  40696. */
  40697. occlusionQueryAlgorithmType: number;
  40698. /**
  40699. * 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
  40700. * @see http://doc.babylonjs.com/features/occlusionquery
  40701. */
  40702. isOccluded: boolean;
  40703. /**
  40704. * Flag to check the progress status of the query
  40705. * @see http://doc.babylonjs.com/features/occlusionquery
  40706. */
  40707. isOcclusionQueryInProgress: boolean;
  40708. }
  40709. }
  40710. declare module BABYLON {
  40711. /** @hidden */
  40712. export var _forceTransformFeedbackToBundle: boolean;
  40713. interface Engine {
  40714. /**
  40715. * Creates a webGL transform feedback object
  40716. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40717. * @returns the webGL transform feedback object
  40718. */
  40719. createTransformFeedback(): WebGLTransformFeedback;
  40720. /**
  40721. * Delete a webGL transform feedback object
  40722. * @param value defines the webGL transform feedback object to delete
  40723. */
  40724. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40725. /**
  40726. * Bind a webGL transform feedback object to the webgl context
  40727. * @param value defines the webGL transform feedback object to bind
  40728. */
  40729. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40730. /**
  40731. * Begins a transform feedback operation
  40732. * @param usePoints defines if points or triangles must be used
  40733. */
  40734. beginTransformFeedback(usePoints: boolean): void;
  40735. /**
  40736. * Ends a transform feedback operation
  40737. */
  40738. endTransformFeedback(): void;
  40739. /**
  40740. * Specify the varyings to use with transform feedback
  40741. * @param program defines the associated webGL program
  40742. * @param value defines the list of strings representing the varying names
  40743. */
  40744. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40745. /**
  40746. * Bind a webGL buffer for a transform feedback operation
  40747. * @param value defines the webGL buffer to bind
  40748. */
  40749. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40750. }
  40751. }
  40752. declare module BABYLON {
  40753. /**
  40754. * Gather the list of clipboard event types as constants.
  40755. */
  40756. export class ClipboardEventTypes {
  40757. /**
  40758. * The clipboard event is fired when a copy command is active (pressed).
  40759. */
  40760. static readonly COPY: number;
  40761. /**
  40762. * The clipboard event is fired when a cut command is active (pressed).
  40763. */
  40764. static readonly CUT: number;
  40765. /**
  40766. * The clipboard event is fired when a paste command is active (pressed).
  40767. */
  40768. static readonly PASTE: number;
  40769. }
  40770. /**
  40771. * This class is used to store clipboard related info for the onClipboardObservable event.
  40772. */
  40773. export class ClipboardInfo {
  40774. /**
  40775. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40776. */
  40777. type: number;
  40778. /**
  40779. * Defines the related dom event
  40780. */
  40781. event: ClipboardEvent;
  40782. /**
  40783. *Creates an instance of ClipboardInfo.
  40784. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  40785. * @param event Defines the related dom event
  40786. */
  40787. constructor(
  40788. /**
  40789. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40790. */
  40791. type: number,
  40792. /**
  40793. * Defines the related dom event
  40794. */
  40795. event: ClipboardEvent);
  40796. /**
  40797. * Get the clipboard event's type from the keycode.
  40798. * @param keyCode Defines the keyCode for the current keyboard event.
  40799. * @return {number}
  40800. */
  40801. static GetTypeFromCharacter(keyCode: number): number;
  40802. }
  40803. }
  40804. declare module BABYLON {
  40805. /**
  40806. * Class used to represent data loading progression
  40807. */
  40808. export class SceneLoaderProgressEvent {
  40809. /** defines if data length to load can be evaluated */
  40810. readonly lengthComputable: boolean;
  40811. /** defines the loaded data length */
  40812. readonly loaded: number;
  40813. /** defines the data length to load */
  40814. readonly total: number;
  40815. /**
  40816. * Create a new progress event
  40817. * @param lengthComputable defines if data length to load can be evaluated
  40818. * @param loaded defines the loaded data length
  40819. * @param total defines the data length to load
  40820. */
  40821. constructor(
  40822. /** defines if data length to load can be evaluated */
  40823. lengthComputable: boolean,
  40824. /** defines the loaded data length */
  40825. loaded: number,
  40826. /** defines the data length to load */
  40827. total: number);
  40828. /**
  40829. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40830. * @param event defines the source event
  40831. * @returns a new SceneLoaderProgressEvent
  40832. */
  40833. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40834. }
  40835. /**
  40836. * Interface used by SceneLoader plugins to define supported file extensions
  40837. */
  40838. export interface ISceneLoaderPluginExtensions {
  40839. /**
  40840. * Defines the list of supported extensions
  40841. */
  40842. [extension: string]: {
  40843. isBinary: boolean;
  40844. };
  40845. }
  40846. /**
  40847. * Interface used by SceneLoader plugin factory
  40848. */
  40849. export interface ISceneLoaderPluginFactory {
  40850. /**
  40851. * Defines the name of the factory
  40852. */
  40853. name: string;
  40854. /**
  40855. * Function called to create a new plugin
  40856. * @return the new plugin
  40857. */
  40858. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40859. /**
  40860. * Boolean indicating if the plugin can direct load specific data
  40861. */
  40862. canDirectLoad?: (data: string) => boolean;
  40863. }
  40864. /**
  40865. * Interface used to define a SceneLoader plugin
  40866. */
  40867. export interface ISceneLoaderPlugin {
  40868. /**
  40869. * The friendly name of this plugin.
  40870. */
  40871. name: string;
  40872. /**
  40873. * The file extensions supported by this plugin.
  40874. */
  40875. extensions: string | ISceneLoaderPluginExtensions;
  40876. /**
  40877. * Import meshes into a scene.
  40878. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40879. * @param scene The scene to import into
  40880. * @param data The data to import
  40881. * @param rootUrl The root url for scene and resources
  40882. * @param meshes The meshes array to import into
  40883. * @param particleSystems The particle systems array to import into
  40884. * @param skeletons The skeletons array to import into
  40885. * @param onError The callback when import fails
  40886. * @returns True if successful or false otherwise
  40887. */
  40888. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40889. /**
  40890. * Load into a scene.
  40891. * @param scene The scene to load into
  40892. * @param data The data to import
  40893. * @param rootUrl The root url for scene and resources
  40894. * @param onError The callback when import fails
  40895. * @returns true if successful or false otherwise
  40896. */
  40897. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40898. /**
  40899. * The callback that returns true if the data can be directly loaded.
  40900. */
  40901. canDirectLoad?: (data: string) => boolean;
  40902. /**
  40903. * The callback that allows custom handling of the root url based on the response url.
  40904. */
  40905. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40906. /**
  40907. * Load into an asset container.
  40908. * @param scene The scene to load into
  40909. * @param data The data to import
  40910. * @param rootUrl The root url for scene and resources
  40911. * @param onError The callback when import fails
  40912. * @returns The loaded asset container
  40913. */
  40914. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  40915. }
  40916. /**
  40917. * Interface used to define an async SceneLoader plugin
  40918. */
  40919. export interface ISceneLoaderPluginAsync {
  40920. /**
  40921. * The friendly name of this plugin.
  40922. */
  40923. name: string;
  40924. /**
  40925. * The file extensions supported by this plugin.
  40926. */
  40927. extensions: string | ISceneLoaderPluginExtensions;
  40928. /**
  40929. * Import meshes into a scene.
  40930. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40931. * @param scene The scene to import into
  40932. * @param data The data to import
  40933. * @param rootUrl The root url for scene and resources
  40934. * @param onProgress The callback when the load progresses
  40935. * @param fileName Defines the name of the file to load
  40936. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  40937. */
  40938. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  40939. meshes: AbstractMesh[];
  40940. particleSystems: IParticleSystem[];
  40941. skeletons: Skeleton[];
  40942. animationGroups: AnimationGroup[];
  40943. }>;
  40944. /**
  40945. * Load into a scene.
  40946. * @param scene The scene to load into
  40947. * @param data The data to import
  40948. * @param rootUrl The root url for scene and resources
  40949. * @param onProgress The callback when the load progresses
  40950. * @param fileName Defines the name of the file to load
  40951. * @returns Nothing
  40952. */
  40953. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  40954. /**
  40955. * The callback that returns true if the data can be directly loaded.
  40956. */
  40957. canDirectLoad?: (data: string) => boolean;
  40958. /**
  40959. * The callback that allows custom handling of the root url based on the response url.
  40960. */
  40961. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40962. /**
  40963. * Load into an asset container.
  40964. * @param scene The scene to load into
  40965. * @param data The data to import
  40966. * @param rootUrl The root url for scene and resources
  40967. * @param onProgress The callback when the load progresses
  40968. * @param fileName Defines the name of the file to load
  40969. * @returns The loaded asset container
  40970. */
  40971. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  40972. }
  40973. /**
  40974. * Class used to load scene from various file formats using registered plugins
  40975. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  40976. */
  40977. export class SceneLoader {
  40978. /**
  40979. * No logging while loading
  40980. */
  40981. static readonly NO_LOGGING: number;
  40982. /**
  40983. * Minimal logging while loading
  40984. */
  40985. static readonly MINIMAL_LOGGING: number;
  40986. /**
  40987. * Summary logging while loading
  40988. */
  40989. static readonly SUMMARY_LOGGING: number;
  40990. /**
  40991. * Detailled logging while loading
  40992. */
  40993. static readonly DETAILED_LOGGING: number;
  40994. /**
  40995. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  40996. */
  40997. static ForceFullSceneLoadingForIncremental: boolean;
  40998. /**
  40999. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41000. */
  41001. static ShowLoadingScreen: boolean;
  41002. /**
  41003. * Defines the current logging level (while loading the scene)
  41004. * @ignorenaming
  41005. */
  41006. static loggingLevel: number;
  41007. /**
  41008. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41009. */
  41010. static CleanBoneMatrixWeights: boolean;
  41011. /**
  41012. * Event raised when a plugin is used to load a scene
  41013. */
  41014. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41015. private static _registeredPlugins;
  41016. private static _getDefaultPlugin;
  41017. private static _getPluginForExtension;
  41018. private static _getPluginForDirectLoad;
  41019. private static _getPluginForFilename;
  41020. private static _getDirectLoad;
  41021. private static _loadData;
  41022. private static _getFileInfo;
  41023. /**
  41024. * Gets a plugin that can load the given extension
  41025. * @param extension defines the extension to load
  41026. * @returns a plugin or null if none works
  41027. */
  41028. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41029. /**
  41030. * Gets a boolean indicating that the given extension can be loaded
  41031. * @param extension defines the extension to load
  41032. * @returns true if the extension is supported
  41033. */
  41034. static IsPluginForExtensionAvailable(extension: string): boolean;
  41035. /**
  41036. * Adds a new plugin to the list of registered plugins
  41037. * @param plugin defines the plugin to add
  41038. */
  41039. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41040. /**
  41041. * Import meshes into a scene
  41042. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41043. * @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)
  41044. * @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)
  41045. * @param scene the instance of BABYLON.Scene to append to
  41046. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41047. * @param onProgress a callback with a progress event for each file being loaded
  41048. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41049. * @param pluginExtension the extension used to determine the plugin
  41050. * @returns The loaded plugin
  41051. */
  41052. 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>;
  41053. /**
  41054. * Import meshes into a scene
  41055. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41056. * @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)
  41057. * @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)
  41058. * @param scene the instance of BABYLON.Scene to append to
  41059. * @param onProgress a callback with a progress event for each file being loaded
  41060. * @param pluginExtension the extension used to determine the plugin
  41061. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41062. */
  41063. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41064. meshes: AbstractMesh[];
  41065. particleSystems: IParticleSystem[];
  41066. skeletons: Skeleton[];
  41067. animationGroups: AnimationGroup[];
  41068. }>;
  41069. /**
  41070. * Load a scene
  41071. * @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)
  41072. * @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)
  41073. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41074. * @param onSuccess a callback with the scene when import succeeds
  41075. * @param onProgress a callback with a progress event for each file being loaded
  41076. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41077. * @param pluginExtension the extension used to determine the plugin
  41078. * @returns The loaded plugin
  41079. */
  41080. 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>;
  41081. /**
  41082. * Load a scene
  41083. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41084. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41085. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41086. * @param onProgress a callback with a progress event for each file being loaded
  41087. * @param pluginExtension the extension used to determine the plugin
  41088. * @returns The loaded scene
  41089. */
  41090. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41091. /**
  41092. * Append a scene
  41093. * @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)
  41094. * @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)
  41095. * @param scene is the instance of BABYLON.Scene to append to
  41096. * @param onSuccess a callback with the scene when import succeeds
  41097. * @param onProgress a callback with a progress event for each file being loaded
  41098. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41099. * @param pluginExtension the extension used to determine the plugin
  41100. * @returns The loaded plugin
  41101. */
  41102. 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>;
  41103. /**
  41104. * Append a scene
  41105. * @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)
  41106. * @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)
  41107. * @param scene is the instance of BABYLON.Scene to append to
  41108. * @param onProgress a callback with a progress event for each file being loaded
  41109. * @param pluginExtension the extension used to determine the plugin
  41110. * @returns The given scene
  41111. */
  41112. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41113. /**
  41114. * Load a scene into an asset container
  41115. * @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)
  41116. * @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)
  41117. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41118. * @param onSuccess a callback with the scene when import succeeds
  41119. * @param onProgress a callback with a progress event for each file being loaded
  41120. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41121. * @param pluginExtension the extension used to determine the plugin
  41122. * @returns The loaded plugin
  41123. */
  41124. 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>;
  41125. /**
  41126. * Load a scene into an asset container
  41127. * @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)
  41128. * @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)
  41129. * @param scene is the instance of Scene to append to
  41130. * @param onProgress a callback with a progress event for each file being loaded
  41131. * @param pluginExtension the extension used to determine the plugin
  41132. * @returns The loaded asset container
  41133. */
  41134. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41135. }
  41136. }
  41137. declare module BABYLON {
  41138. /**
  41139. * Google Daydream controller
  41140. */
  41141. export class DaydreamController extends WebVRController {
  41142. /**
  41143. * Base Url for the controller model.
  41144. */
  41145. static MODEL_BASE_URL: string;
  41146. /**
  41147. * File name for the controller model.
  41148. */
  41149. static MODEL_FILENAME: string;
  41150. /**
  41151. * Gamepad Id prefix used to identify Daydream Controller.
  41152. */
  41153. static readonly GAMEPAD_ID_PREFIX: string;
  41154. /**
  41155. * Creates a new DaydreamController from a gamepad
  41156. * @param vrGamepad the gamepad that the controller should be created from
  41157. */
  41158. constructor(vrGamepad: any);
  41159. /**
  41160. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41161. * @param scene scene in which to add meshes
  41162. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41163. */
  41164. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41165. /**
  41166. * Called once for each button that changed state since the last frame
  41167. * @param buttonIdx Which button index changed
  41168. * @param state New state of the button
  41169. * @param changes Which properties on the state changed since last frame
  41170. */
  41171. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41172. }
  41173. }
  41174. declare module BABYLON {
  41175. /**
  41176. * Gear VR Controller
  41177. */
  41178. export class GearVRController extends WebVRController {
  41179. /**
  41180. * Base Url for the controller model.
  41181. */
  41182. static MODEL_BASE_URL: string;
  41183. /**
  41184. * File name for the controller model.
  41185. */
  41186. static MODEL_FILENAME: string;
  41187. /**
  41188. * Gamepad Id prefix used to identify this controller.
  41189. */
  41190. static readonly GAMEPAD_ID_PREFIX: string;
  41191. private readonly _buttonIndexToObservableNameMap;
  41192. /**
  41193. * Creates a new GearVRController from a gamepad
  41194. * @param vrGamepad the gamepad that the controller should be created from
  41195. */
  41196. constructor(vrGamepad: any);
  41197. /**
  41198. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41199. * @param scene scene in which to add meshes
  41200. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41201. */
  41202. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41203. /**
  41204. * Called once for each button that changed state since the last frame
  41205. * @param buttonIdx Which button index changed
  41206. * @param state New state of the button
  41207. * @param changes Which properties on the state changed since last frame
  41208. */
  41209. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41210. }
  41211. }
  41212. declare module BABYLON {
  41213. /**
  41214. * Generic Controller
  41215. */
  41216. export class GenericController extends WebVRController {
  41217. /**
  41218. * Base Url for the controller model.
  41219. */
  41220. static readonly MODEL_BASE_URL: string;
  41221. /**
  41222. * File name for the controller model.
  41223. */
  41224. static readonly MODEL_FILENAME: string;
  41225. /**
  41226. * Creates a new GenericController from a gamepad
  41227. * @param vrGamepad the gamepad that the controller should be created from
  41228. */
  41229. constructor(vrGamepad: any);
  41230. /**
  41231. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41232. * @param scene scene in which to add meshes
  41233. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41234. */
  41235. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41236. /**
  41237. * Called once for each button that changed state since the last frame
  41238. * @param buttonIdx Which button index changed
  41239. * @param state New state of the button
  41240. * @param changes Which properties on the state changed since last frame
  41241. */
  41242. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41243. }
  41244. }
  41245. declare module BABYLON {
  41246. /**
  41247. * Oculus Touch Controller
  41248. */
  41249. export class OculusTouchController extends WebVRController {
  41250. /**
  41251. * Base Url for the controller model.
  41252. */
  41253. static MODEL_BASE_URL: string;
  41254. /**
  41255. * File name for the left controller model.
  41256. */
  41257. static MODEL_LEFT_FILENAME: string;
  41258. /**
  41259. * File name for the right controller model.
  41260. */
  41261. static MODEL_RIGHT_FILENAME: string;
  41262. /**
  41263. * Fired when the secondary trigger on this controller is modified
  41264. */
  41265. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41266. /**
  41267. * Fired when the thumb rest on this controller is modified
  41268. */
  41269. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41270. /**
  41271. * Creates a new OculusTouchController from a gamepad
  41272. * @param vrGamepad the gamepad that the controller should be created from
  41273. */
  41274. constructor(vrGamepad: any);
  41275. /**
  41276. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41277. * @param scene scene in which to add meshes
  41278. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41279. */
  41280. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41281. /**
  41282. * Fired when the A button on this controller is modified
  41283. */
  41284. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41285. /**
  41286. * Fired when the B button on this controller is modified
  41287. */
  41288. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41289. /**
  41290. * Fired when the X button on this controller is modified
  41291. */
  41292. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41293. /**
  41294. * Fired when the Y button on this controller is modified
  41295. */
  41296. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41297. /**
  41298. * Called once for each button that changed state since the last frame
  41299. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41300. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41301. * 2) secondary trigger (same)
  41302. * 3) A (right) X (left), touch, pressed = value
  41303. * 4) B / Y
  41304. * 5) thumb rest
  41305. * @param buttonIdx Which button index changed
  41306. * @param state New state of the button
  41307. * @param changes Which properties on the state changed since last frame
  41308. */
  41309. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41310. }
  41311. }
  41312. declare module BABYLON {
  41313. /**
  41314. * Vive Controller
  41315. */
  41316. export class ViveController extends WebVRController {
  41317. /**
  41318. * Base Url for the controller model.
  41319. */
  41320. static MODEL_BASE_URL: string;
  41321. /**
  41322. * File name for the controller model.
  41323. */
  41324. static MODEL_FILENAME: string;
  41325. /**
  41326. * Creates a new ViveController from a gamepad
  41327. * @param vrGamepad the gamepad that the controller should be created from
  41328. */
  41329. constructor(vrGamepad: any);
  41330. /**
  41331. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41332. * @param scene scene in which to add meshes
  41333. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41334. */
  41335. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41336. /**
  41337. * Fired when the left button on this controller is modified
  41338. */
  41339. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41340. /**
  41341. * Fired when the right button on this controller is modified
  41342. */
  41343. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41344. /**
  41345. * Fired when the menu button on this controller is modified
  41346. */
  41347. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41348. /**
  41349. * Called once for each button that changed state since the last frame
  41350. * Vive mapping:
  41351. * 0: touchpad
  41352. * 1: trigger
  41353. * 2: left AND right buttons
  41354. * 3: menu button
  41355. * @param buttonIdx Which button index changed
  41356. * @param state New state of the button
  41357. * @param changes Which properties on the state changed since last frame
  41358. */
  41359. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41360. }
  41361. }
  41362. declare module BABYLON {
  41363. /**
  41364. * Defines the WindowsMotionController object that the state of the windows motion controller
  41365. */
  41366. export class WindowsMotionController extends WebVRController {
  41367. /**
  41368. * The base url used to load the left and right controller models
  41369. */
  41370. static MODEL_BASE_URL: string;
  41371. /**
  41372. * The name of the left controller model file
  41373. */
  41374. static MODEL_LEFT_FILENAME: string;
  41375. /**
  41376. * The name of the right controller model file
  41377. */
  41378. static MODEL_RIGHT_FILENAME: string;
  41379. /**
  41380. * The controller name prefix for this controller type
  41381. */
  41382. static readonly GAMEPAD_ID_PREFIX: string;
  41383. /**
  41384. * The controller id pattern for this controller type
  41385. */
  41386. private static readonly GAMEPAD_ID_PATTERN;
  41387. private _loadedMeshInfo;
  41388. private readonly _mapping;
  41389. /**
  41390. * Fired when the trackpad on this controller is clicked
  41391. */
  41392. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41393. /**
  41394. * Fired when the trackpad on this controller is modified
  41395. */
  41396. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41397. /**
  41398. * The current x and y values of this controller's trackpad
  41399. */
  41400. trackpad: StickValues;
  41401. /**
  41402. * Creates a new WindowsMotionController from a gamepad
  41403. * @param vrGamepad the gamepad that the controller should be created from
  41404. */
  41405. constructor(vrGamepad: any);
  41406. /**
  41407. * Fired when the trigger on this controller is modified
  41408. */
  41409. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41410. /**
  41411. * Fired when the menu button on this controller is modified
  41412. */
  41413. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41414. /**
  41415. * Fired when the grip button on this controller is modified
  41416. */
  41417. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41418. /**
  41419. * Fired when the thumbstick button on this controller is modified
  41420. */
  41421. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41422. /**
  41423. * Fired when the touchpad button on this controller is modified
  41424. */
  41425. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41426. /**
  41427. * Fired when the touchpad values on this controller are modified
  41428. */
  41429. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41430. private _updateTrackpad;
  41431. /**
  41432. * Called once per frame by the engine.
  41433. */
  41434. update(): void;
  41435. /**
  41436. * Called once for each button that changed state since the last frame
  41437. * @param buttonIdx Which button index changed
  41438. * @param state New state of the button
  41439. * @param changes Which properties on the state changed since last frame
  41440. */
  41441. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41442. /**
  41443. * Moves the buttons on the controller mesh based on their current state
  41444. * @param buttonName the name of the button to move
  41445. * @param buttonValue the value of the button which determines the buttons new position
  41446. */
  41447. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41448. /**
  41449. * Moves the axis on the controller mesh based on its current state
  41450. * @param axis the index of the axis
  41451. * @param axisValue the value of the axis which determines the meshes new position
  41452. * @hidden
  41453. */
  41454. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41455. /**
  41456. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41457. * @param scene scene in which to add meshes
  41458. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41459. */
  41460. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41461. /**
  41462. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41463. * can be transformed by button presses and axes values, based on this._mapping.
  41464. *
  41465. * @param scene scene in which the meshes exist
  41466. * @param meshes list of meshes that make up the controller model to process
  41467. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41468. */
  41469. private processModel;
  41470. private createMeshInfo;
  41471. /**
  41472. * Gets the ray of the controller in the direction the controller is pointing
  41473. * @param length the length the resulting ray should be
  41474. * @returns a ray in the direction the controller is pointing
  41475. */
  41476. getForwardRay(length?: number): Ray;
  41477. /**
  41478. * Disposes of the controller
  41479. */
  41480. dispose(): void;
  41481. }
  41482. }
  41483. declare module BABYLON {
  41484. /**
  41485. * Single axis scale gizmo
  41486. */
  41487. export class AxisScaleGizmo extends Gizmo {
  41488. private _coloredMaterial;
  41489. /**
  41490. * Drag behavior responsible for the gizmos dragging interactions
  41491. */
  41492. dragBehavior: PointerDragBehavior;
  41493. private _pointerObserver;
  41494. /**
  41495. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41496. */
  41497. snapDistance: number;
  41498. /**
  41499. * Event that fires each time the gizmo snaps to a new location.
  41500. * * snapDistance is the the change in distance
  41501. */
  41502. onSnapObservable: Observable<{
  41503. snapDistance: number;
  41504. }>;
  41505. /**
  41506. * If the scaling operation should be done on all axis (default: false)
  41507. */
  41508. uniformScaling: boolean;
  41509. /**
  41510. * Creates an AxisScaleGizmo
  41511. * @param gizmoLayer The utility layer the gizmo will be added to
  41512. * @param dragAxis The axis which the gizmo will be able to scale on
  41513. * @param color The color of the gizmo
  41514. */
  41515. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41516. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41517. /**
  41518. * Disposes of the gizmo
  41519. */
  41520. dispose(): void;
  41521. /**
  41522. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41523. * @param mesh The mesh to replace the default mesh of the gizmo
  41524. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41525. */
  41526. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41527. }
  41528. }
  41529. declare module BABYLON {
  41530. /**
  41531. * Bounding box gizmo
  41532. */
  41533. export class BoundingBoxGizmo extends Gizmo {
  41534. private _lineBoundingBox;
  41535. private _rotateSpheresParent;
  41536. private _scaleBoxesParent;
  41537. private _boundingDimensions;
  41538. private _renderObserver;
  41539. private _pointerObserver;
  41540. private _scaleDragSpeed;
  41541. private _tmpQuaternion;
  41542. private _tmpVector;
  41543. private _tmpRotationMatrix;
  41544. /**
  41545. * 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)
  41546. */
  41547. ignoreChildren: boolean;
  41548. /**
  41549. * 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)
  41550. */
  41551. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41552. /**
  41553. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41554. */
  41555. rotationSphereSize: number;
  41556. /**
  41557. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41558. */
  41559. scaleBoxSize: number;
  41560. /**
  41561. * 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)
  41562. */
  41563. fixedDragMeshScreenSize: boolean;
  41564. /**
  41565. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41566. */
  41567. fixedDragMeshScreenSizeDistanceFactor: number;
  41568. /**
  41569. * Fired when a rotation sphere or scale box is dragged
  41570. */
  41571. onDragStartObservable: Observable<{}>;
  41572. /**
  41573. * Fired when a scale box is dragged
  41574. */
  41575. onScaleBoxDragObservable: Observable<{}>;
  41576. /**
  41577. * Fired when a scale box drag is ended
  41578. */
  41579. onScaleBoxDragEndObservable: Observable<{}>;
  41580. /**
  41581. * Fired when a rotation sphere is dragged
  41582. */
  41583. onRotationSphereDragObservable: Observable<{}>;
  41584. /**
  41585. * Fired when a rotation sphere drag is ended
  41586. */
  41587. onRotationSphereDragEndObservable: Observable<{}>;
  41588. /**
  41589. * 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)
  41590. */
  41591. scalePivot: Nullable<Vector3>;
  41592. /**
  41593. * Mesh used as a pivot to rotate the attached mesh
  41594. */
  41595. private _anchorMesh;
  41596. private _existingMeshScale;
  41597. private _dragMesh;
  41598. private pointerDragBehavior;
  41599. private coloredMaterial;
  41600. private hoverColoredMaterial;
  41601. /**
  41602. * Sets the color of the bounding box gizmo
  41603. * @param color the color to set
  41604. */
  41605. setColor(color: Color3): void;
  41606. /**
  41607. * Creates an BoundingBoxGizmo
  41608. * @param gizmoLayer The utility layer the gizmo will be added to
  41609. * @param color The color of the gizmo
  41610. */
  41611. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41612. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41613. private _selectNode;
  41614. /**
  41615. * Updates the bounding box information for the Gizmo
  41616. */
  41617. updateBoundingBox(): void;
  41618. private _updateRotationSpheres;
  41619. private _updateScaleBoxes;
  41620. /**
  41621. * Enables rotation on the specified axis and disables rotation on the others
  41622. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41623. */
  41624. setEnabledRotationAxis(axis: string): void;
  41625. /**
  41626. * Enables/disables scaling
  41627. * @param enable if scaling should be enabled
  41628. */
  41629. setEnabledScaling(enable: boolean): void;
  41630. private _updateDummy;
  41631. /**
  41632. * Enables a pointer drag behavior on the bounding box of the gizmo
  41633. */
  41634. enableDragBehavior(): void;
  41635. /**
  41636. * Disposes of the gizmo
  41637. */
  41638. dispose(): void;
  41639. /**
  41640. * 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)
  41641. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41642. * @returns the bounding box mesh with the passed in mesh as a child
  41643. */
  41644. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41645. /**
  41646. * CustomMeshes are not supported by this gizmo
  41647. * @param mesh The mesh to replace the default mesh of the gizmo
  41648. */
  41649. setCustomMesh(mesh: Mesh): void;
  41650. }
  41651. }
  41652. declare module BABYLON {
  41653. /**
  41654. * Single plane rotation gizmo
  41655. */
  41656. export class PlaneRotationGizmo extends Gizmo {
  41657. /**
  41658. * Drag behavior responsible for the gizmos dragging interactions
  41659. */
  41660. dragBehavior: PointerDragBehavior;
  41661. private _pointerObserver;
  41662. /**
  41663. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41664. */
  41665. snapDistance: number;
  41666. /**
  41667. * Event that fires each time the gizmo snaps to a new location.
  41668. * * snapDistance is the the change in distance
  41669. */
  41670. onSnapObservable: Observable<{
  41671. snapDistance: number;
  41672. }>;
  41673. /**
  41674. * Creates a PlaneRotationGizmo
  41675. * @param gizmoLayer The utility layer the gizmo will be added to
  41676. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41677. * @param color The color of the gizmo
  41678. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41679. */
  41680. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41681. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41682. /**
  41683. * Disposes of the gizmo
  41684. */
  41685. dispose(): void;
  41686. }
  41687. }
  41688. declare module BABYLON {
  41689. /**
  41690. * Gizmo that enables rotating a mesh along 3 axis
  41691. */
  41692. export class RotationGizmo extends Gizmo {
  41693. /**
  41694. * Internal gizmo used for interactions on the x axis
  41695. */
  41696. xGizmo: PlaneRotationGizmo;
  41697. /**
  41698. * Internal gizmo used for interactions on the y axis
  41699. */
  41700. yGizmo: PlaneRotationGizmo;
  41701. /**
  41702. * Internal gizmo used for interactions on the z axis
  41703. */
  41704. zGizmo: PlaneRotationGizmo;
  41705. /** Fires an event when any of it's sub gizmos are dragged */
  41706. onDragStartObservable: Observable<{}>;
  41707. /** Fires an event when any of it's sub gizmos are released from dragging */
  41708. onDragEndObservable: Observable<{}>;
  41709. attachedMesh: Nullable<AbstractMesh>;
  41710. /**
  41711. * Creates a RotationGizmo
  41712. * @param gizmoLayer The utility layer the gizmo will be added to
  41713. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41714. */
  41715. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41716. updateGizmoRotationToMatchAttachedMesh: boolean;
  41717. /**
  41718. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41719. */
  41720. snapDistance: number;
  41721. /**
  41722. * Ratio for the scale of the gizmo (Default: 1)
  41723. */
  41724. scaleRatio: number;
  41725. /**
  41726. * Disposes of the gizmo
  41727. */
  41728. dispose(): void;
  41729. /**
  41730. * CustomMeshes are not supported by this gizmo
  41731. * @param mesh The mesh to replace the default mesh of the gizmo
  41732. */
  41733. setCustomMesh(mesh: Mesh): void;
  41734. }
  41735. }
  41736. declare module BABYLON {
  41737. /**
  41738. * Gizmo that enables dragging a mesh along 3 axis
  41739. */
  41740. export class PositionGizmo extends Gizmo {
  41741. /**
  41742. * Internal gizmo used for interactions on the x axis
  41743. */
  41744. xGizmo: AxisDragGizmo;
  41745. /**
  41746. * Internal gizmo used for interactions on the y axis
  41747. */
  41748. yGizmo: AxisDragGizmo;
  41749. /**
  41750. * Internal gizmo used for interactions on the z axis
  41751. */
  41752. zGizmo: AxisDragGizmo;
  41753. /** Fires an event when any of it's sub gizmos are dragged */
  41754. onDragStartObservable: Observable<{}>;
  41755. /** Fires an event when any of it's sub gizmos are released from dragging */
  41756. onDragEndObservable: Observable<{}>;
  41757. attachedMesh: Nullable<AbstractMesh>;
  41758. /**
  41759. * Creates a PositionGizmo
  41760. * @param gizmoLayer The utility layer the gizmo will be added to
  41761. */
  41762. constructor(gizmoLayer?: UtilityLayerRenderer);
  41763. updateGizmoRotationToMatchAttachedMesh: boolean;
  41764. /**
  41765. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41766. */
  41767. snapDistance: number;
  41768. /**
  41769. * Ratio for the scale of the gizmo (Default: 1)
  41770. */
  41771. scaleRatio: number;
  41772. /**
  41773. * Disposes of the gizmo
  41774. */
  41775. dispose(): void;
  41776. /**
  41777. * CustomMeshes are not supported by this gizmo
  41778. * @param mesh The mesh to replace the default mesh of the gizmo
  41779. */
  41780. setCustomMesh(mesh: Mesh): void;
  41781. }
  41782. }
  41783. declare module BABYLON {
  41784. /**
  41785. * Class containing static functions to help procedurally build meshes
  41786. */
  41787. export class PolyhedronBuilder {
  41788. /**
  41789. * Creates a polyhedron mesh
  41790. * * 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
  41791. * * The parameter `size` (positive float, default 1) sets the polygon size
  41792. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  41793. * * 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`
  41794. * * 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
  41795. * * 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)`)
  41796. * * 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
  41797. * * 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
  41798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41799. * * If you create a double-sided mesh, you can choose what parts of 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
  41800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41801. * @param name defines the name of the mesh
  41802. * @param options defines the options used to create the mesh
  41803. * @param scene defines the hosting scene
  41804. * @returns the polyhedron mesh
  41805. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  41806. */
  41807. static CreatePolyhedron(name: string, options: {
  41808. type?: number;
  41809. size?: number;
  41810. sizeX?: number;
  41811. sizeY?: number;
  41812. sizeZ?: number;
  41813. custom?: any;
  41814. faceUV?: Vector4[];
  41815. faceColors?: Color4[];
  41816. flat?: boolean;
  41817. updatable?: boolean;
  41818. sideOrientation?: number;
  41819. frontUVs?: Vector4;
  41820. backUVs?: Vector4;
  41821. }, scene?: Nullable<Scene>): Mesh;
  41822. }
  41823. }
  41824. declare module BABYLON {
  41825. /**
  41826. * Gizmo that enables scaling a mesh along 3 axis
  41827. */
  41828. export class ScaleGizmo extends Gizmo {
  41829. /**
  41830. * Internal gizmo used for interactions on the x axis
  41831. */
  41832. xGizmo: AxisScaleGizmo;
  41833. /**
  41834. * Internal gizmo used for interactions on the y axis
  41835. */
  41836. yGizmo: AxisScaleGizmo;
  41837. /**
  41838. * Internal gizmo used for interactions on the z axis
  41839. */
  41840. zGizmo: AxisScaleGizmo;
  41841. /**
  41842. * Internal gizmo used to scale all axis equally
  41843. */
  41844. uniformScaleGizmo: AxisScaleGizmo;
  41845. /** Fires an event when any of it's sub gizmos are dragged */
  41846. onDragStartObservable: Observable<{}>;
  41847. /** Fires an event when any of it's sub gizmos are released from dragging */
  41848. onDragEndObservable: Observable<{}>;
  41849. attachedMesh: Nullable<AbstractMesh>;
  41850. /**
  41851. * Creates a ScaleGizmo
  41852. * @param gizmoLayer The utility layer the gizmo will be added to
  41853. */
  41854. constructor(gizmoLayer?: UtilityLayerRenderer);
  41855. updateGizmoRotationToMatchAttachedMesh: boolean;
  41856. /**
  41857. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41858. */
  41859. snapDistance: number;
  41860. /**
  41861. * Ratio for the scale of the gizmo (Default: 1)
  41862. */
  41863. scaleRatio: number;
  41864. /**
  41865. * Disposes of the gizmo
  41866. */
  41867. dispose(): void;
  41868. }
  41869. }
  41870. declare module BABYLON {
  41871. /**
  41872. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  41873. */
  41874. export class GizmoManager implements IDisposable {
  41875. private scene;
  41876. /**
  41877. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  41878. */
  41879. gizmos: {
  41880. positionGizmo: Nullable<PositionGizmo>;
  41881. rotationGizmo: Nullable<RotationGizmo>;
  41882. scaleGizmo: Nullable<ScaleGizmo>;
  41883. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  41884. };
  41885. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  41886. clearGizmoOnEmptyPointerEvent: boolean;
  41887. /** Fires an event when the manager is attached to a mesh */
  41888. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  41889. private _gizmosEnabled;
  41890. private _pointerObserver;
  41891. private _attachedMesh;
  41892. private _boundingBoxColor;
  41893. private _defaultUtilityLayer;
  41894. private _defaultKeepDepthUtilityLayer;
  41895. /**
  41896. * When bounding box gizmo is enabled, this can be used to track drag/end events
  41897. */
  41898. boundingBoxDragBehavior: SixDofDragBehavior;
  41899. /**
  41900. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  41901. */
  41902. attachableMeshes: Nullable<Array<AbstractMesh>>;
  41903. /**
  41904. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  41905. */
  41906. usePointerToAttachGizmos: boolean;
  41907. /**
  41908. * Instatiates a gizmo manager
  41909. * @param scene the scene to overlay the gizmos on top of
  41910. */
  41911. constructor(scene: Scene);
  41912. /**
  41913. * Attaches a set of gizmos to the specified mesh
  41914. * @param mesh The mesh the gizmo's should be attached to
  41915. */
  41916. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  41917. /**
  41918. * If the position gizmo is enabled
  41919. */
  41920. positionGizmoEnabled: boolean;
  41921. /**
  41922. * If the rotation gizmo is enabled
  41923. */
  41924. rotationGizmoEnabled: boolean;
  41925. /**
  41926. * If the scale gizmo is enabled
  41927. */
  41928. scaleGizmoEnabled: boolean;
  41929. /**
  41930. * If the boundingBox gizmo is enabled
  41931. */
  41932. boundingBoxGizmoEnabled: boolean;
  41933. /**
  41934. * Disposes of the gizmo manager
  41935. */
  41936. dispose(): void;
  41937. }
  41938. }
  41939. declare module BABYLON {
  41940. /**
  41941. * A directional light is defined by a direction (what a surprise!).
  41942. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  41943. * 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.
  41944. * Documentation: https://doc.babylonjs.com/babylon101/lights
  41945. */
  41946. export class DirectionalLight extends ShadowLight {
  41947. private _shadowFrustumSize;
  41948. /**
  41949. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  41950. */
  41951. /**
  41952. * Specifies a fix frustum size for the shadow generation.
  41953. */
  41954. shadowFrustumSize: number;
  41955. private _shadowOrthoScale;
  41956. /**
  41957. * Gets the shadow projection scale against the optimal computed one.
  41958. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  41959. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  41960. */
  41961. /**
  41962. * Sets the shadow projection scale against the optimal computed one.
  41963. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  41964. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  41965. */
  41966. shadowOrthoScale: number;
  41967. /**
  41968. * Automatically compute the projection matrix to best fit (including all the casters)
  41969. * on each frame.
  41970. */
  41971. autoUpdateExtends: boolean;
  41972. private _orthoLeft;
  41973. private _orthoRight;
  41974. private _orthoTop;
  41975. private _orthoBottom;
  41976. /**
  41977. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  41978. * The directional light is emitted from everywhere in the given direction.
  41979. * It can cast shadows.
  41980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  41981. * @param name The friendly name of the light
  41982. * @param direction The direction of the light
  41983. * @param scene The scene the light belongs to
  41984. */
  41985. constructor(name: string, direction: Vector3, scene: Scene);
  41986. /**
  41987. * Returns the string "DirectionalLight".
  41988. * @return The class name
  41989. */
  41990. getClassName(): string;
  41991. /**
  41992. * Returns the integer 1.
  41993. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  41994. */
  41995. getTypeID(): number;
  41996. /**
  41997. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  41998. * Returns the DirectionalLight Shadow projection matrix.
  41999. */
  42000. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42001. /**
  42002. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42003. * Returns the DirectionalLight Shadow projection matrix.
  42004. */
  42005. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42006. /**
  42007. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42008. * Returns the DirectionalLight Shadow projection matrix.
  42009. */
  42010. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42011. protected _buildUniformLayout(): void;
  42012. /**
  42013. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42014. * @param effect The effect to update
  42015. * @param lightIndex The index of the light in the effect to update
  42016. * @returns The directional light
  42017. */
  42018. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42019. /**
  42020. * Gets the minZ used for shadow according to both the scene and the light.
  42021. *
  42022. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42023. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42024. * @param activeCamera The camera we are returning the min for
  42025. * @returns the depth min z
  42026. */
  42027. getDepthMinZ(activeCamera: Camera): number;
  42028. /**
  42029. * Gets the maxZ used for shadow according to both the scene and the light.
  42030. *
  42031. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42032. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42033. * @param activeCamera The camera we are returning the max for
  42034. * @returns the depth max z
  42035. */
  42036. getDepthMaxZ(activeCamera: Camera): number;
  42037. /**
  42038. * Prepares the list of defines specific to the light type.
  42039. * @param defines the list of defines
  42040. * @param lightIndex defines the index of the light for the effect
  42041. */
  42042. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42043. }
  42044. }
  42045. declare module BABYLON {
  42046. /**
  42047. * Class containing static functions to help procedurally build meshes
  42048. */
  42049. export class HemisphereBuilder {
  42050. /**
  42051. * Creates a hemisphere mesh
  42052. * @param name defines the name of the mesh
  42053. * @param options defines the options used to create the mesh
  42054. * @param scene defines the hosting scene
  42055. * @returns the hemisphere mesh
  42056. */
  42057. static CreateHemisphere(name: string, options: {
  42058. segments?: number;
  42059. diameter?: number;
  42060. sideOrientation?: number;
  42061. }, scene: any): Mesh;
  42062. }
  42063. }
  42064. declare module BABYLON {
  42065. /**
  42066. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42067. * These values define a cone of light starting from the position, emitting toward the direction.
  42068. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42069. * and the exponent defines the speed of the decay of the light with distance (reach).
  42070. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42071. */
  42072. export class SpotLight extends ShadowLight {
  42073. private _angle;
  42074. private _innerAngle;
  42075. private _cosHalfAngle;
  42076. private _lightAngleScale;
  42077. private _lightAngleOffset;
  42078. /**
  42079. * Gets the cone angle of the spot light in Radians.
  42080. */
  42081. /**
  42082. * Sets the cone angle of the spot light in Radians.
  42083. */
  42084. angle: number;
  42085. /**
  42086. * Only used in gltf falloff mode, this defines the angle where
  42087. * the directional falloff will start before cutting at angle which could be seen
  42088. * as outer angle.
  42089. */
  42090. /**
  42091. * Only used in gltf falloff mode, this defines the angle where
  42092. * the directional falloff will start before cutting at angle which could be seen
  42093. * as outer angle.
  42094. */
  42095. innerAngle: number;
  42096. private _shadowAngleScale;
  42097. /**
  42098. * Allows scaling the angle of the light for shadow generation only.
  42099. */
  42100. /**
  42101. * Allows scaling the angle of the light for shadow generation only.
  42102. */
  42103. shadowAngleScale: number;
  42104. /**
  42105. * The light decay speed with the distance from the emission spot.
  42106. */
  42107. exponent: number;
  42108. private _projectionTextureMatrix;
  42109. /**
  42110. * Allows reading the projecton texture
  42111. */
  42112. readonly projectionTextureMatrix: Matrix;
  42113. protected _projectionTextureLightNear: number;
  42114. /**
  42115. * Gets the near clip of the Spotlight for texture projection.
  42116. */
  42117. /**
  42118. * Sets the near clip of the Spotlight for texture projection.
  42119. */
  42120. projectionTextureLightNear: number;
  42121. protected _projectionTextureLightFar: number;
  42122. /**
  42123. * Gets the far clip of the Spotlight for texture projection.
  42124. */
  42125. /**
  42126. * Sets the far clip of the Spotlight for texture projection.
  42127. */
  42128. projectionTextureLightFar: number;
  42129. protected _projectionTextureUpDirection: Vector3;
  42130. /**
  42131. * Gets the Up vector of the Spotlight for texture projection.
  42132. */
  42133. /**
  42134. * Sets the Up vector of the Spotlight for texture projection.
  42135. */
  42136. projectionTextureUpDirection: Vector3;
  42137. private _projectionTexture;
  42138. /**
  42139. * Gets the projection texture of the light.
  42140. */
  42141. /**
  42142. * Sets the projection texture of the light.
  42143. */
  42144. projectionTexture: Nullable<BaseTexture>;
  42145. private _projectionTextureViewLightDirty;
  42146. private _projectionTextureProjectionLightDirty;
  42147. private _projectionTextureDirty;
  42148. private _projectionTextureViewTargetVector;
  42149. private _projectionTextureViewLightMatrix;
  42150. private _projectionTextureProjectionLightMatrix;
  42151. private _projectionTextureScalingMatrix;
  42152. /**
  42153. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42154. * It can cast shadows.
  42155. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42156. * @param name The light friendly name
  42157. * @param position The position of the spot light in the scene
  42158. * @param direction The direction of the light in the scene
  42159. * @param angle The cone angle of the light in Radians
  42160. * @param exponent The light decay speed with the distance from the emission spot
  42161. * @param scene The scene the lights belongs to
  42162. */
  42163. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42164. /**
  42165. * Returns the string "SpotLight".
  42166. * @returns the class name
  42167. */
  42168. getClassName(): string;
  42169. /**
  42170. * Returns the integer 2.
  42171. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42172. */
  42173. getTypeID(): number;
  42174. /**
  42175. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42176. */
  42177. protected _setDirection(value: Vector3): void;
  42178. /**
  42179. * Overrides the position setter to recompute the projection texture view light Matrix.
  42180. */
  42181. protected _setPosition(value: Vector3): void;
  42182. /**
  42183. * 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.
  42184. * Returns the SpotLight.
  42185. */
  42186. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42187. protected _computeProjectionTextureViewLightMatrix(): void;
  42188. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42189. /**
  42190. * Main function for light texture projection matrix computing.
  42191. */
  42192. protected _computeProjectionTextureMatrix(): void;
  42193. protected _buildUniformLayout(): void;
  42194. private _computeAngleValues;
  42195. /**
  42196. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42197. * @param effect The effect to update
  42198. * @param lightIndex The index of the light in the effect to update
  42199. * @returns The spot light
  42200. */
  42201. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42202. /**
  42203. * Disposes the light and the associated resources.
  42204. */
  42205. dispose(): void;
  42206. /**
  42207. * Prepares the list of defines specific to the light type.
  42208. * @param defines the list of defines
  42209. * @param lightIndex defines the index of the light for the effect
  42210. */
  42211. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42212. }
  42213. }
  42214. declare module BABYLON {
  42215. /**
  42216. * Gizmo that enables viewing a light
  42217. */
  42218. export class LightGizmo extends Gizmo {
  42219. private _lightMesh;
  42220. private _material;
  42221. /**
  42222. * Creates a LightGizmo
  42223. * @param gizmoLayer The utility layer the gizmo will be added to
  42224. */
  42225. constructor(gizmoLayer?: UtilityLayerRenderer);
  42226. private _light;
  42227. /**
  42228. * The light that the gizmo is attached to
  42229. */
  42230. light: Nullable<Light>;
  42231. /**
  42232. * @hidden
  42233. * Updates the gizmo to match the attached mesh's position/rotation
  42234. */
  42235. protected _update(): void;
  42236. private static _Scale;
  42237. /**
  42238. * Creates the lines for a light mesh
  42239. */
  42240. private static _createLightLines;
  42241. private static _CreateHemisphericLightMesh;
  42242. private static _CreatePointLightMesh;
  42243. private static _CreateSpotLightMesh;
  42244. private static _CreateDirectionalLightMesh;
  42245. }
  42246. }
  42247. declare module BABYLON {
  42248. /** @hidden */
  42249. export var backgroundFragmentDeclaration: {
  42250. name: string;
  42251. shader: string;
  42252. };
  42253. }
  42254. declare module BABYLON {
  42255. /** @hidden */
  42256. export var backgroundUboDeclaration: {
  42257. name: string;
  42258. shader: string;
  42259. };
  42260. }
  42261. declare module BABYLON {
  42262. /** @hidden */
  42263. export var backgroundPixelShader: {
  42264. name: string;
  42265. shader: string;
  42266. };
  42267. }
  42268. declare module BABYLON {
  42269. /** @hidden */
  42270. export var backgroundVertexDeclaration: {
  42271. name: string;
  42272. shader: string;
  42273. };
  42274. }
  42275. declare module BABYLON {
  42276. /** @hidden */
  42277. export var backgroundVertexShader: {
  42278. name: string;
  42279. shader: string;
  42280. };
  42281. }
  42282. declare module BABYLON {
  42283. /**
  42284. * Background material used to create an efficient environement around your scene.
  42285. */
  42286. export class BackgroundMaterial extends PushMaterial {
  42287. /**
  42288. * Standard reflectance value at parallel view angle.
  42289. */
  42290. static StandardReflectance0: number;
  42291. /**
  42292. * Standard reflectance value at grazing angle.
  42293. */
  42294. static StandardReflectance90: number;
  42295. protected _primaryColor: Color3;
  42296. /**
  42297. * Key light Color (multiply against the environement texture)
  42298. */
  42299. primaryColor: Color3;
  42300. protected __perceptualColor: Nullable<Color3>;
  42301. /**
  42302. * Experimental Internal Use Only.
  42303. *
  42304. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42305. * This acts as a helper to set the primary color to a more "human friendly" value.
  42306. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42307. * output color as close as possible from the chosen value.
  42308. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42309. * part of lighting setup.)
  42310. */ perceptualColor: Nullable<Color3>;
  42311. protected _primaryColorShadowLevel: float;
  42312. /**
  42313. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42314. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42315. */
  42316. primaryColorShadowLevel: float;
  42317. protected _primaryColorHighlightLevel: float;
  42318. /**
  42319. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42320. * The primary color is used at the level chosen to define what the white area would look.
  42321. */
  42322. primaryColorHighlightLevel: float;
  42323. protected _reflectionTexture: Nullable<BaseTexture>;
  42324. /**
  42325. * Reflection Texture used in the material.
  42326. * Should be author in a specific way for the best result (refer to the documentation).
  42327. */
  42328. reflectionTexture: Nullable<BaseTexture>;
  42329. protected _reflectionBlur: float;
  42330. /**
  42331. * Reflection Texture level of blur.
  42332. *
  42333. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42334. * texture twice.
  42335. */
  42336. reflectionBlur: float;
  42337. protected _diffuseTexture: Nullable<BaseTexture>;
  42338. /**
  42339. * Diffuse Texture used in the material.
  42340. * Should be author in a specific way for the best result (refer to the documentation).
  42341. */
  42342. diffuseTexture: Nullable<BaseTexture>;
  42343. protected _shadowLights: Nullable<IShadowLight[]>;
  42344. /**
  42345. * Specify the list of lights casting shadow on the material.
  42346. * All scene shadow lights will be included if null.
  42347. */
  42348. shadowLights: Nullable<IShadowLight[]>;
  42349. protected _shadowLevel: float;
  42350. /**
  42351. * Helps adjusting the shadow to a softer level if required.
  42352. * 0 means black shadows and 1 means no shadows.
  42353. */
  42354. shadowLevel: float;
  42355. protected _sceneCenter: Vector3;
  42356. /**
  42357. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42358. * It is usually zero but might be interesting to modify according to your setup.
  42359. */
  42360. sceneCenter: Vector3;
  42361. protected _opacityFresnel: boolean;
  42362. /**
  42363. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42364. * This helps ensuring a nice transition when the camera goes under the ground.
  42365. */
  42366. opacityFresnel: boolean;
  42367. protected _reflectionFresnel: boolean;
  42368. /**
  42369. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42370. * This helps adding a mirror texture on the ground.
  42371. */
  42372. reflectionFresnel: boolean;
  42373. protected _reflectionFalloffDistance: number;
  42374. /**
  42375. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42376. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42377. */
  42378. reflectionFalloffDistance: number;
  42379. protected _reflectionAmount: number;
  42380. /**
  42381. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42382. */
  42383. reflectionAmount: number;
  42384. protected _reflectionReflectance0: number;
  42385. /**
  42386. * This specifies the weight of the reflection at grazing angle.
  42387. */
  42388. reflectionReflectance0: number;
  42389. protected _reflectionReflectance90: number;
  42390. /**
  42391. * This specifies the weight of the reflection at a perpendicular point of view.
  42392. */
  42393. reflectionReflectance90: number;
  42394. /**
  42395. * Sets the reflection reflectance fresnel values according to the default standard
  42396. * empirically know to work well :-)
  42397. */
  42398. reflectionStandardFresnelWeight: number;
  42399. protected _useRGBColor: boolean;
  42400. /**
  42401. * Helps to directly use the maps channels instead of their level.
  42402. */
  42403. useRGBColor: boolean;
  42404. protected _enableNoise: boolean;
  42405. /**
  42406. * This helps reducing the banding effect that could occur on the background.
  42407. */
  42408. enableNoise: boolean;
  42409. /**
  42410. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42411. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42412. * Recommended to be keep at 1.0 except for special cases.
  42413. */
  42414. fovMultiplier: number;
  42415. private _fovMultiplier;
  42416. /**
  42417. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42418. */
  42419. useEquirectangularFOV: boolean;
  42420. private _maxSimultaneousLights;
  42421. /**
  42422. * Number of Simultaneous lights allowed on the material.
  42423. */
  42424. maxSimultaneousLights: int;
  42425. /**
  42426. * Default configuration related to image processing available in the Background Material.
  42427. */
  42428. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42429. /**
  42430. * Keep track of the image processing observer to allow dispose and replace.
  42431. */
  42432. private _imageProcessingObserver;
  42433. /**
  42434. * Attaches a new image processing configuration to the PBR Material.
  42435. * @param configuration (if null the scene configuration will be use)
  42436. */
  42437. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42438. /**
  42439. * Gets the image processing configuration used either in this material.
  42440. */
  42441. /**
  42442. * Sets the Default image processing configuration used either in the this material.
  42443. *
  42444. * If sets to null, the scene one is in use.
  42445. */
  42446. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42447. /**
  42448. * Gets wether the color curves effect is enabled.
  42449. */
  42450. /**
  42451. * Sets wether the color curves effect is enabled.
  42452. */
  42453. cameraColorCurvesEnabled: boolean;
  42454. /**
  42455. * Gets wether the color grading effect is enabled.
  42456. */
  42457. /**
  42458. * Gets wether the color grading effect is enabled.
  42459. */
  42460. cameraColorGradingEnabled: boolean;
  42461. /**
  42462. * Gets wether tonemapping is enabled or not.
  42463. */
  42464. /**
  42465. * Sets wether tonemapping is enabled or not
  42466. */
  42467. cameraToneMappingEnabled: boolean;
  42468. /**
  42469. * The camera exposure used on this material.
  42470. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42471. * This corresponds to a photographic exposure.
  42472. */
  42473. /**
  42474. * The camera exposure used on this material.
  42475. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42476. * This corresponds to a photographic exposure.
  42477. */
  42478. cameraExposure: float;
  42479. /**
  42480. * Gets The camera contrast used on this material.
  42481. */
  42482. /**
  42483. * Sets The camera contrast used on this material.
  42484. */
  42485. cameraContrast: float;
  42486. /**
  42487. * Gets the Color Grading 2D Lookup Texture.
  42488. */
  42489. /**
  42490. * Sets the Color Grading 2D Lookup Texture.
  42491. */
  42492. cameraColorGradingTexture: Nullable<BaseTexture>;
  42493. /**
  42494. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42495. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42496. * 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;
  42497. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42498. */
  42499. /**
  42500. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42501. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42502. * 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;
  42503. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42504. */
  42505. cameraColorCurves: Nullable<ColorCurves>;
  42506. /**
  42507. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42508. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42509. */
  42510. switchToBGR: boolean;
  42511. private _renderTargets;
  42512. private _reflectionControls;
  42513. private _white;
  42514. private _primaryShadowColor;
  42515. private _primaryHighlightColor;
  42516. /**
  42517. * Instantiates a Background Material in the given scene
  42518. * @param name The friendly name of the material
  42519. * @param scene The scene to add the material to
  42520. */
  42521. constructor(name: string, scene: Scene);
  42522. /**
  42523. * Gets a boolean indicating that current material needs to register RTT
  42524. */
  42525. readonly hasRenderTargetTextures: boolean;
  42526. /**
  42527. * The entire material has been created in order to prevent overdraw.
  42528. * @returns false
  42529. */
  42530. needAlphaTesting(): boolean;
  42531. /**
  42532. * The entire material has been created in order to prevent overdraw.
  42533. * @returns true if blending is enable
  42534. */
  42535. needAlphaBlending(): boolean;
  42536. /**
  42537. * Checks wether the material is ready to be rendered for a given mesh.
  42538. * @param mesh The mesh to render
  42539. * @param subMesh The submesh to check against
  42540. * @param useInstances Specify wether or not the material is used with instances
  42541. * @returns true if all the dependencies are ready (Textures, Effects...)
  42542. */
  42543. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42544. /**
  42545. * Compute the primary color according to the chosen perceptual color.
  42546. */
  42547. private _computePrimaryColorFromPerceptualColor;
  42548. /**
  42549. * Compute the highlights and shadow colors according to their chosen levels.
  42550. */
  42551. private _computePrimaryColors;
  42552. /**
  42553. * Build the uniform buffer used in the material.
  42554. */
  42555. buildUniformLayout(): void;
  42556. /**
  42557. * Unbind the material.
  42558. */
  42559. unbind(): void;
  42560. /**
  42561. * Bind only the world matrix to the material.
  42562. * @param world The world matrix to bind.
  42563. */
  42564. bindOnlyWorldMatrix(world: Matrix): void;
  42565. /**
  42566. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42567. * @param world The world matrix to bind.
  42568. * @param subMesh The submesh to bind for.
  42569. */
  42570. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42571. /**
  42572. * Dispose the material.
  42573. * @param forceDisposeEffect Force disposal of the associated effect.
  42574. * @param forceDisposeTextures Force disposal of the associated textures.
  42575. */
  42576. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42577. /**
  42578. * Clones the material.
  42579. * @param name The cloned name.
  42580. * @returns The cloned material.
  42581. */
  42582. clone(name: string): BackgroundMaterial;
  42583. /**
  42584. * Serializes the current material to its JSON representation.
  42585. * @returns The JSON representation.
  42586. */
  42587. serialize(): any;
  42588. /**
  42589. * Gets the class name of the material
  42590. * @returns "BackgroundMaterial"
  42591. */
  42592. getClassName(): string;
  42593. /**
  42594. * Parse a JSON input to create back a background material.
  42595. * @param source The JSON data to parse
  42596. * @param scene The scene to create the parsed material in
  42597. * @param rootUrl The root url of the assets the material depends upon
  42598. * @returns the instantiated BackgroundMaterial.
  42599. */
  42600. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42601. }
  42602. }
  42603. declare module BABYLON {
  42604. /**
  42605. * Represents the different options available during the creation of
  42606. * a Environment helper.
  42607. *
  42608. * This can control the default ground, skybox and image processing setup of your scene.
  42609. */
  42610. export interface IEnvironmentHelperOptions {
  42611. /**
  42612. * Specifies wether or not to create a ground.
  42613. * True by default.
  42614. */
  42615. createGround: boolean;
  42616. /**
  42617. * Specifies the ground size.
  42618. * 15 by default.
  42619. */
  42620. groundSize: number;
  42621. /**
  42622. * The texture used on the ground for the main color.
  42623. * Comes from the BabylonJS CDN by default.
  42624. *
  42625. * Remarks: Can be either a texture or a url.
  42626. */
  42627. groundTexture: string | BaseTexture;
  42628. /**
  42629. * The color mixed in the ground texture by default.
  42630. * BabylonJS clearColor by default.
  42631. */
  42632. groundColor: Color3;
  42633. /**
  42634. * Specifies the ground opacity.
  42635. * 1 by default.
  42636. */
  42637. groundOpacity: number;
  42638. /**
  42639. * Enables the ground to receive shadows.
  42640. * True by default.
  42641. */
  42642. enableGroundShadow: boolean;
  42643. /**
  42644. * Helps preventing the shadow to be fully black on the ground.
  42645. * 0.5 by default.
  42646. */
  42647. groundShadowLevel: number;
  42648. /**
  42649. * Creates a mirror texture attach to the ground.
  42650. * false by default.
  42651. */
  42652. enableGroundMirror: boolean;
  42653. /**
  42654. * Specifies the ground mirror size ratio.
  42655. * 0.3 by default as the default kernel is 64.
  42656. */
  42657. groundMirrorSizeRatio: number;
  42658. /**
  42659. * Specifies the ground mirror blur kernel size.
  42660. * 64 by default.
  42661. */
  42662. groundMirrorBlurKernel: number;
  42663. /**
  42664. * Specifies the ground mirror visibility amount.
  42665. * 1 by default
  42666. */
  42667. groundMirrorAmount: number;
  42668. /**
  42669. * Specifies the ground mirror reflectance weight.
  42670. * This uses the standard weight of the background material to setup the fresnel effect
  42671. * of the mirror.
  42672. * 1 by default.
  42673. */
  42674. groundMirrorFresnelWeight: number;
  42675. /**
  42676. * Specifies the ground mirror Falloff distance.
  42677. * This can helps reducing the size of the reflection.
  42678. * 0 by Default.
  42679. */
  42680. groundMirrorFallOffDistance: number;
  42681. /**
  42682. * Specifies the ground mirror texture type.
  42683. * Unsigned Int by Default.
  42684. */
  42685. groundMirrorTextureType: number;
  42686. /**
  42687. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42688. * the shown objects.
  42689. */
  42690. groundYBias: number;
  42691. /**
  42692. * Specifies wether or not to create a skybox.
  42693. * True by default.
  42694. */
  42695. createSkybox: boolean;
  42696. /**
  42697. * Specifies the skybox size.
  42698. * 20 by default.
  42699. */
  42700. skyboxSize: number;
  42701. /**
  42702. * The texture used on the skybox for the main color.
  42703. * Comes from the BabylonJS CDN by default.
  42704. *
  42705. * Remarks: Can be either a texture or a url.
  42706. */
  42707. skyboxTexture: string | BaseTexture;
  42708. /**
  42709. * The color mixed in the skybox texture by default.
  42710. * BabylonJS clearColor by default.
  42711. */
  42712. skyboxColor: Color3;
  42713. /**
  42714. * The background rotation around the Y axis of the scene.
  42715. * This helps aligning the key lights of your scene with the background.
  42716. * 0 by default.
  42717. */
  42718. backgroundYRotation: number;
  42719. /**
  42720. * Compute automatically the size of the elements to best fit with the scene.
  42721. */
  42722. sizeAuto: boolean;
  42723. /**
  42724. * Default position of the rootMesh if autoSize is not true.
  42725. */
  42726. rootPosition: Vector3;
  42727. /**
  42728. * Sets up the image processing in the scene.
  42729. * true by default.
  42730. */
  42731. setupImageProcessing: boolean;
  42732. /**
  42733. * The texture used as your environment texture in the scene.
  42734. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  42735. *
  42736. * Remarks: Can be either a texture or a url.
  42737. */
  42738. environmentTexture: string | BaseTexture;
  42739. /**
  42740. * The value of the exposure to apply to the scene.
  42741. * 0.6 by default if setupImageProcessing is true.
  42742. */
  42743. cameraExposure: number;
  42744. /**
  42745. * The value of the contrast to apply to the scene.
  42746. * 1.6 by default if setupImageProcessing is true.
  42747. */
  42748. cameraContrast: number;
  42749. /**
  42750. * Specifies wether or not tonemapping should be enabled in the scene.
  42751. * true by default if setupImageProcessing is true.
  42752. */
  42753. toneMappingEnabled: boolean;
  42754. }
  42755. /**
  42756. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42757. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42758. * It also helps with the default setup of your imageProcessing configuration.
  42759. */
  42760. export class EnvironmentHelper {
  42761. /**
  42762. * Default ground texture URL.
  42763. */
  42764. private static _groundTextureCDNUrl;
  42765. /**
  42766. * Default skybox texture URL.
  42767. */
  42768. private static _skyboxTextureCDNUrl;
  42769. /**
  42770. * Default environment texture URL.
  42771. */
  42772. private static _environmentTextureCDNUrl;
  42773. /**
  42774. * Creates the default options for the helper.
  42775. */
  42776. private static _getDefaultOptions;
  42777. private _rootMesh;
  42778. /**
  42779. * Gets the root mesh created by the helper.
  42780. */
  42781. readonly rootMesh: Mesh;
  42782. private _skybox;
  42783. /**
  42784. * Gets the skybox created by the helper.
  42785. */
  42786. readonly skybox: Nullable<Mesh>;
  42787. private _skyboxTexture;
  42788. /**
  42789. * Gets the skybox texture created by the helper.
  42790. */
  42791. readonly skyboxTexture: Nullable<BaseTexture>;
  42792. private _skyboxMaterial;
  42793. /**
  42794. * Gets the skybox material created by the helper.
  42795. */
  42796. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  42797. private _ground;
  42798. /**
  42799. * Gets the ground mesh created by the helper.
  42800. */
  42801. readonly ground: Nullable<Mesh>;
  42802. private _groundTexture;
  42803. /**
  42804. * Gets the ground texture created by the helper.
  42805. */
  42806. readonly groundTexture: Nullable<BaseTexture>;
  42807. private _groundMirror;
  42808. /**
  42809. * Gets the ground mirror created by the helper.
  42810. */
  42811. readonly groundMirror: Nullable<MirrorTexture>;
  42812. /**
  42813. * Gets the ground mirror render list to helps pushing the meshes
  42814. * you wish in the ground reflection.
  42815. */
  42816. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  42817. private _groundMaterial;
  42818. /**
  42819. * Gets the ground material created by the helper.
  42820. */
  42821. readonly groundMaterial: Nullable<BackgroundMaterial>;
  42822. /**
  42823. * Stores the creation options.
  42824. */
  42825. private readonly _scene;
  42826. private _options;
  42827. /**
  42828. * This observable will be notified with any error during the creation of the environment,
  42829. * mainly texture creation errors.
  42830. */
  42831. onErrorObservable: Observable<{
  42832. message?: string;
  42833. exception?: any;
  42834. }>;
  42835. /**
  42836. * constructor
  42837. * @param options Defines the options we want to customize the helper
  42838. * @param scene The scene to add the material to
  42839. */
  42840. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  42841. /**
  42842. * Updates the background according to the new options
  42843. * @param options
  42844. */
  42845. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  42846. /**
  42847. * Sets the primary color of all the available elements.
  42848. * @param color the main color to affect to the ground and the background
  42849. */
  42850. setMainColor(color: Color3): void;
  42851. /**
  42852. * Setup the image processing according to the specified options.
  42853. */
  42854. private _setupImageProcessing;
  42855. /**
  42856. * Setup the environment texture according to the specified options.
  42857. */
  42858. private _setupEnvironmentTexture;
  42859. /**
  42860. * Setup the background according to the specified options.
  42861. */
  42862. private _setupBackground;
  42863. /**
  42864. * Get the scene sizes according to the setup.
  42865. */
  42866. private _getSceneSize;
  42867. /**
  42868. * Setup the ground according to the specified options.
  42869. */
  42870. private _setupGround;
  42871. /**
  42872. * Setup the ground material according to the specified options.
  42873. */
  42874. private _setupGroundMaterial;
  42875. /**
  42876. * Setup the ground diffuse texture according to the specified options.
  42877. */
  42878. private _setupGroundDiffuseTexture;
  42879. /**
  42880. * Setup the ground mirror texture according to the specified options.
  42881. */
  42882. private _setupGroundMirrorTexture;
  42883. /**
  42884. * Setup the ground to receive the mirror texture.
  42885. */
  42886. private _setupMirrorInGroundMaterial;
  42887. /**
  42888. * Setup the skybox according to the specified options.
  42889. */
  42890. private _setupSkybox;
  42891. /**
  42892. * Setup the skybox material according to the specified options.
  42893. */
  42894. private _setupSkyboxMaterial;
  42895. /**
  42896. * Setup the skybox reflection texture according to the specified options.
  42897. */
  42898. private _setupSkyboxReflectionTexture;
  42899. private _errorHandler;
  42900. /**
  42901. * Dispose all the elements created by the Helper.
  42902. */
  42903. dispose(): void;
  42904. }
  42905. }
  42906. declare module BABYLON {
  42907. /**
  42908. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  42909. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  42910. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  42911. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42912. */
  42913. export class PhotoDome extends TransformNode {
  42914. private _useDirectMapping;
  42915. /**
  42916. * The texture being displayed on the sphere
  42917. */
  42918. protected _photoTexture: Texture;
  42919. /**
  42920. * Gets or sets the texture being displayed on the sphere
  42921. */
  42922. photoTexture: Texture;
  42923. /**
  42924. * Observable raised when an error occured while loading the 360 image
  42925. */
  42926. onLoadErrorObservable: Observable<string>;
  42927. /**
  42928. * The skybox material
  42929. */
  42930. protected _material: BackgroundMaterial;
  42931. /**
  42932. * The surface used for the skybox
  42933. */
  42934. protected _mesh: Mesh;
  42935. /**
  42936. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42937. * Also see the options.resolution property.
  42938. */
  42939. fovMultiplier: number;
  42940. /**
  42941. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  42942. * @param name Element's name, child elements will append suffixes for their own names.
  42943. * @param urlsOfPhoto defines the url of the photo to display
  42944. * @param options defines an object containing optional or exposed sub element properties
  42945. * @param onError defines a callback called when an error occured while loading the texture
  42946. */
  42947. constructor(name: string, urlOfPhoto: string, options: {
  42948. resolution?: number;
  42949. size?: number;
  42950. useDirectMapping?: boolean;
  42951. faceForward?: boolean;
  42952. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  42953. /**
  42954. * Releases resources associated with this node.
  42955. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42956. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42957. */
  42958. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42959. }
  42960. }
  42961. declare module BABYLON {
  42962. /** @hidden */
  42963. export var rgbdDecodePixelShader: {
  42964. name: string;
  42965. shader: string;
  42966. };
  42967. }
  42968. declare module BABYLON {
  42969. /**
  42970. * Class used to host texture specific utilities
  42971. */
  42972. export class BRDFTextureTools {
  42973. /**
  42974. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  42975. * @param texture the texture to expand.
  42976. */
  42977. private static _ExpandDefaultBRDFTexture;
  42978. /**
  42979. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  42980. * @param scene defines the hosting scene
  42981. * @returns the environment BRDF texture
  42982. */
  42983. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  42984. private static _environmentBRDFBase64Texture;
  42985. }
  42986. }
  42987. declare module BABYLON {
  42988. /**
  42989. * @hidden
  42990. */
  42991. export interface IMaterialClearCoatDefines {
  42992. CLEARCOAT: boolean;
  42993. CLEARCOAT_DEFAULTIOR: boolean;
  42994. CLEARCOAT_TEXTURE: boolean;
  42995. CLEARCOAT_TEXTUREDIRECTUV: number;
  42996. CLEARCOAT_BUMP: boolean;
  42997. CLEARCOAT_BUMPDIRECTUV: number;
  42998. CLEARCOAT_TINT: boolean;
  42999. CLEARCOAT_TINT_TEXTURE: boolean;
  43000. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43001. /** @hidden */ areTexturesDirty: boolean;
  43002. }
  43003. /**
  43004. * Define the code related to the clear coat parameters of the pbr material.
  43005. */
  43006. export class PBRClearCoatConfiguration {
  43007. /**
  43008. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43009. * The default fits with a polyurethane material.
  43010. */
  43011. private static readonly _DefaultIndiceOfRefraction;
  43012. private _isEnabled;
  43013. /**
  43014. * Defines if the clear coat is enabled in the material.
  43015. */
  43016. isEnabled: boolean;
  43017. /**
  43018. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43019. */
  43020. intensity: number;
  43021. /**
  43022. * Defines the clear coat layer roughness.
  43023. */
  43024. roughness: number;
  43025. private _indiceOfRefraction;
  43026. /**
  43027. * Defines the indice of refraction of the clear coat.
  43028. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43029. * The default fits with a polyurethane material.
  43030. * Changing the default value is more performance intensive.
  43031. */
  43032. indiceOfRefraction: number;
  43033. private _texture;
  43034. /**
  43035. * Stores the clear coat values in a texture.
  43036. */
  43037. texture: Nullable<BaseTexture>;
  43038. private _bumpTexture;
  43039. /**
  43040. * Define the clear coat specific bump texture.
  43041. */
  43042. bumpTexture: Nullable<BaseTexture>;
  43043. private _isTintEnabled;
  43044. /**
  43045. * Defines if the clear coat tint is enabled in the material.
  43046. */
  43047. isTintEnabled: boolean;
  43048. /**
  43049. * Defines the clear coat tint of the material.
  43050. * This is only use if tint is enabled
  43051. */
  43052. tintColor: Color3;
  43053. /**
  43054. * Defines the distance at which the tint color should be found in the
  43055. * clear coat media.
  43056. * This is only use if tint is enabled
  43057. */
  43058. tintColorAtDistance: number;
  43059. /**
  43060. * Defines the clear coat layer thickness.
  43061. * This is only use if tint is enabled
  43062. */
  43063. tintThickness: number;
  43064. private _tintTexture;
  43065. /**
  43066. * Stores the clear tint values in a texture.
  43067. * rgb is tint
  43068. * a is a thickness factor
  43069. */
  43070. tintTexture: Nullable<BaseTexture>;
  43071. /** @hidden */
  43072. private _internalMarkAllSubMeshesAsTexturesDirty;
  43073. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43074. /**
  43075. * Instantiate a new istance of clear coat configuration.
  43076. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43077. */
  43078. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43079. /**
  43080. * Gets wehter the submesh is ready to be used or not.
  43081. * @param defines the list of "defines" to update.
  43082. * @param scene defines the scene the material belongs to.
  43083. * @param engine defines the engine the material belongs to.
  43084. * @param disableBumpMap defines wether the material disables bump or not.
  43085. * @returns - boolean indicating that the submesh is ready or not.
  43086. */
  43087. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43088. /**
  43089. * Checks to see if a texture is used in the material.
  43090. * @param defines the list of "defines" to update.
  43091. * @param scene defines the scene to the material belongs to.
  43092. */
  43093. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43094. /**
  43095. * Binds the material data.
  43096. * @param uniformBuffer defines the Uniform buffer to fill in.
  43097. * @param scene defines the scene the material belongs to.
  43098. * @param engine defines the engine the material belongs to.
  43099. * @param disableBumpMap defines wether the material disables bump or not.
  43100. * @param isFrozen defines wether the material is frozen or not.
  43101. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43102. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43103. */
  43104. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43105. /**
  43106. * Checks to see if a texture is used in the material.
  43107. * @param texture - Base texture to use.
  43108. * @returns - Boolean specifying if a texture is used in the material.
  43109. */
  43110. hasTexture(texture: BaseTexture): boolean;
  43111. /**
  43112. * Returns an array of the actively used textures.
  43113. * @param activeTextures Array of BaseTextures
  43114. */
  43115. getActiveTextures(activeTextures: BaseTexture[]): void;
  43116. /**
  43117. * Returns the animatable textures.
  43118. * @param animatables Array of animatable textures.
  43119. */
  43120. getAnimatables(animatables: IAnimatable[]): void;
  43121. /**
  43122. * Disposes the resources of the material.
  43123. * @param forceDisposeTextures - Forces the disposal of all textures.
  43124. */
  43125. dispose(forceDisposeTextures?: boolean): void;
  43126. /**
  43127. * Get the current class name of the texture useful for serialization or dynamic coding.
  43128. * @returns "PBRClearCoatConfiguration"
  43129. */
  43130. getClassName(): string;
  43131. /**
  43132. * Add fallbacks to the effect fallbacks list.
  43133. * @param defines defines the Base texture to use.
  43134. * @param fallbacks defines the current fallback list.
  43135. * @param currentRank defines the current fallback rank.
  43136. * @returns the new fallback rank.
  43137. */
  43138. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43139. /**
  43140. * Add the required uniforms to the current list.
  43141. * @param uniforms defines the current uniform list.
  43142. */
  43143. static AddUniforms(uniforms: string[]): void;
  43144. /**
  43145. * Add the required samplers to the current list.
  43146. * @param samplers defines the current sampler list.
  43147. */
  43148. static AddSamplers(samplers: string[]): void;
  43149. /**
  43150. * Add the required uniforms to the current buffer.
  43151. * @param uniformBuffer defines the current uniform buffer.
  43152. */
  43153. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43154. /**
  43155. * Makes a duplicate of the current configuration into another one.
  43156. * @param clearCoatConfiguration define the config where to copy the info
  43157. */
  43158. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43159. /**
  43160. * Serializes this clear coat configuration.
  43161. * @returns - An object with the serialized config.
  43162. */
  43163. serialize(): any;
  43164. /**
  43165. * Parses a Clear Coat Configuration from a serialized object.
  43166. * @param source - Serialized object.
  43167. */
  43168. parse(source: any): void;
  43169. }
  43170. }
  43171. declare module BABYLON {
  43172. /**
  43173. * @hidden
  43174. */
  43175. export interface IMaterialAnisotropicDefines {
  43176. ANISOTROPIC: boolean;
  43177. ANISOTROPIC_TEXTURE: boolean;
  43178. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43179. MAINUV1: boolean; areTexturesDirty: boolean; needUVs: boolean;
  43180. }
  43181. /**
  43182. * Define the code related to the anisotropic parameters of the pbr material.
  43183. */
  43184. export class PBRAnisotropicConfiguration {
  43185. private _isEnabled;
  43186. /**
  43187. * Defines if the anisotropy is enabled in the material.
  43188. */
  43189. isEnabled: boolean;
  43190. /**
  43191. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43192. */
  43193. intensity: number;
  43194. /**
  43195. * Defines if the effect is along the tangents, bitangents or in between.
  43196. * By default, the effect is "strectching" the highlights along the tangents.
  43197. */
  43198. direction: Vector2;
  43199. private _texture;
  43200. /**
  43201. * Stores the anisotropy values in a texture.
  43202. * rg is direction (like normal from -1 to 1)
  43203. * b is a intensity
  43204. */
  43205. texture: Nullable<BaseTexture>;
  43206. /** @hidden */
  43207. private _internalMarkAllSubMeshesAsTexturesDirty;
  43208. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43209. /**
  43210. * Instantiate a new istance of anisotropy configuration.
  43211. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43212. */
  43213. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43214. /**
  43215. * Specifies that the submesh is ready to be used.
  43216. * @param defines the list of "defines" to update.
  43217. * @param scene defines the scene the material belongs to.
  43218. * @returns - boolean indicating that the submesh is ready or not.
  43219. */
  43220. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43221. /**
  43222. * Checks to see if a texture is used in the material.
  43223. * @param defines the list of "defines" to update.
  43224. * @param mesh the mesh we are preparing the defines for.
  43225. * @param scene defines the scene the material belongs to.
  43226. */
  43227. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43228. /**
  43229. * Binds the material data.
  43230. * @param uniformBuffer defines the Uniform buffer to fill in.
  43231. * @param scene defines the scene the material belongs to.
  43232. * @param isFrozen defines wether the material is frozen or not.
  43233. */
  43234. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43235. /**
  43236. * Checks to see if a texture is used in the material.
  43237. * @param texture - Base texture to use.
  43238. * @returns - Boolean specifying if a texture is used in the material.
  43239. */
  43240. hasTexture(texture: BaseTexture): boolean;
  43241. /**
  43242. * Returns an array of the actively used textures.
  43243. * @param activeTextures Array of BaseTextures
  43244. */
  43245. getActiveTextures(activeTextures: BaseTexture[]): void;
  43246. /**
  43247. * Returns the animatable textures.
  43248. * @param animatables Array of animatable textures.
  43249. */
  43250. getAnimatables(animatables: IAnimatable[]): void;
  43251. /**
  43252. * Disposes the resources of the material.
  43253. * @param forceDisposeTextures - Forces the disposal of all textures.
  43254. */
  43255. dispose(forceDisposeTextures?: boolean): void;
  43256. /**
  43257. * Get the current class name of the texture useful for serialization or dynamic coding.
  43258. * @returns "PBRAnisotropicConfiguration"
  43259. */
  43260. getClassName(): string;
  43261. /**
  43262. * Add fallbacks to the effect fallbacks list.
  43263. * @param defines defines the Base texture to use.
  43264. * @param fallbacks defines the current fallback list.
  43265. * @param currentRank defines the current fallback rank.
  43266. * @returns the new fallback rank.
  43267. */
  43268. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43269. /**
  43270. * Add the required uniforms to the current list.
  43271. * @param uniforms defines the current uniform list.
  43272. */
  43273. static AddUniforms(uniforms: string[]): void;
  43274. /**
  43275. * Add the required uniforms to the current buffer.
  43276. * @param uniformBuffer defines the current uniform buffer.
  43277. */
  43278. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43279. /**
  43280. * Add the required samplers to the current list.
  43281. * @param samplers defines the current sampler list.
  43282. */
  43283. static AddSamplers(samplers: string[]): void;
  43284. /**
  43285. * Makes a duplicate of the current configuration into another one.
  43286. * @param anisotropicConfiguration define the config where to copy the info
  43287. */
  43288. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43289. /**
  43290. * Serializes this anisotropy configuration.
  43291. * @returns - An object with the serialized config.
  43292. */
  43293. serialize(): any;
  43294. /**
  43295. * Parses a anisotropy Configuration from a serialized object.
  43296. * @param source - Serialized object.
  43297. */
  43298. parse(source: any): void;
  43299. }
  43300. }
  43301. declare module BABYLON {
  43302. /**
  43303. * @hidden
  43304. */
  43305. export interface IMaterialBRDFDefines {
  43306. BRDF_V_HEIGHT_CORRELATED: boolean;
  43307. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43308. /** @hidden */ areMiscDirty: boolean;
  43309. }
  43310. /**
  43311. * Define the code related to the BRDF parameters of the pbr material.
  43312. */
  43313. export class PBRBRDFConfiguration {
  43314. /**
  43315. * Default value used for the energy conservation.
  43316. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43317. */
  43318. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43319. /**
  43320. * Default value used for the Smith Visibility Height Correlated mode.
  43321. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43322. */
  43323. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43324. private _useEnergyConservation;
  43325. /**
  43326. * Defines if the material uses energy conservation.
  43327. */
  43328. useEnergyConservation: boolean;
  43329. private _useSmithVisibilityHeightCorrelated;
  43330. /**
  43331. * LEGACY Mode set to false
  43332. * Defines if the material uses height smith correlated visibility term.
  43333. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43334. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43335. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43336. * Not relying on height correlated will also disable energy conservation.
  43337. */
  43338. useSmithVisibilityHeightCorrelated: boolean;
  43339. /** @hidden */
  43340. private _internalMarkAllSubMeshesAsMiscDirty;
  43341. /** @hidden */ markAllSubMeshesAsMiscDirty(): void;
  43342. /**
  43343. * Instantiate a new istance of clear coat configuration.
  43344. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43345. */
  43346. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43347. /**
  43348. * Checks to see if a texture is used in the material.
  43349. * @param defines the list of "defines" to update.
  43350. */
  43351. prepareDefines(defines: IMaterialBRDFDefines): void;
  43352. /**
  43353. * Get the current class name of the texture useful for serialization or dynamic coding.
  43354. * @returns "PBRClearCoatConfiguration"
  43355. */
  43356. getClassName(): string;
  43357. /**
  43358. * Makes a duplicate of the current configuration into another one.
  43359. * @param brdfConfiguration define the config where to copy the info
  43360. */
  43361. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43362. /**
  43363. * Serializes this BRDF configuration.
  43364. * @returns - An object with the serialized config.
  43365. */
  43366. serialize(): any;
  43367. /**
  43368. * Parses a BRDF Configuration from a serialized object.
  43369. * @param source - Serialized object.
  43370. */
  43371. parse(source: any): void;
  43372. }
  43373. }
  43374. declare module BABYLON {
  43375. /**
  43376. * @hidden
  43377. */
  43378. export interface IMaterialSheenDefines {
  43379. SHEEN: boolean;
  43380. SHEEN_TEXTURE: boolean;
  43381. SHEEN_TEXTUREDIRECTUV: number;
  43382. SHEEN_LINKWITHALBEDO: boolean;
  43383. /** @hidden */ areTexturesDirty: boolean;
  43384. }
  43385. /**
  43386. * Define the code related to the Sheen parameters of the pbr material.
  43387. */
  43388. export class PBRSheenConfiguration {
  43389. private _isEnabled;
  43390. /**
  43391. * Defines if the material uses sheen.
  43392. */
  43393. isEnabled: boolean;
  43394. private _linkSheenWithAlbedo;
  43395. /**
  43396. * Defines if the sheen is linked to the sheen color.
  43397. */
  43398. linkSheenWithAlbedo: boolean;
  43399. /**
  43400. * Defines the sheen intensity.
  43401. */
  43402. intensity: number;
  43403. /**
  43404. * Defines the sheen color.
  43405. */
  43406. color: Color3;
  43407. private _texture;
  43408. /**
  43409. * Stores the sheen tint values in a texture.
  43410. * rgb is tint
  43411. * a is a intensity
  43412. */
  43413. texture: Nullable<BaseTexture>;
  43414. /** @hidden */
  43415. private _internalMarkAllSubMeshesAsTexturesDirty;
  43416. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43417. /**
  43418. * Instantiate a new istance of clear coat configuration.
  43419. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43420. */
  43421. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43422. /**
  43423. * Specifies that the submesh is ready to be used.
  43424. * @param defines the list of "defines" to update.
  43425. * @param scene defines the scene the material belongs to.
  43426. * @returns - boolean indicating that the submesh is ready or not.
  43427. */
  43428. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43429. /**
  43430. * Checks to see if a texture is used in the material.
  43431. * @param defines the list of "defines" to update.
  43432. * @param scene defines the scene the material belongs to.
  43433. */
  43434. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43435. /**
  43436. * Binds the material data.
  43437. * @param uniformBuffer defines the Uniform buffer to fill in.
  43438. * @param scene defines the scene the material belongs to.
  43439. * @param isFrozen defines wether the material is frozen or not.
  43440. */
  43441. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43442. /**
  43443. * Checks to see if a texture is used in the material.
  43444. * @param texture - Base texture to use.
  43445. * @returns - Boolean specifying if a texture is used in the material.
  43446. */
  43447. hasTexture(texture: BaseTexture): boolean;
  43448. /**
  43449. * Returns an array of the actively used textures.
  43450. * @param activeTextures Array of BaseTextures
  43451. */
  43452. getActiveTextures(activeTextures: BaseTexture[]): void;
  43453. /**
  43454. * Returns the animatable textures.
  43455. * @param animatables Array of animatable textures.
  43456. */
  43457. getAnimatables(animatables: IAnimatable[]): void;
  43458. /**
  43459. * Disposes the resources of the material.
  43460. * @param forceDisposeTextures - Forces the disposal of all textures.
  43461. */
  43462. dispose(forceDisposeTextures?: boolean): void;
  43463. /**
  43464. * Get the current class name of the texture useful for serialization or dynamic coding.
  43465. * @returns "PBRSheenConfiguration"
  43466. */
  43467. getClassName(): string;
  43468. /**
  43469. * Add fallbacks to the effect fallbacks list.
  43470. * @param defines defines the Base texture to use.
  43471. * @param fallbacks defines the current fallback list.
  43472. * @param currentRank defines the current fallback rank.
  43473. * @returns the new fallback rank.
  43474. */
  43475. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43476. /**
  43477. * Add the required uniforms to the current list.
  43478. * @param uniforms defines the current uniform list.
  43479. */
  43480. static AddUniforms(uniforms: string[]): void;
  43481. /**
  43482. * Add the required uniforms to the current buffer.
  43483. * @param uniformBuffer defines the current uniform buffer.
  43484. */
  43485. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43486. /**
  43487. * Add the required samplers to the current list.
  43488. * @param samplers defines the current sampler list.
  43489. */
  43490. static AddSamplers(samplers: string[]): void;
  43491. /**
  43492. * Makes a duplicate of the current configuration into another one.
  43493. * @param sheenConfiguration define the config where to copy the info
  43494. */
  43495. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43496. /**
  43497. * Serializes this BRDF configuration.
  43498. * @returns - An object with the serialized config.
  43499. */
  43500. serialize(): any;
  43501. /**
  43502. * Parses a Sheen Configuration from a serialized object.
  43503. * @param source - Serialized object.
  43504. */
  43505. parse(source: any): void;
  43506. }
  43507. }
  43508. declare module BABYLON {
  43509. /**
  43510. * @hidden
  43511. */
  43512. export interface IMaterialSubSurfaceDefines {
  43513. SUBSURFACE: boolean;
  43514. SS_REFRACTION: boolean;
  43515. SS_TRANSLUCENCY: boolean;
  43516. SS_SCATERRING: boolean;
  43517. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43518. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43519. SS_REFRACTIONMAP_3D: boolean;
  43520. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43521. SS_LODINREFRACTIONALPHA: boolean;
  43522. SS_GAMMAREFRACTION: boolean;
  43523. SS_RGBDREFRACTION: boolean;
  43524. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43525. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43526. /** @hidden */ areTexturesDirty: boolean;
  43527. }
  43528. /**
  43529. * Define the code related to the sub surface parameters of the pbr material.
  43530. */
  43531. export class PBRSubSurfaceConfiguration {
  43532. private _isRefractionEnabled;
  43533. /**
  43534. * Defines if the refraction is enabled in the material.
  43535. */
  43536. isRefractionEnabled: boolean;
  43537. private _isTranslucencyEnabled;
  43538. /**
  43539. * Defines if the translucency is enabled in the material.
  43540. */
  43541. isTranslucencyEnabled: boolean;
  43542. private _isScatteringEnabled;
  43543. /**
  43544. * Defines the refraction intensity of the material.
  43545. * The refraction when enabled replaces the Diffuse part of the material.
  43546. * The intensity helps transitionning between diffuse and refraction.
  43547. */
  43548. refractionIntensity: number;
  43549. /**
  43550. * Defines the translucency intensity of the material.
  43551. * When translucency has been enabled, this defines how much of the "translucency"
  43552. * is addded to the diffuse part of the material.
  43553. */
  43554. translucencyIntensity: number;
  43555. /**
  43556. * Defines the scattering intensity of the material.
  43557. * When scattering has been enabled, this defines how much of the "scattered light"
  43558. * is addded to the diffuse part of the material.
  43559. */
  43560. scatteringIntensity: number;
  43561. private _thicknessTexture;
  43562. /**
  43563. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  43564. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  43565. * 0 would mean minimumThickness
  43566. * 1 would mean maximumThickness
  43567. * The other channels might be use as a mask to vary the different effects intensity.
  43568. */
  43569. thicknessTexture: Nullable<BaseTexture>;
  43570. private _refractionTexture;
  43571. /**
  43572. * Defines the texture to use for refraction.
  43573. */
  43574. refractionTexture: Nullable<BaseTexture>;
  43575. private _indexOfRefraction;
  43576. /**
  43577. * Defines the indice of refraction used in the material.
  43578. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  43579. */
  43580. indexOfRefraction: number;
  43581. private _invertRefractionY;
  43582. /**
  43583. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43584. */
  43585. invertRefractionY: boolean;
  43586. private _linkRefractionWithTransparency;
  43587. /**
  43588. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43589. * Materials half opaque for instance using refraction could benefit from this control.
  43590. */
  43591. linkRefractionWithTransparency: boolean;
  43592. /**
  43593. * Defines the minimum thickness stored in the thickness map.
  43594. * If no thickness map is defined, this value will be used to simulate thickness.
  43595. */
  43596. minimumThickness: number;
  43597. /**
  43598. * Defines the maximum thickness stored in the thickness map.
  43599. */
  43600. maximumThickness: number;
  43601. /**
  43602. * Defines the volume tint of the material.
  43603. * This is used for both translucency and scattering.
  43604. */
  43605. tintColor: Color3;
  43606. /**
  43607. * Defines the distance at which the tint color should be found in the media.
  43608. * This is used for refraction only.
  43609. */
  43610. tintColorAtDistance: number;
  43611. /**
  43612. * Defines how far each channel transmit through the media.
  43613. * It is defined as a color to simplify it selection.
  43614. */
  43615. diffusionDistance: Color3;
  43616. private _useMaskFromThicknessTexture;
  43617. /**
  43618. * Stores the intensity of the different subsurface effects in the thickness texture.
  43619. * * the green channel is the translucency intensity.
  43620. * * the blue channel is the scattering intensity.
  43621. * * the alpha channel is the refraction intensity.
  43622. */
  43623. useMaskFromThicknessTexture: boolean;
  43624. /** @hidden */
  43625. private _internalMarkAllSubMeshesAsTexturesDirty;
  43626. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43627. /**
  43628. * Instantiate a new istance of sub surface configuration.
  43629. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43630. */
  43631. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43632. /**
  43633. * Gets wehter the submesh is ready to be used or not.
  43634. * @param defines the list of "defines" to update.
  43635. * @param scene defines the scene the material belongs to.
  43636. * @returns - boolean indicating that the submesh is ready or not.
  43637. */
  43638. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  43639. /**
  43640. * Checks to see if a texture is used in the material.
  43641. * @param defines the list of "defines" to update.
  43642. * @param scene defines the scene to the material belongs to.
  43643. */
  43644. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  43645. /**
  43646. * Binds the material data.
  43647. * @param uniformBuffer defines the Uniform buffer to fill in.
  43648. * @param scene defines the scene the material belongs to.
  43649. * @param engine defines the engine the material belongs to.
  43650. * @param isFrozen defines wether the material is frozen or not.
  43651. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  43652. */
  43653. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  43654. /**
  43655. * Unbinds the material from the mesh.
  43656. * @param activeEffect defines the effect that should be unbound from.
  43657. * @returns true if unbound, otherwise false
  43658. */
  43659. unbind(activeEffect: Effect): boolean;
  43660. /**
  43661. * Returns the texture used for refraction or null if none is used.
  43662. * @param scene defines the scene the material belongs to.
  43663. * @returns - Refraction texture if present. If no refraction texture and refraction
  43664. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43665. */
  43666. private _getRefractionTexture;
  43667. /**
  43668. * Returns true if alpha blending should be disabled.
  43669. */
  43670. readonly disableAlphaBlending: boolean;
  43671. /**
  43672. * Fills the list of render target textures.
  43673. * @param renderTargets the list of render targets to update
  43674. */
  43675. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  43676. /**
  43677. * Checks to see if a texture is used in the material.
  43678. * @param texture - Base texture to use.
  43679. * @returns - Boolean specifying if a texture is used in the material.
  43680. */
  43681. hasTexture(texture: BaseTexture): boolean;
  43682. /**
  43683. * Gets a boolean indicating that current material needs to register RTT
  43684. * @returns true if this uses a render target otherwise false.
  43685. */
  43686. hasRenderTargetTextures(): boolean;
  43687. /**
  43688. * Returns an array of the actively used textures.
  43689. * @param activeTextures Array of BaseTextures
  43690. */
  43691. getActiveTextures(activeTextures: BaseTexture[]): void;
  43692. /**
  43693. * Returns the animatable textures.
  43694. * @param animatables Array of animatable textures.
  43695. */
  43696. getAnimatables(animatables: IAnimatable[]): void;
  43697. /**
  43698. * Disposes the resources of the material.
  43699. * @param forceDisposeTextures - Forces the disposal of all textures.
  43700. */
  43701. dispose(forceDisposeTextures?: boolean): void;
  43702. /**
  43703. * Get the current class name of the texture useful for serialization or dynamic coding.
  43704. * @returns "PBRSubSurfaceConfiguration"
  43705. */
  43706. getClassName(): string;
  43707. /**
  43708. * Add fallbacks to the effect fallbacks list.
  43709. * @param defines defines the Base texture to use.
  43710. * @param fallbacks defines the current fallback list.
  43711. * @param currentRank defines the current fallback rank.
  43712. * @returns the new fallback rank.
  43713. */
  43714. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43715. /**
  43716. * Add the required uniforms to the current list.
  43717. * @param uniforms defines the current uniform list.
  43718. */
  43719. static AddUniforms(uniforms: string[]): void;
  43720. /**
  43721. * Add the required samplers to the current list.
  43722. * @param samplers defines the current sampler list.
  43723. */
  43724. static AddSamplers(samplers: string[]): void;
  43725. /**
  43726. * Add the required uniforms to the current buffer.
  43727. * @param uniformBuffer defines the current uniform buffer.
  43728. */
  43729. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43730. /**
  43731. * Makes a duplicate of the current configuration into another one.
  43732. * @param configuration define the config where to copy the info
  43733. */
  43734. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  43735. /**
  43736. * Serializes this Sub Surface configuration.
  43737. * @returns - An object with the serialized config.
  43738. */
  43739. serialize(): any;
  43740. /**
  43741. * Parses a Sub Surface Configuration from a serialized object.
  43742. * @param source - Serialized object.
  43743. */
  43744. parse(source: any): void;
  43745. }
  43746. }
  43747. declare module BABYLON {
  43748. /** @hidden */
  43749. export var pbrFragmentDeclaration: {
  43750. name: string;
  43751. shader: string;
  43752. };
  43753. }
  43754. declare module BABYLON {
  43755. /** @hidden */
  43756. export var pbrUboDeclaration: {
  43757. name: string;
  43758. shader: string;
  43759. };
  43760. }
  43761. declare module BABYLON {
  43762. /** @hidden */
  43763. export var pbrFragmentExtraDeclaration: {
  43764. name: string;
  43765. shader: string;
  43766. };
  43767. }
  43768. declare module BABYLON {
  43769. /** @hidden */
  43770. export var pbrFragmentSamplersDeclaration: {
  43771. name: string;
  43772. shader: string;
  43773. };
  43774. }
  43775. declare module BABYLON {
  43776. /** @hidden */
  43777. export var pbrHelperFunctions: {
  43778. name: string;
  43779. shader: string;
  43780. };
  43781. }
  43782. declare module BABYLON {
  43783. /** @hidden */
  43784. export var harmonicsFunctions: {
  43785. name: string;
  43786. shader: string;
  43787. };
  43788. }
  43789. declare module BABYLON {
  43790. /** @hidden */
  43791. export var pbrDirectLightingSetupFunctions: {
  43792. name: string;
  43793. shader: string;
  43794. };
  43795. }
  43796. declare module BABYLON {
  43797. /** @hidden */
  43798. export var pbrDirectLightingFalloffFunctions: {
  43799. name: string;
  43800. shader: string;
  43801. };
  43802. }
  43803. declare module BABYLON {
  43804. /** @hidden */
  43805. export var pbrBRDFFunctions: {
  43806. name: string;
  43807. shader: string;
  43808. };
  43809. }
  43810. declare module BABYLON {
  43811. /** @hidden */
  43812. export var pbrDirectLightingFunctions: {
  43813. name: string;
  43814. shader: string;
  43815. };
  43816. }
  43817. declare module BABYLON {
  43818. /** @hidden */
  43819. export var pbrIBLFunctions: {
  43820. name: string;
  43821. shader: string;
  43822. };
  43823. }
  43824. declare module BABYLON {
  43825. /** @hidden */
  43826. export var pbrDebug: {
  43827. name: string;
  43828. shader: string;
  43829. };
  43830. }
  43831. declare module BABYLON {
  43832. /** @hidden */
  43833. export var pbrPixelShader: {
  43834. name: string;
  43835. shader: string;
  43836. };
  43837. }
  43838. declare module BABYLON {
  43839. /** @hidden */
  43840. export var pbrVertexDeclaration: {
  43841. name: string;
  43842. shader: string;
  43843. };
  43844. }
  43845. declare module BABYLON {
  43846. /** @hidden */
  43847. export var pbrVertexShader: {
  43848. name: string;
  43849. shader: string;
  43850. };
  43851. }
  43852. declare module BABYLON {
  43853. /**
  43854. * Manages the defines for the PBR Material.
  43855. * @hidden
  43856. */
  43857. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  43858. PBR: boolean;
  43859. MAINUV1: boolean;
  43860. MAINUV2: boolean;
  43861. UV1: boolean;
  43862. UV2: boolean;
  43863. ALBEDO: boolean;
  43864. ALBEDODIRECTUV: number;
  43865. VERTEXCOLOR: boolean;
  43866. AMBIENT: boolean;
  43867. AMBIENTDIRECTUV: number;
  43868. AMBIENTINGRAYSCALE: boolean;
  43869. OPACITY: boolean;
  43870. VERTEXALPHA: boolean;
  43871. OPACITYDIRECTUV: number;
  43872. OPACITYRGB: boolean;
  43873. ALPHATEST: boolean;
  43874. DEPTHPREPASS: boolean;
  43875. ALPHABLEND: boolean;
  43876. ALPHAFROMALBEDO: boolean;
  43877. ALPHATESTVALUE: string;
  43878. SPECULAROVERALPHA: boolean;
  43879. RADIANCEOVERALPHA: boolean;
  43880. ALPHAFRESNEL: boolean;
  43881. LINEARALPHAFRESNEL: boolean;
  43882. PREMULTIPLYALPHA: boolean;
  43883. EMISSIVE: boolean;
  43884. EMISSIVEDIRECTUV: number;
  43885. REFLECTIVITY: boolean;
  43886. REFLECTIVITYDIRECTUV: number;
  43887. SPECULARTERM: boolean;
  43888. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  43889. MICROSURFACEAUTOMATIC: boolean;
  43890. LODBASEDMICROSFURACE: boolean;
  43891. MICROSURFACEMAP: boolean;
  43892. MICROSURFACEMAPDIRECTUV: number;
  43893. METALLICWORKFLOW: boolean;
  43894. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  43895. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  43896. METALLNESSSTOREINMETALMAPBLUE: boolean;
  43897. AOSTOREINMETALMAPRED: boolean;
  43898. ENVIRONMENTBRDF: boolean;
  43899. ENVIRONMENTBRDF_RGBD: boolean;
  43900. NORMAL: boolean;
  43901. TANGENT: boolean;
  43902. BUMP: boolean;
  43903. BUMPDIRECTUV: number;
  43904. OBJECTSPACE_NORMALMAP: boolean;
  43905. PARALLAX: boolean;
  43906. PARALLAXOCCLUSION: boolean;
  43907. NORMALXYSCALE: boolean;
  43908. LIGHTMAP: boolean;
  43909. LIGHTMAPDIRECTUV: number;
  43910. USELIGHTMAPASSHADOWMAP: boolean;
  43911. GAMMALIGHTMAP: boolean;
  43912. REFLECTION: boolean;
  43913. REFLECTIONMAP_3D: boolean;
  43914. REFLECTIONMAP_SPHERICAL: boolean;
  43915. REFLECTIONMAP_PLANAR: boolean;
  43916. REFLECTIONMAP_CUBIC: boolean;
  43917. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  43918. REFLECTIONMAP_PROJECTION: boolean;
  43919. REFLECTIONMAP_SKYBOX: boolean;
  43920. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  43921. REFLECTIONMAP_EXPLICIT: boolean;
  43922. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  43923. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  43924. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  43925. INVERTCUBICMAP: boolean;
  43926. USESPHERICALFROMREFLECTIONMAP: boolean;
  43927. USESPHERICALINVERTEX: boolean;
  43928. REFLECTIONMAP_OPPOSITEZ: boolean;
  43929. LODINREFLECTIONALPHA: boolean;
  43930. GAMMAREFLECTION: boolean;
  43931. RGBDREFLECTION: boolean;
  43932. RADIANCEOCCLUSION: boolean;
  43933. HORIZONOCCLUSION: boolean;
  43934. INSTANCES: boolean;
  43935. NUM_BONE_INFLUENCERS: number;
  43936. BonesPerMesh: number;
  43937. BONETEXTURE: boolean;
  43938. NONUNIFORMSCALING: boolean;
  43939. MORPHTARGETS: boolean;
  43940. MORPHTARGETS_NORMAL: boolean;
  43941. MORPHTARGETS_TANGENT: boolean;
  43942. NUM_MORPH_INFLUENCERS: number;
  43943. IMAGEPROCESSING: boolean;
  43944. VIGNETTE: boolean;
  43945. VIGNETTEBLENDMODEMULTIPLY: boolean;
  43946. VIGNETTEBLENDMODEOPAQUE: boolean;
  43947. TONEMAPPING: boolean;
  43948. TONEMAPPING_ACES: boolean;
  43949. CONTRAST: boolean;
  43950. COLORCURVES: boolean;
  43951. COLORGRADING: boolean;
  43952. COLORGRADING3D: boolean;
  43953. SAMPLER3DGREENDEPTH: boolean;
  43954. SAMPLER3DBGRMAP: boolean;
  43955. IMAGEPROCESSINGPOSTPROCESS: boolean;
  43956. EXPOSURE: boolean;
  43957. MULTIVIEW: boolean;
  43958. USEPHYSICALLIGHTFALLOFF: boolean;
  43959. USEGLTFLIGHTFALLOFF: boolean;
  43960. TWOSIDEDLIGHTING: boolean;
  43961. SHADOWFLOAT: boolean;
  43962. CLIPPLANE: boolean;
  43963. CLIPPLANE2: boolean;
  43964. CLIPPLANE3: boolean;
  43965. CLIPPLANE4: boolean;
  43966. POINTSIZE: boolean;
  43967. FOG: boolean;
  43968. LOGARITHMICDEPTH: boolean;
  43969. FORCENORMALFORWARD: boolean;
  43970. SPECULARAA: boolean;
  43971. CLEARCOAT: boolean;
  43972. CLEARCOAT_DEFAULTIOR: boolean;
  43973. CLEARCOAT_TEXTURE: boolean;
  43974. CLEARCOAT_TEXTUREDIRECTUV: number;
  43975. CLEARCOAT_BUMP: boolean;
  43976. CLEARCOAT_BUMPDIRECTUV: number;
  43977. CLEARCOAT_TINT: boolean;
  43978. CLEARCOAT_TINT_TEXTURE: boolean;
  43979. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43980. ANISOTROPIC: boolean;
  43981. ANISOTROPIC_TEXTURE: boolean;
  43982. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43983. BRDF_V_HEIGHT_CORRELATED: boolean;
  43984. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43985. SHEEN: boolean;
  43986. SHEEN_TEXTURE: boolean;
  43987. SHEEN_TEXTUREDIRECTUV: number;
  43988. SHEEN_LINKWITHALBEDO: boolean;
  43989. SUBSURFACE: boolean;
  43990. SS_REFRACTION: boolean;
  43991. SS_TRANSLUCENCY: boolean;
  43992. SS_SCATERRING: boolean;
  43993. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43994. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43995. SS_REFRACTIONMAP_3D: boolean;
  43996. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43997. SS_LODINREFRACTIONALPHA: boolean;
  43998. SS_GAMMAREFRACTION: boolean;
  43999. SS_RGBDREFRACTION: boolean;
  44000. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44001. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44002. UNLIT: boolean;
  44003. DEBUGMODE: number;
  44004. /**
  44005. * Initializes the PBR Material defines.
  44006. */
  44007. constructor();
  44008. /**
  44009. * Resets the PBR Material defines.
  44010. */
  44011. reset(): void;
  44012. }
  44013. /**
  44014. * The Physically based material base class of BJS.
  44015. *
  44016. * This offers the main features of a standard PBR material.
  44017. * For more information, please refer to the documentation :
  44018. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44019. */
  44020. export abstract class PBRBaseMaterial extends PushMaterial {
  44021. /**
  44022. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44023. */
  44024. static readonly PBRMATERIAL_OPAQUE: number;
  44025. /**
  44026. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44027. */
  44028. static readonly PBRMATERIAL_ALPHATEST: number;
  44029. /**
  44030. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44031. */
  44032. static readonly PBRMATERIAL_ALPHABLEND: number;
  44033. /**
  44034. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44035. * They are also discarded below the alpha cutoff threshold to improve performances.
  44036. */
  44037. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44038. /**
  44039. * Defines the default value of how much AO map is occluding the analytical lights
  44040. * (point spot...).
  44041. */
  44042. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44043. /**
  44044. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44045. */
  44046. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44047. /**
  44048. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44049. * to enhance interoperability with other engines.
  44050. */
  44051. static readonly LIGHTFALLOFF_GLTF: number;
  44052. /**
  44053. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44054. * to enhance interoperability with other materials.
  44055. */
  44056. static readonly LIGHTFALLOFF_STANDARD: number;
  44057. /**
  44058. * Intensity of the direct lights e.g. the four lights available in your scene.
  44059. * This impacts both the direct diffuse and specular highlights.
  44060. */
  44061. protected _directIntensity: number;
  44062. /**
  44063. * Intensity of the emissive part of the material.
  44064. * This helps controlling the emissive effect without modifying the emissive color.
  44065. */
  44066. protected _emissiveIntensity: number;
  44067. /**
  44068. * Intensity of the environment e.g. how much the environment will light the object
  44069. * either through harmonics for rough material or through the refelction for shiny ones.
  44070. */
  44071. protected _environmentIntensity: number;
  44072. /**
  44073. * This is a special control allowing the reduction of the specular highlights coming from the
  44074. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44075. */
  44076. protected _specularIntensity: number;
  44077. /**
  44078. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44079. */
  44080. private _lightingInfos;
  44081. /**
  44082. * Debug Control allowing disabling the bump map on this material.
  44083. */
  44084. protected _disableBumpMap: boolean;
  44085. /**
  44086. * AKA Diffuse Texture in standard nomenclature.
  44087. */
  44088. protected _albedoTexture: Nullable<BaseTexture>;
  44089. /**
  44090. * AKA Occlusion Texture in other nomenclature.
  44091. */
  44092. protected _ambientTexture: Nullable<BaseTexture>;
  44093. /**
  44094. * AKA Occlusion Texture Intensity in other nomenclature.
  44095. */
  44096. protected _ambientTextureStrength: number;
  44097. /**
  44098. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44099. * 1 means it completely occludes it
  44100. * 0 mean it has no impact
  44101. */
  44102. protected _ambientTextureImpactOnAnalyticalLights: number;
  44103. /**
  44104. * Stores the alpha values in a texture.
  44105. */
  44106. protected _opacityTexture: Nullable<BaseTexture>;
  44107. /**
  44108. * Stores the reflection values in a texture.
  44109. */
  44110. protected _reflectionTexture: Nullable<BaseTexture>;
  44111. /**
  44112. * Stores the emissive values in a texture.
  44113. */
  44114. protected _emissiveTexture: Nullable<BaseTexture>;
  44115. /**
  44116. * AKA Specular texture in other nomenclature.
  44117. */
  44118. protected _reflectivityTexture: Nullable<BaseTexture>;
  44119. /**
  44120. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44121. */
  44122. protected _metallicTexture: Nullable<BaseTexture>;
  44123. /**
  44124. * Specifies the metallic scalar of the metallic/roughness workflow.
  44125. * Can also be used to scale the metalness values of the metallic texture.
  44126. */
  44127. protected _metallic: Nullable<number>;
  44128. /**
  44129. * Specifies the roughness scalar of the metallic/roughness workflow.
  44130. * Can also be used to scale the roughness values of the metallic texture.
  44131. */
  44132. protected _roughness: Nullable<number>;
  44133. /**
  44134. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44135. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44136. */
  44137. protected _microSurfaceTexture: Nullable<BaseTexture>;
  44138. /**
  44139. * Stores surface normal data used to displace a mesh in a texture.
  44140. */
  44141. protected _bumpTexture: Nullable<BaseTexture>;
  44142. /**
  44143. * Stores the pre-calculated light information of a mesh in a texture.
  44144. */
  44145. protected _lightmapTexture: Nullable<BaseTexture>;
  44146. /**
  44147. * The color of a material in ambient lighting.
  44148. */
  44149. protected _ambientColor: Color3;
  44150. /**
  44151. * AKA Diffuse Color in other nomenclature.
  44152. */
  44153. protected _albedoColor: Color3;
  44154. /**
  44155. * AKA Specular Color in other nomenclature.
  44156. */
  44157. protected _reflectivityColor: Color3;
  44158. /**
  44159. * The color applied when light is reflected from a material.
  44160. */
  44161. protected _reflectionColor: Color3;
  44162. /**
  44163. * The color applied when light is emitted from a material.
  44164. */
  44165. protected _emissiveColor: Color3;
  44166. /**
  44167. * AKA Glossiness in other nomenclature.
  44168. */
  44169. protected _microSurface: number;
  44170. /**
  44171. * Specifies that the material will use the light map as a show map.
  44172. */
  44173. protected _useLightmapAsShadowmap: boolean;
  44174. /**
  44175. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44176. * makes the reflect vector face the model (under horizon).
  44177. */
  44178. protected _useHorizonOcclusion: boolean;
  44179. /**
  44180. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44181. * too much the area relying on ambient texture to define their ambient occlusion.
  44182. */
  44183. protected _useRadianceOcclusion: boolean;
  44184. /**
  44185. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44186. */
  44187. protected _useAlphaFromAlbedoTexture: boolean;
  44188. /**
  44189. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44190. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44191. */
  44192. protected _useSpecularOverAlpha: boolean;
  44193. /**
  44194. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44195. */
  44196. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44197. /**
  44198. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44199. */
  44200. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44201. /**
  44202. * Specifies if the metallic texture contains the roughness information in its green channel.
  44203. */
  44204. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44205. /**
  44206. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44207. */
  44208. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44209. /**
  44210. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44211. */
  44212. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44213. /**
  44214. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44215. */
  44216. protected _useAmbientInGrayScale: boolean;
  44217. /**
  44218. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44219. * The material will try to infer what glossiness each pixel should be.
  44220. */
  44221. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44222. /**
  44223. * Defines the falloff type used in this material.
  44224. * It by default is Physical.
  44225. */
  44226. protected _lightFalloff: number;
  44227. /**
  44228. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44229. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44230. */
  44231. protected _useRadianceOverAlpha: boolean;
  44232. /**
  44233. * Allows using an object space normal map (instead of tangent space).
  44234. */
  44235. protected _useObjectSpaceNormalMap: boolean;
  44236. /**
  44237. * Allows using the bump map in parallax mode.
  44238. */
  44239. protected _useParallax: boolean;
  44240. /**
  44241. * Allows using the bump map in parallax occlusion mode.
  44242. */
  44243. protected _useParallaxOcclusion: boolean;
  44244. /**
  44245. * Controls the scale bias of the parallax mode.
  44246. */
  44247. protected _parallaxScaleBias: number;
  44248. /**
  44249. * If sets to true, disables all the lights affecting the material.
  44250. */
  44251. protected _disableLighting: boolean;
  44252. /**
  44253. * Number of Simultaneous lights allowed on the material.
  44254. */
  44255. protected _maxSimultaneousLights: number;
  44256. /**
  44257. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44258. */
  44259. protected _invertNormalMapX: boolean;
  44260. /**
  44261. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44262. */
  44263. protected _invertNormalMapY: boolean;
  44264. /**
  44265. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44266. */
  44267. protected _twoSidedLighting: boolean;
  44268. /**
  44269. * Defines the alpha limits in alpha test mode.
  44270. */
  44271. protected _alphaCutOff: number;
  44272. /**
  44273. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44274. */
  44275. protected _forceAlphaTest: boolean;
  44276. /**
  44277. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44278. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44279. */
  44280. protected _useAlphaFresnel: boolean;
  44281. /**
  44282. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44283. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44284. */
  44285. protected _useLinearAlphaFresnel: boolean;
  44286. /**
  44287. * The transparency mode of the material.
  44288. */
  44289. protected _transparencyMode: Nullable<number>;
  44290. /**
  44291. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44292. * from cos thetav and roughness:
  44293. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44294. */
  44295. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44296. /**
  44297. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44298. */
  44299. protected _forceIrradianceInFragment: boolean;
  44300. /**
  44301. * Force normal to face away from face.
  44302. */
  44303. protected _forceNormalForward: boolean;
  44304. /**
  44305. * Enables specular anti aliasing in the PBR shader.
  44306. * It will both interacts on the Geometry for analytical and IBL lighting.
  44307. * It also prefilter the roughness map based on the bump values.
  44308. */
  44309. protected _enableSpecularAntiAliasing: boolean;
  44310. /**
  44311. * Default configuration related to image processing available in the PBR Material.
  44312. */
  44313. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44314. /**
  44315. * Keep track of the image processing observer to allow dispose and replace.
  44316. */
  44317. private _imageProcessingObserver;
  44318. /**
  44319. * Attaches a new image processing configuration to the PBR Material.
  44320. * @param configuration
  44321. */
  44322. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44323. /**
  44324. * Stores the available render targets.
  44325. */
  44326. private _renderTargets;
  44327. /**
  44328. * Sets the global ambient color for the material used in lighting calculations.
  44329. */
  44330. private _globalAmbientColor;
  44331. /**
  44332. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44333. */
  44334. private _useLogarithmicDepth;
  44335. /**
  44336. * If set to true, no lighting calculations will be applied.
  44337. */
  44338. private _unlit;
  44339. private _debugMode;
  44340. /**
  44341. * @hidden
  44342. * This is reserved for the inspector.
  44343. * Defines the material debug mode.
  44344. * It helps seeing only some components of the material while troubleshooting.
  44345. */
  44346. debugMode: number;
  44347. /**
  44348. * @hidden
  44349. * This is reserved for the inspector.
  44350. * Specify from where on screen the debug mode should start.
  44351. * The value goes from -1 (full screen) to 1 (not visible)
  44352. * It helps with side by side comparison against the final render
  44353. * This defaults to -1
  44354. */
  44355. private debugLimit;
  44356. /**
  44357. * @hidden
  44358. * This is reserved for the inspector.
  44359. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44360. * You can use the factor to better multiply the final value.
  44361. */
  44362. private debugFactor;
  44363. /**
  44364. * Defines the clear coat layer parameters for the material.
  44365. */
  44366. readonly clearCoat: PBRClearCoatConfiguration;
  44367. /**
  44368. * Defines the anisotropic parameters for the material.
  44369. */
  44370. readonly anisotropy: PBRAnisotropicConfiguration;
  44371. /**
  44372. * Defines the BRDF parameters for the material.
  44373. */
  44374. readonly brdf: PBRBRDFConfiguration;
  44375. /**
  44376. * Defines the Sheen parameters for the material.
  44377. */
  44378. readonly sheen: PBRSheenConfiguration;
  44379. /**
  44380. * Defines the SubSurface parameters for the material.
  44381. */
  44382. readonly subSurface: PBRSubSurfaceConfiguration;
  44383. /**
  44384. * Custom callback helping to override the default shader used in the material.
  44385. */
  44386. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44387. /**
  44388. * Instantiates a new PBRMaterial instance.
  44389. *
  44390. * @param name The material name
  44391. * @param scene The scene the material will be use in.
  44392. */
  44393. constructor(name: string, scene: Scene);
  44394. /**
  44395. * Gets a boolean indicating that current material needs to register RTT
  44396. */
  44397. readonly hasRenderTargetTextures: boolean;
  44398. /**
  44399. * Gets the name of the material class.
  44400. */
  44401. getClassName(): string;
  44402. /**
  44403. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44404. */
  44405. /**
  44406. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44407. */
  44408. useLogarithmicDepth: boolean;
  44409. /**
  44410. * Gets the current transparency mode.
  44411. */
  44412. /**
  44413. * Sets the transparency mode of the material.
  44414. *
  44415. * | Value | Type | Description |
  44416. * | ----- | ----------------------------------- | ----------- |
  44417. * | 0 | OPAQUE | |
  44418. * | 1 | ALPHATEST | |
  44419. * | 2 | ALPHABLEND | |
  44420. * | 3 | ALPHATESTANDBLEND | |
  44421. *
  44422. */
  44423. transparencyMode: Nullable<number>;
  44424. /**
  44425. * Returns true if alpha blending should be disabled.
  44426. */
  44427. private readonly _disableAlphaBlending;
  44428. /**
  44429. * Specifies whether or not this material should be rendered in alpha blend mode.
  44430. */
  44431. needAlphaBlending(): boolean;
  44432. /**
  44433. * Specifies if the mesh will require alpha blending.
  44434. * @param mesh - BJS mesh.
  44435. */
  44436. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44437. /**
  44438. * Specifies whether or not this material should be rendered in alpha test mode.
  44439. */
  44440. needAlphaTesting(): boolean;
  44441. /**
  44442. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44443. */
  44444. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44445. /**
  44446. * Gets the texture used for the alpha test.
  44447. */
  44448. getAlphaTestTexture(): Nullable<BaseTexture>;
  44449. /**
  44450. * Specifies that the submesh is ready to be used.
  44451. * @param mesh - BJS mesh.
  44452. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44453. * @param useInstances - Specifies that instances should be used.
  44454. * @returns - boolean indicating that the submesh is ready or not.
  44455. */
  44456. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44457. /**
  44458. * Specifies if the material uses metallic roughness workflow.
  44459. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44460. */
  44461. isMetallicWorkflow(): boolean;
  44462. private _prepareEffect;
  44463. private _prepareDefines;
  44464. /**
  44465. * Force shader compilation
  44466. */
  44467. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44468. clipPlane: boolean;
  44469. }>): void;
  44470. /**
  44471. * Initializes the uniform buffer layout for the shader.
  44472. */
  44473. buildUniformLayout(): void;
  44474. /**
  44475. * Unbinds the material from the mesh
  44476. */
  44477. unbind(): void;
  44478. /**
  44479. * Binds the submesh data.
  44480. * @param world - The world matrix.
  44481. * @param mesh - The BJS mesh.
  44482. * @param subMesh - A submesh of the BJS mesh.
  44483. */
  44484. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44485. /**
  44486. * Returns the animatable textures.
  44487. * @returns - Array of animatable textures.
  44488. */
  44489. getAnimatables(): IAnimatable[];
  44490. /**
  44491. * Returns the texture used for reflections.
  44492. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44493. */
  44494. private _getReflectionTexture;
  44495. /**
  44496. * Returns an array of the actively used textures.
  44497. * @returns - Array of BaseTextures
  44498. */
  44499. getActiveTextures(): BaseTexture[];
  44500. /**
  44501. * Checks to see if a texture is used in the material.
  44502. * @param texture - Base texture to use.
  44503. * @returns - Boolean specifying if a texture is used in the material.
  44504. */
  44505. hasTexture(texture: BaseTexture): boolean;
  44506. /**
  44507. * Disposes the resources of the material.
  44508. * @param forceDisposeEffect - Forces the disposal of effects.
  44509. * @param forceDisposeTextures - Forces the disposal of all textures.
  44510. */
  44511. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44512. }
  44513. }
  44514. declare module BABYLON {
  44515. /**
  44516. * The Physically based material of BJS.
  44517. *
  44518. * This offers the main features of a standard PBR material.
  44519. * For more information, please refer to the documentation :
  44520. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44521. */
  44522. export class PBRMaterial extends PBRBaseMaterial {
  44523. /**
  44524. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44525. */
  44526. static readonly PBRMATERIAL_OPAQUE: number;
  44527. /**
  44528. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44529. */
  44530. static readonly PBRMATERIAL_ALPHATEST: number;
  44531. /**
  44532. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44533. */
  44534. static readonly PBRMATERIAL_ALPHABLEND: number;
  44535. /**
  44536. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44537. * They are also discarded below the alpha cutoff threshold to improve performances.
  44538. */
  44539. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44540. /**
  44541. * Defines the default value of how much AO map is occluding the analytical lights
  44542. * (point spot...).
  44543. */
  44544. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44545. /**
  44546. * Intensity of the direct lights e.g. the four lights available in your scene.
  44547. * This impacts both the direct diffuse and specular highlights.
  44548. */
  44549. directIntensity: number;
  44550. /**
  44551. * Intensity of the emissive part of the material.
  44552. * This helps controlling the emissive effect without modifying the emissive color.
  44553. */
  44554. emissiveIntensity: number;
  44555. /**
  44556. * Intensity of the environment e.g. how much the environment will light the object
  44557. * either through harmonics for rough material or through the refelction for shiny ones.
  44558. */
  44559. environmentIntensity: number;
  44560. /**
  44561. * This is a special control allowing the reduction of the specular highlights coming from the
  44562. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44563. */
  44564. specularIntensity: number;
  44565. /**
  44566. * Debug Control allowing disabling the bump map on this material.
  44567. */
  44568. disableBumpMap: boolean;
  44569. /**
  44570. * AKA Diffuse Texture in standard nomenclature.
  44571. */
  44572. albedoTexture: BaseTexture;
  44573. /**
  44574. * AKA Occlusion Texture in other nomenclature.
  44575. */
  44576. ambientTexture: BaseTexture;
  44577. /**
  44578. * AKA Occlusion Texture Intensity in other nomenclature.
  44579. */
  44580. ambientTextureStrength: number;
  44581. /**
  44582. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44583. * 1 means it completely occludes it
  44584. * 0 mean it has no impact
  44585. */
  44586. ambientTextureImpactOnAnalyticalLights: number;
  44587. /**
  44588. * Stores the alpha values in a texture.
  44589. */
  44590. opacityTexture: BaseTexture;
  44591. /**
  44592. * Stores the reflection values in a texture.
  44593. */
  44594. reflectionTexture: Nullable<BaseTexture>;
  44595. /**
  44596. * Stores the emissive values in a texture.
  44597. */
  44598. emissiveTexture: BaseTexture;
  44599. /**
  44600. * AKA Specular texture in other nomenclature.
  44601. */
  44602. reflectivityTexture: BaseTexture;
  44603. /**
  44604. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44605. */
  44606. metallicTexture: BaseTexture;
  44607. /**
  44608. * Specifies the metallic scalar of the metallic/roughness workflow.
  44609. * Can also be used to scale the metalness values of the metallic texture.
  44610. */
  44611. metallic: Nullable<number>;
  44612. /**
  44613. * Specifies the roughness scalar of the metallic/roughness workflow.
  44614. * Can also be used to scale the roughness values of the metallic texture.
  44615. */
  44616. roughness: Nullable<number>;
  44617. /**
  44618. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44619. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44620. */
  44621. microSurfaceTexture: BaseTexture;
  44622. /**
  44623. * Stores surface normal data used to displace a mesh in a texture.
  44624. */
  44625. bumpTexture: BaseTexture;
  44626. /**
  44627. * Stores the pre-calculated light information of a mesh in a texture.
  44628. */
  44629. lightmapTexture: BaseTexture;
  44630. /**
  44631. * Stores the refracted light information in a texture.
  44632. */
  44633. refractionTexture: Nullable<BaseTexture>;
  44634. /**
  44635. * The color of a material in ambient lighting.
  44636. */
  44637. ambientColor: Color3;
  44638. /**
  44639. * AKA Diffuse Color in other nomenclature.
  44640. */
  44641. albedoColor: Color3;
  44642. /**
  44643. * AKA Specular Color in other nomenclature.
  44644. */
  44645. reflectivityColor: Color3;
  44646. /**
  44647. * The color reflected from the material.
  44648. */
  44649. reflectionColor: Color3;
  44650. /**
  44651. * The color emitted from the material.
  44652. */
  44653. emissiveColor: Color3;
  44654. /**
  44655. * AKA Glossiness in other nomenclature.
  44656. */
  44657. microSurface: number;
  44658. /**
  44659. * source material index of refraction (IOR)' / 'destination material IOR.
  44660. */
  44661. indexOfRefraction: number;
  44662. /**
  44663. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44664. */
  44665. invertRefractionY: boolean;
  44666. /**
  44667. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44668. * Materials half opaque for instance using refraction could benefit from this control.
  44669. */
  44670. linkRefractionWithTransparency: boolean;
  44671. /**
  44672. * If true, the light map contains occlusion information instead of lighting info.
  44673. */
  44674. useLightmapAsShadowmap: boolean;
  44675. /**
  44676. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44677. */
  44678. useAlphaFromAlbedoTexture: boolean;
  44679. /**
  44680. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44681. */
  44682. forceAlphaTest: boolean;
  44683. /**
  44684. * Defines the alpha limits in alpha test mode.
  44685. */
  44686. alphaCutOff: number;
  44687. /**
  44688. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44689. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44690. */
  44691. useSpecularOverAlpha: boolean;
  44692. /**
  44693. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44694. */
  44695. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44696. /**
  44697. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44698. */
  44699. useRoughnessFromMetallicTextureAlpha: boolean;
  44700. /**
  44701. * Specifies if the metallic texture contains the roughness information in its green channel.
  44702. */
  44703. useRoughnessFromMetallicTextureGreen: boolean;
  44704. /**
  44705. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44706. */
  44707. useMetallnessFromMetallicTextureBlue: boolean;
  44708. /**
  44709. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44710. */
  44711. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44712. /**
  44713. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44714. */
  44715. useAmbientInGrayScale: boolean;
  44716. /**
  44717. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44718. * The material will try to infer what glossiness each pixel should be.
  44719. */
  44720. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44721. /**
  44722. * BJS is using an harcoded light falloff based on a manually sets up range.
  44723. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44724. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44725. */
  44726. /**
  44727. * BJS is using an harcoded light falloff based on a manually sets up range.
  44728. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44729. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44730. */
  44731. usePhysicalLightFalloff: boolean;
  44732. /**
  44733. * In order to support the falloff compatibility with gltf, a special mode has been added
  44734. * to reproduce the gltf light falloff.
  44735. */
  44736. /**
  44737. * In order to support the falloff compatibility with gltf, a special mode has been added
  44738. * to reproduce the gltf light falloff.
  44739. */
  44740. useGLTFLightFalloff: boolean;
  44741. /**
  44742. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44743. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44744. */
  44745. useRadianceOverAlpha: boolean;
  44746. /**
  44747. * Allows using an object space normal map (instead of tangent space).
  44748. */
  44749. useObjectSpaceNormalMap: boolean;
  44750. /**
  44751. * Allows using the bump map in parallax mode.
  44752. */
  44753. useParallax: boolean;
  44754. /**
  44755. * Allows using the bump map in parallax occlusion mode.
  44756. */
  44757. useParallaxOcclusion: boolean;
  44758. /**
  44759. * Controls the scale bias of the parallax mode.
  44760. */
  44761. parallaxScaleBias: number;
  44762. /**
  44763. * If sets to true, disables all the lights affecting the material.
  44764. */
  44765. disableLighting: boolean;
  44766. /**
  44767. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44768. */
  44769. forceIrradianceInFragment: boolean;
  44770. /**
  44771. * Number of Simultaneous lights allowed on the material.
  44772. */
  44773. maxSimultaneousLights: number;
  44774. /**
  44775. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44776. */
  44777. invertNormalMapX: boolean;
  44778. /**
  44779. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44780. */
  44781. invertNormalMapY: boolean;
  44782. /**
  44783. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44784. */
  44785. twoSidedLighting: boolean;
  44786. /**
  44787. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44788. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44789. */
  44790. useAlphaFresnel: boolean;
  44791. /**
  44792. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44793. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44794. */
  44795. useLinearAlphaFresnel: boolean;
  44796. /**
  44797. * Let user defines the brdf lookup texture used for IBL.
  44798. * A default 8bit version is embedded but you could point at :
  44799. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  44800. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44801. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44802. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44803. */
  44804. environmentBRDFTexture: Nullable<BaseTexture>;
  44805. /**
  44806. * Force normal to face away from face.
  44807. */
  44808. forceNormalForward: boolean;
  44809. /**
  44810. * Enables specular anti aliasing in the PBR shader.
  44811. * It will both interacts on the Geometry for analytical and IBL lighting.
  44812. * It also prefilter the roughness map based on the bump values.
  44813. */
  44814. enableSpecularAntiAliasing: boolean;
  44815. /**
  44816. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44817. * makes the reflect vector face the model (under horizon).
  44818. */
  44819. useHorizonOcclusion: boolean;
  44820. /**
  44821. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44822. * too much the area relying on ambient texture to define their ambient occlusion.
  44823. */
  44824. useRadianceOcclusion: boolean;
  44825. /**
  44826. * If set to true, no lighting calculations will be applied.
  44827. */
  44828. unlit: boolean;
  44829. /**
  44830. * Gets the image processing configuration used either in this material.
  44831. */
  44832. /**
  44833. * Sets the Default image processing configuration used either in the this material.
  44834. *
  44835. * If sets to null, the scene one is in use.
  44836. */
  44837. imageProcessingConfiguration: ImageProcessingConfiguration;
  44838. /**
  44839. * Gets wether the color curves effect is enabled.
  44840. */
  44841. /**
  44842. * Sets wether the color curves effect is enabled.
  44843. */
  44844. cameraColorCurvesEnabled: boolean;
  44845. /**
  44846. * Gets wether the color grading effect is enabled.
  44847. */
  44848. /**
  44849. * Gets wether the color grading effect is enabled.
  44850. */
  44851. cameraColorGradingEnabled: boolean;
  44852. /**
  44853. * Gets wether tonemapping is enabled or not.
  44854. */
  44855. /**
  44856. * Sets wether tonemapping is enabled or not
  44857. */
  44858. cameraToneMappingEnabled: boolean;
  44859. /**
  44860. * The camera exposure used on this material.
  44861. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44862. * This corresponds to a photographic exposure.
  44863. */
  44864. /**
  44865. * The camera exposure used on this material.
  44866. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44867. * This corresponds to a photographic exposure.
  44868. */
  44869. cameraExposure: number;
  44870. /**
  44871. * Gets The camera contrast used on this material.
  44872. */
  44873. /**
  44874. * Sets The camera contrast used on this material.
  44875. */
  44876. cameraContrast: number;
  44877. /**
  44878. * Gets the Color Grading 2D Lookup Texture.
  44879. */
  44880. /**
  44881. * Sets the Color Grading 2D Lookup Texture.
  44882. */
  44883. cameraColorGradingTexture: Nullable<BaseTexture>;
  44884. /**
  44885. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44886. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44887. * 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;
  44888. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44889. */
  44890. /**
  44891. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44892. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44893. * 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;
  44894. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44895. */
  44896. cameraColorCurves: Nullable<ColorCurves>;
  44897. /**
  44898. * Instantiates a new PBRMaterial instance.
  44899. *
  44900. * @param name The material name
  44901. * @param scene The scene the material will be use in.
  44902. */
  44903. constructor(name: string, scene: Scene);
  44904. /**
  44905. * Returns the name of this material class.
  44906. */
  44907. getClassName(): string;
  44908. /**
  44909. * Makes a duplicate of the current material.
  44910. * @param name - name to use for the new material.
  44911. */
  44912. clone(name: string): PBRMaterial;
  44913. /**
  44914. * Serializes this PBR Material.
  44915. * @returns - An object with the serialized material.
  44916. */
  44917. serialize(): any;
  44918. /**
  44919. * Parses a PBR Material from a serialized object.
  44920. * @param source - Serialized object.
  44921. * @param scene - BJS scene instance.
  44922. * @param rootUrl - url for the scene object
  44923. * @returns - PBRMaterial
  44924. */
  44925. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44926. }
  44927. }
  44928. declare module BABYLON {
  44929. /**
  44930. * Direct draw surface info
  44931. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  44932. */
  44933. export interface DDSInfo {
  44934. /**
  44935. * Width of the texture
  44936. */
  44937. width: number;
  44938. /**
  44939. * Width of the texture
  44940. */
  44941. height: number;
  44942. /**
  44943. * Number of Mipmaps for the texture
  44944. * @see https://en.wikipedia.org/wiki/Mipmap
  44945. */
  44946. mipmapCount: number;
  44947. /**
  44948. * If the textures format is a known fourCC format
  44949. * @see https://www.fourcc.org/
  44950. */
  44951. isFourCC: boolean;
  44952. /**
  44953. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  44954. */
  44955. isRGB: boolean;
  44956. /**
  44957. * If the texture is a lumincance format
  44958. */
  44959. isLuminance: boolean;
  44960. /**
  44961. * If this is a cube texture
  44962. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  44963. */
  44964. isCube: boolean;
  44965. /**
  44966. * If the texture is a compressed format eg. FOURCC_DXT1
  44967. */
  44968. isCompressed: boolean;
  44969. /**
  44970. * The dxgiFormat of the texture
  44971. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  44972. */
  44973. dxgiFormat: number;
  44974. /**
  44975. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  44976. */
  44977. textureType: number;
  44978. /**
  44979. * Sphericle polynomial created for the dds texture
  44980. */
  44981. sphericalPolynomial?: SphericalPolynomial;
  44982. }
  44983. /**
  44984. * Class used to provide DDS decompression tools
  44985. */
  44986. export class DDSTools {
  44987. /**
  44988. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  44989. */
  44990. static StoreLODInAlphaChannel: boolean;
  44991. /**
  44992. * Gets DDS information from an array buffer
  44993. * @param arrayBuffer defines the array buffer to read data from
  44994. * @returns the DDS information
  44995. */
  44996. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  44997. private static _FloatView;
  44998. private static _Int32View;
  44999. private static _ToHalfFloat;
  45000. private static _FromHalfFloat;
  45001. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45002. private static _GetHalfFloatRGBAArrayBuffer;
  45003. private static _GetFloatRGBAArrayBuffer;
  45004. private static _GetFloatAsUIntRGBAArrayBuffer;
  45005. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45006. private static _GetRGBAArrayBuffer;
  45007. private static _ExtractLongWordOrder;
  45008. private static _GetRGBArrayBuffer;
  45009. private static _GetLuminanceArrayBuffer;
  45010. /**
  45011. * Uploads DDS Levels to a Babylon Texture
  45012. * @hidden
  45013. */
  45014. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45015. }
  45016. interface Engine {
  45017. /**
  45018. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45019. * @param rootUrl defines the url where the file to load is located
  45020. * @param scene defines the current scene
  45021. * @param lodScale defines scale to apply to the mip map selection
  45022. * @param lodOffset defines offset to apply to the mip map selection
  45023. * @param onLoad defines an optional callback raised when the texture is loaded
  45024. * @param onError defines an optional callback raised if there is an issue to load the texture
  45025. * @param format defines the format of the data
  45026. * @param forcedExtension defines the extension to use to pick the right loader
  45027. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45028. * @returns the cube texture as an InternalTexture
  45029. */
  45030. 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;
  45031. }
  45032. }
  45033. declare module BABYLON {
  45034. /**
  45035. * Implementation of the DDS Texture Loader.
  45036. * @hidden
  45037. */
  45038. export class _DDSTextureLoader implements IInternalTextureLoader {
  45039. /**
  45040. * Defines wether the loader supports cascade loading the different faces.
  45041. */
  45042. readonly supportCascades: boolean;
  45043. /**
  45044. * This returns if the loader support the current file information.
  45045. * @param extension defines the file extension of the file being loaded
  45046. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45047. * @param fallback defines the fallback internal texture if any
  45048. * @param isBase64 defines whether the texture is encoded as a base64
  45049. * @param isBuffer defines whether the texture data are stored as a buffer
  45050. * @returns true if the loader can load the specified file
  45051. */
  45052. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45053. /**
  45054. * Transform the url before loading if required.
  45055. * @param rootUrl the url of the texture
  45056. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45057. * @returns the transformed texture
  45058. */
  45059. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45060. /**
  45061. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45062. * @param rootUrl the url of the texture
  45063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45064. * @returns the fallback texture
  45065. */
  45066. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45067. /**
  45068. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45069. * @param data contains the texture data
  45070. * @param texture defines the BabylonJS internal texture
  45071. * @param createPolynomials will be true if polynomials have been requested
  45072. * @param onLoad defines the callback to trigger once the texture is ready
  45073. * @param onError defines the callback to trigger in case of error
  45074. */
  45075. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45076. /**
  45077. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45078. * @param data contains the texture data
  45079. * @param texture defines the BabylonJS internal texture
  45080. * @param callback defines the method to call once ready to upload
  45081. */
  45082. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45083. }
  45084. }
  45085. declare module BABYLON {
  45086. /** @hidden */
  45087. export var rgbdEncodePixelShader: {
  45088. name: string;
  45089. shader: string;
  45090. };
  45091. }
  45092. declare module BABYLON {
  45093. /**
  45094. * Raw texture data and descriptor sufficient for WebGL texture upload
  45095. */
  45096. export interface EnvironmentTextureInfo {
  45097. /**
  45098. * Version of the environment map
  45099. */
  45100. version: number;
  45101. /**
  45102. * Width of image
  45103. */
  45104. width: number;
  45105. /**
  45106. * Irradiance information stored in the file.
  45107. */
  45108. irradiance: any;
  45109. /**
  45110. * Specular information stored in the file.
  45111. */
  45112. specular: any;
  45113. }
  45114. /**
  45115. * Sets of helpers addressing the serialization and deserialization of environment texture
  45116. * stored in a BabylonJS env file.
  45117. * Those files are usually stored as .env files.
  45118. */
  45119. export class EnvironmentTextureTools {
  45120. /**
  45121. * Magic number identifying the env file.
  45122. */
  45123. private static _MagicBytes;
  45124. /**
  45125. * Gets the environment info from an env file.
  45126. * @param data The array buffer containing the .env bytes.
  45127. * @returns the environment file info (the json header) if successfully parsed.
  45128. */
  45129. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45130. /**
  45131. * Creates an environment texture from a loaded cube texture.
  45132. * @param texture defines the cube texture to convert in env file
  45133. * @return a promise containing the environment data if succesfull.
  45134. */
  45135. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45136. /**
  45137. * Creates a JSON representation of the spherical data.
  45138. * @param texture defines the texture containing the polynomials
  45139. * @return the JSON representation of the spherical info
  45140. */
  45141. private static _CreateEnvTextureIrradiance;
  45142. /**
  45143. * Uploads the texture info contained in the env file to the GPU.
  45144. * @param texture defines the internal texture to upload to
  45145. * @param arrayBuffer defines the buffer cotaining the data to load
  45146. * @param info defines the texture info retrieved through the GetEnvInfo method
  45147. * @returns a promise
  45148. */
  45149. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45150. /**
  45151. * Uploads the levels of image data to the GPU.
  45152. * @param texture defines the internal texture to upload to
  45153. * @param imageData defines the array buffer views of image data [mipmap][face]
  45154. * @returns a promise
  45155. */
  45156. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45157. /**
  45158. * Uploads spherical polynomials information to the texture.
  45159. * @param texture defines the texture we are trying to upload the information to
  45160. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45161. */
  45162. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45163. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45164. }
  45165. }
  45166. declare module BABYLON {
  45167. /**
  45168. * Implementation of the ENV Texture Loader.
  45169. * @hidden
  45170. */
  45171. export class _ENVTextureLoader implements IInternalTextureLoader {
  45172. /**
  45173. * Defines wether the loader supports cascade loading the different faces.
  45174. */
  45175. readonly supportCascades: boolean;
  45176. /**
  45177. * This returns if the loader support the current file information.
  45178. * @param extension defines the file extension of the file being loaded
  45179. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45180. * @param fallback defines the fallback internal texture if any
  45181. * @param isBase64 defines whether the texture is encoded as a base64
  45182. * @param isBuffer defines whether the texture data are stored as a buffer
  45183. * @returns true if the loader can load the specified file
  45184. */
  45185. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45186. /**
  45187. * Transform the url before loading if required.
  45188. * @param rootUrl the url of the texture
  45189. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45190. * @returns the transformed texture
  45191. */
  45192. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45193. /**
  45194. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45195. * @param rootUrl the url of the texture
  45196. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45197. * @returns the fallback texture
  45198. */
  45199. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45200. /**
  45201. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45202. * @param data contains the texture data
  45203. * @param texture defines the BabylonJS internal texture
  45204. * @param createPolynomials will be true if polynomials have been requested
  45205. * @param onLoad defines the callback to trigger once the texture is ready
  45206. * @param onError defines the callback to trigger in case of error
  45207. */
  45208. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45209. /**
  45210. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45211. * @param data contains the texture data
  45212. * @param texture defines the BabylonJS internal texture
  45213. * @param callback defines the method to call once ready to upload
  45214. */
  45215. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45216. }
  45217. }
  45218. declare module BABYLON {
  45219. /**
  45220. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45221. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45222. */
  45223. export class KhronosTextureContainer {
  45224. /** contents of the KTX container file */
  45225. arrayBuffer: any;
  45226. private static HEADER_LEN;
  45227. private static COMPRESSED_2D;
  45228. private static COMPRESSED_3D;
  45229. private static TEX_2D;
  45230. private static TEX_3D;
  45231. /**
  45232. * Gets the openGL type
  45233. */
  45234. glType: number;
  45235. /**
  45236. * Gets the openGL type size
  45237. */
  45238. glTypeSize: number;
  45239. /**
  45240. * Gets the openGL format
  45241. */
  45242. glFormat: number;
  45243. /**
  45244. * Gets the openGL internal format
  45245. */
  45246. glInternalFormat: number;
  45247. /**
  45248. * Gets the base internal format
  45249. */
  45250. glBaseInternalFormat: number;
  45251. /**
  45252. * Gets image width in pixel
  45253. */
  45254. pixelWidth: number;
  45255. /**
  45256. * Gets image height in pixel
  45257. */
  45258. pixelHeight: number;
  45259. /**
  45260. * Gets image depth in pixels
  45261. */
  45262. pixelDepth: number;
  45263. /**
  45264. * Gets the number of array elements
  45265. */
  45266. numberOfArrayElements: number;
  45267. /**
  45268. * Gets the number of faces
  45269. */
  45270. numberOfFaces: number;
  45271. /**
  45272. * Gets the number of mipmap levels
  45273. */
  45274. numberOfMipmapLevels: number;
  45275. /**
  45276. * Gets the bytes of key value data
  45277. */
  45278. bytesOfKeyValueData: number;
  45279. /**
  45280. * Gets the load type
  45281. */
  45282. loadType: number;
  45283. /**
  45284. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45285. */
  45286. isInvalid: boolean;
  45287. /**
  45288. * Creates a new KhronosTextureContainer
  45289. * @param arrayBuffer contents of the KTX container file
  45290. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45291. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45292. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45293. */
  45294. constructor(
  45295. /** contents of the KTX container file */
  45296. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45297. /**
  45298. * Uploads KTX content to a Babylon Texture.
  45299. * It is assumed that the texture has already been created & is currently bound
  45300. * @hidden
  45301. */
  45302. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45303. private _upload2DCompressedLevels;
  45304. }
  45305. }
  45306. declare module BABYLON {
  45307. /**
  45308. * Implementation of the KTX Texture Loader.
  45309. * @hidden
  45310. */
  45311. export class _KTXTextureLoader implements IInternalTextureLoader {
  45312. /**
  45313. * Defines wether the loader supports cascade loading the different faces.
  45314. */
  45315. readonly supportCascades: boolean;
  45316. /**
  45317. * This returns if the loader support the current file information.
  45318. * @param extension defines the file extension of the file being loaded
  45319. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45320. * @param fallback defines the fallback internal texture if any
  45321. * @param isBase64 defines whether the texture is encoded as a base64
  45322. * @param isBuffer defines whether the texture data are stored as a buffer
  45323. * @returns true if the loader can load the specified file
  45324. */
  45325. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45326. /**
  45327. * Transform the url before loading if required.
  45328. * @param rootUrl the url of the texture
  45329. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45330. * @returns the transformed texture
  45331. */
  45332. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45333. /**
  45334. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45335. * @param rootUrl the url of the texture
  45336. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45337. * @returns the fallback texture
  45338. */
  45339. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45340. /**
  45341. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45342. * @param data contains the texture data
  45343. * @param texture defines the BabylonJS internal texture
  45344. * @param createPolynomials will be true if polynomials have been requested
  45345. * @param onLoad defines the callback to trigger once the texture is ready
  45346. * @param onError defines the callback to trigger in case of error
  45347. */
  45348. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45349. /**
  45350. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45351. * @param data contains the texture data
  45352. * @param texture defines the BabylonJS internal texture
  45353. * @param callback defines the method to call once ready to upload
  45354. */
  45355. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45356. }
  45357. }
  45358. declare module BABYLON {
  45359. /** @hidden */
  45360. export var _forceSceneHelpersToBundle: boolean;
  45361. interface Scene {
  45362. /**
  45363. * Creates a default light for the scene.
  45364. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45365. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45366. */
  45367. createDefaultLight(replace?: boolean): void;
  45368. /**
  45369. * Creates a default camera for the scene.
  45370. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45371. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45372. * @param replace has default false, when true replaces the active camera in the scene
  45373. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45374. */
  45375. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45376. /**
  45377. * Creates a default camera and a default light.
  45378. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45379. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45380. * @param replace has the default false, when true replaces the active camera/light in the scene
  45381. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45382. */
  45383. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45384. /**
  45385. * Creates a new sky box
  45386. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45387. * @param environmentTexture defines the texture to use as environment texture
  45388. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45389. * @param scale defines the overall scale of the skybox
  45390. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45391. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45392. * @returns a new mesh holding the sky box
  45393. */
  45394. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45395. /**
  45396. * Creates a new environment
  45397. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45398. * @param options defines the options you can use to configure the environment
  45399. * @returns the new EnvironmentHelper
  45400. */
  45401. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45402. /**
  45403. * Creates a new VREXperienceHelper
  45404. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45405. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45406. * @returns a new VREXperienceHelper
  45407. */
  45408. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45409. /**
  45410. * Creates a new XREXperienceHelper
  45411. * @see http://doc.babylonjs.com/how_to/webxr
  45412. * @returns a promise for a new XREXperienceHelper
  45413. */
  45414. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45415. }
  45416. }
  45417. declare module BABYLON {
  45418. /**
  45419. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45420. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45421. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45422. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45423. */
  45424. export class VideoDome extends TransformNode {
  45425. /**
  45426. * Define the video source as a Monoscopic panoramic 360 video.
  45427. */
  45428. static readonly MODE_MONOSCOPIC: number;
  45429. /**
  45430. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45431. */
  45432. static readonly MODE_TOPBOTTOM: number;
  45433. /**
  45434. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45435. */
  45436. static readonly MODE_SIDEBYSIDE: number;
  45437. private _useDirectMapping;
  45438. /**
  45439. * The video texture being displayed on the sphere
  45440. */
  45441. protected _videoTexture: VideoTexture;
  45442. /**
  45443. * Gets the video texture being displayed on the sphere
  45444. */
  45445. readonly videoTexture: VideoTexture;
  45446. /**
  45447. * The skybox material
  45448. */
  45449. protected _material: BackgroundMaterial;
  45450. /**
  45451. * The surface used for the skybox
  45452. */
  45453. protected _mesh: Mesh;
  45454. /**
  45455. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45456. * Also see the options.resolution property.
  45457. */
  45458. fovMultiplier: number;
  45459. private _videoMode;
  45460. /**
  45461. * Gets or set the current video mode for the video. It can be:
  45462. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45463. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45464. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45465. */
  45466. videoMode: number;
  45467. /**
  45468. * Oberserver used in Stereoscopic VR Mode.
  45469. */
  45470. private _onBeforeCameraRenderObserver;
  45471. /**
  45472. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45473. * @param name Element's name, child elements will append suffixes for their own names.
  45474. * @param urlsOrVideo defines the url(s) or the video element to use
  45475. * @param options An object containing optional or exposed sub element properties
  45476. */
  45477. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45478. resolution?: number;
  45479. clickToPlay?: boolean;
  45480. autoPlay?: boolean;
  45481. loop?: boolean;
  45482. size?: number;
  45483. poster?: string;
  45484. faceForward?: boolean;
  45485. useDirectMapping?: boolean;
  45486. }, scene: Scene);
  45487. private _changeVideoMode;
  45488. /**
  45489. * Releases resources associated with this node.
  45490. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45491. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45492. */
  45493. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45494. }
  45495. }
  45496. declare module BABYLON {
  45497. /**
  45498. * This class can be used to get instrumentation data from a Babylon engine
  45499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45500. */
  45501. export class EngineInstrumentation implements IDisposable {
  45502. /**
  45503. * Define the instrumented engine.
  45504. */
  45505. engine: Engine;
  45506. private _captureGPUFrameTime;
  45507. private _gpuFrameTimeToken;
  45508. private _gpuFrameTime;
  45509. private _captureShaderCompilationTime;
  45510. private _shaderCompilationTime;
  45511. private _onBeginFrameObserver;
  45512. private _onEndFrameObserver;
  45513. private _onBeforeShaderCompilationObserver;
  45514. private _onAfterShaderCompilationObserver;
  45515. /**
  45516. * Gets the perf counter used for GPU frame time
  45517. */
  45518. readonly gpuFrameTimeCounter: PerfCounter;
  45519. /**
  45520. * Gets the GPU frame time capture status
  45521. */
  45522. /**
  45523. * Enable or disable the GPU frame time capture
  45524. */
  45525. captureGPUFrameTime: boolean;
  45526. /**
  45527. * Gets the perf counter used for shader compilation time
  45528. */
  45529. readonly shaderCompilationTimeCounter: PerfCounter;
  45530. /**
  45531. * Gets the shader compilation time capture status
  45532. */
  45533. /**
  45534. * Enable or disable the shader compilation time capture
  45535. */
  45536. captureShaderCompilationTime: boolean;
  45537. /**
  45538. * Instantiates a new engine instrumentation.
  45539. * This class can be used to get instrumentation data from a Babylon engine
  45540. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45541. * @param engine Defines the engine to instrument
  45542. */
  45543. constructor(
  45544. /**
  45545. * Define the instrumented engine.
  45546. */
  45547. engine: Engine);
  45548. /**
  45549. * Dispose and release associated resources.
  45550. */
  45551. dispose(): void;
  45552. }
  45553. }
  45554. declare module BABYLON {
  45555. /**
  45556. * This class can be used to get instrumentation data from a Babylon engine
  45557. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45558. */
  45559. export class SceneInstrumentation implements IDisposable {
  45560. /**
  45561. * Defines the scene to instrument
  45562. */
  45563. scene: Scene;
  45564. private _captureActiveMeshesEvaluationTime;
  45565. private _activeMeshesEvaluationTime;
  45566. private _captureRenderTargetsRenderTime;
  45567. private _renderTargetsRenderTime;
  45568. private _captureFrameTime;
  45569. private _frameTime;
  45570. private _captureRenderTime;
  45571. private _renderTime;
  45572. private _captureInterFrameTime;
  45573. private _interFrameTime;
  45574. private _captureParticlesRenderTime;
  45575. private _particlesRenderTime;
  45576. private _captureSpritesRenderTime;
  45577. private _spritesRenderTime;
  45578. private _capturePhysicsTime;
  45579. private _physicsTime;
  45580. private _captureAnimationsTime;
  45581. private _animationsTime;
  45582. private _captureCameraRenderTime;
  45583. private _cameraRenderTime;
  45584. private _onBeforeActiveMeshesEvaluationObserver;
  45585. private _onAfterActiveMeshesEvaluationObserver;
  45586. private _onBeforeRenderTargetsRenderObserver;
  45587. private _onAfterRenderTargetsRenderObserver;
  45588. private _onAfterRenderObserver;
  45589. private _onBeforeDrawPhaseObserver;
  45590. private _onAfterDrawPhaseObserver;
  45591. private _onBeforeAnimationsObserver;
  45592. private _onBeforeParticlesRenderingObserver;
  45593. private _onAfterParticlesRenderingObserver;
  45594. private _onBeforeSpritesRenderingObserver;
  45595. private _onAfterSpritesRenderingObserver;
  45596. private _onBeforePhysicsObserver;
  45597. private _onAfterPhysicsObserver;
  45598. private _onAfterAnimationsObserver;
  45599. private _onBeforeCameraRenderObserver;
  45600. private _onAfterCameraRenderObserver;
  45601. /**
  45602. * Gets the perf counter used for active meshes evaluation time
  45603. */
  45604. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45605. /**
  45606. * Gets the active meshes evaluation time capture status
  45607. */
  45608. /**
  45609. * Enable or disable the active meshes evaluation time capture
  45610. */
  45611. captureActiveMeshesEvaluationTime: boolean;
  45612. /**
  45613. * Gets the perf counter used for render targets render time
  45614. */
  45615. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45616. /**
  45617. * Gets the render targets render time capture status
  45618. */
  45619. /**
  45620. * Enable or disable the render targets render time capture
  45621. */
  45622. captureRenderTargetsRenderTime: boolean;
  45623. /**
  45624. * Gets the perf counter used for particles render time
  45625. */
  45626. readonly particlesRenderTimeCounter: PerfCounter;
  45627. /**
  45628. * Gets the particles render time capture status
  45629. */
  45630. /**
  45631. * Enable or disable the particles render time capture
  45632. */
  45633. captureParticlesRenderTime: boolean;
  45634. /**
  45635. * Gets the perf counter used for sprites render time
  45636. */
  45637. readonly spritesRenderTimeCounter: PerfCounter;
  45638. /**
  45639. * Gets the sprites render time capture status
  45640. */
  45641. /**
  45642. * Enable or disable the sprites render time capture
  45643. */
  45644. captureSpritesRenderTime: boolean;
  45645. /**
  45646. * Gets the perf counter used for physics time
  45647. */
  45648. readonly physicsTimeCounter: PerfCounter;
  45649. /**
  45650. * Gets the physics time capture status
  45651. */
  45652. /**
  45653. * Enable or disable the physics time capture
  45654. */
  45655. capturePhysicsTime: boolean;
  45656. /**
  45657. * Gets the perf counter used for animations time
  45658. */
  45659. readonly animationsTimeCounter: PerfCounter;
  45660. /**
  45661. * Gets the animations time capture status
  45662. */
  45663. /**
  45664. * Enable or disable the animations time capture
  45665. */
  45666. captureAnimationsTime: boolean;
  45667. /**
  45668. * Gets the perf counter used for frame time capture
  45669. */
  45670. readonly frameTimeCounter: PerfCounter;
  45671. /**
  45672. * Gets the frame time capture status
  45673. */
  45674. /**
  45675. * Enable or disable the frame time capture
  45676. */
  45677. captureFrameTime: boolean;
  45678. /**
  45679. * Gets the perf counter used for inter-frames time capture
  45680. */
  45681. readonly interFrameTimeCounter: PerfCounter;
  45682. /**
  45683. * Gets the inter-frames time capture status
  45684. */
  45685. /**
  45686. * Enable or disable the inter-frames time capture
  45687. */
  45688. captureInterFrameTime: boolean;
  45689. /**
  45690. * Gets the perf counter used for render time capture
  45691. */
  45692. readonly renderTimeCounter: PerfCounter;
  45693. /**
  45694. * Gets the render time capture status
  45695. */
  45696. /**
  45697. * Enable or disable the render time capture
  45698. */
  45699. captureRenderTime: boolean;
  45700. /**
  45701. * Gets the perf counter used for camera render time capture
  45702. */
  45703. readonly cameraRenderTimeCounter: PerfCounter;
  45704. /**
  45705. * Gets the camera render time capture status
  45706. */
  45707. /**
  45708. * Enable or disable the camera render time capture
  45709. */
  45710. captureCameraRenderTime: boolean;
  45711. /**
  45712. * Gets the perf counter used for draw calls
  45713. */
  45714. readonly drawCallsCounter: PerfCounter;
  45715. /**
  45716. * Instantiates a new scene instrumentation.
  45717. * This class can be used to get instrumentation data from a Babylon engine
  45718. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45719. * @param scene Defines the scene to instrument
  45720. */
  45721. constructor(
  45722. /**
  45723. * Defines the scene to instrument
  45724. */
  45725. scene: Scene);
  45726. /**
  45727. * Dispose and release associated resources.
  45728. */
  45729. dispose(): void;
  45730. }
  45731. }
  45732. declare module BABYLON {
  45733. /** @hidden */
  45734. export var glowMapGenerationPixelShader: {
  45735. name: string;
  45736. shader: string;
  45737. };
  45738. }
  45739. declare module BABYLON {
  45740. /** @hidden */
  45741. export var glowMapGenerationVertexShader: {
  45742. name: string;
  45743. shader: string;
  45744. };
  45745. }
  45746. declare module BABYLON {
  45747. /**
  45748. * Effect layer options. This helps customizing the behaviour
  45749. * of the effect layer.
  45750. */
  45751. export interface IEffectLayerOptions {
  45752. /**
  45753. * Multiplication factor apply to the canvas size to compute the render target size
  45754. * used to generated the objects (the smaller the faster).
  45755. */
  45756. mainTextureRatio: number;
  45757. /**
  45758. * Enforces a fixed size texture to ensure effect stability across devices.
  45759. */
  45760. mainTextureFixedSize?: number;
  45761. /**
  45762. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45763. */
  45764. alphaBlendingMode: number;
  45765. /**
  45766. * The camera attached to the layer.
  45767. */
  45768. camera: Nullable<Camera>;
  45769. /**
  45770. * The rendering group to draw the layer in.
  45771. */
  45772. renderingGroupId: number;
  45773. }
  45774. /**
  45775. * The effect layer Helps adding post process effect blended with the main pass.
  45776. *
  45777. * This can be for instance use to generate glow or higlight effects on the scene.
  45778. *
  45779. * The effect layer class can not be used directly and is intented to inherited from to be
  45780. * customized per effects.
  45781. */
  45782. export abstract class EffectLayer {
  45783. private _vertexBuffers;
  45784. private _indexBuffer;
  45785. private _cachedDefines;
  45786. private _effectLayerMapGenerationEffect;
  45787. private _effectLayerOptions;
  45788. private _mergeEffect;
  45789. protected _scene: Scene;
  45790. protected _engine: Engine;
  45791. protected _maxSize: number;
  45792. protected _mainTextureDesiredSize: ISize;
  45793. protected _mainTexture: RenderTargetTexture;
  45794. protected _shouldRender: boolean;
  45795. protected _postProcesses: PostProcess[];
  45796. protected _textures: BaseTexture[];
  45797. protected _emissiveTextureAndColor: {
  45798. texture: Nullable<BaseTexture>;
  45799. color: Color4;
  45800. };
  45801. /**
  45802. * The name of the layer
  45803. */
  45804. name: string;
  45805. /**
  45806. * The clear color of the texture used to generate the glow map.
  45807. */
  45808. neutralColor: Color4;
  45809. /**
  45810. * Specifies wether the highlight layer is enabled or not.
  45811. */
  45812. isEnabled: boolean;
  45813. /**
  45814. * Gets the camera attached to the layer.
  45815. */
  45816. readonly camera: Nullable<Camera>;
  45817. /**
  45818. * Gets the rendering group id the layer should render in.
  45819. */
  45820. readonly renderingGroupId: number;
  45821. /**
  45822. * An event triggered when the effect layer has been disposed.
  45823. */
  45824. onDisposeObservable: Observable<EffectLayer>;
  45825. /**
  45826. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45827. */
  45828. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45829. /**
  45830. * An event triggered when the generated texture is being merged in the scene.
  45831. */
  45832. onBeforeComposeObservable: Observable<EffectLayer>;
  45833. /**
  45834. * An event triggered when the generated texture has been merged in the scene.
  45835. */
  45836. onAfterComposeObservable: Observable<EffectLayer>;
  45837. /**
  45838. * An event triggered when the efffect layer changes its size.
  45839. */
  45840. onSizeChangedObservable: Observable<EffectLayer>;
  45841. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  45842. /**
  45843. * Instantiates a new effect Layer and references it in the scene.
  45844. * @param name The name of the layer
  45845. * @param scene The scene to use the layer in
  45846. */
  45847. constructor(
  45848. /** The Friendly of the effect in the scene */
  45849. name: string, scene: Scene);
  45850. /**
  45851. * Get the effect name of the layer.
  45852. * @return The effect name
  45853. */
  45854. abstract getEffectName(): string;
  45855. /**
  45856. * Checks for the readiness of the element composing the layer.
  45857. * @param subMesh the mesh to check for
  45858. * @param useInstances specify wether or not to use instances to render the mesh
  45859. * @return true if ready otherwise, false
  45860. */
  45861. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45862. /**
  45863. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45864. * @returns true if the effect requires stencil during the main canvas render pass.
  45865. */
  45866. abstract needStencil(): boolean;
  45867. /**
  45868. * Create the merge effect. This is the shader use to blit the information back
  45869. * to the main canvas at the end of the scene rendering.
  45870. * @returns The effect containing the shader used to merge the effect on the main canvas
  45871. */
  45872. protected abstract _createMergeEffect(): Effect;
  45873. /**
  45874. * Creates the render target textures and post processes used in the effect layer.
  45875. */
  45876. protected abstract _createTextureAndPostProcesses(): void;
  45877. /**
  45878. * Implementation specific of rendering the generating effect on the main canvas.
  45879. * @param effect The effect used to render through
  45880. */
  45881. protected abstract _internalRender(effect: Effect): void;
  45882. /**
  45883. * Sets the required values for both the emissive texture and and the main color.
  45884. */
  45885. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45886. /**
  45887. * Free any resources and references associated to a mesh.
  45888. * Internal use
  45889. * @param mesh The mesh to free.
  45890. */
  45891. abstract _disposeMesh(mesh: Mesh): void;
  45892. /**
  45893. * Serializes this layer (Glow or Highlight for example)
  45894. * @returns a serialized layer object
  45895. */
  45896. abstract serialize?(): any;
  45897. /**
  45898. * Initializes the effect layer with the required options.
  45899. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45900. */
  45901. protected _init(options: Partial<IEffectLayerOptions>): void;
  45902. /**
  45903. * Generates the index buffer of the full screen quad blending to the main canvas.
  45904. */
  45905. private _generateIndexBuffer;
  45906. /**
  45907. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45908. */
  45909. private _genrateVertexBuffer;
  45910. /**
  45911. * Sets the main texture desired size which is the closest power of two
  45912. * of the engine canvas size.
  45913. */
  45914. private _setMainTextureSize;
  45915. /**
  45916. * Creates the main texture for the effect layer.
  45917. */
  45918. protected _createMainTexture(): void;
  45919. /**
  45920. * Adds specific effects defines.
  45921. * @param defines The defines to add specifics to.
  45922. */
  45923. protected _addCustomEffectDefines(defines: string[]): void;
  45924. /**
  45925. * Checks for the readiness of the element composing the layer.
  45926. * @param subMesh the mesh to check for
  45927. * @param useInstances specify wether or not to use instances to render the mesh
  45928. * @param emissiveTexture the associated emissive texture used to generate the glow
  45929. * @return true if ready otherwise, false
  45930. */
  45931. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45932. /**
  45933. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45934. */
  45935. render(): void;
  45936. /**
  45937. * Determine if a given mesh will be used in the current effect.
  45938. * @param mesh mesh to test
  45939. * @returns true if the mesh will be used
  45940. */
  45941. hasMesh(mesh: AbstractMesh): boolean;
  45942. /**
  45943. * Returns true if the layer contains information to display, otherwise false.
  45944. * @returns true if the glow layer should be rendered
  45945. */
  45946. shouldRender(): boolean;
  45947. /**
  45948. * Returns true if the mesh should render, otherwise false.
  45949. * @param mesh The mesh to render
  45950. * @returns true if it should render otherwise false
  45951. */
  45952. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45953. /**
  45954. * Returns true if the mesh can be rendered, otherwise false.
  45955. * @param mesh The mesh to render
  45956. * @param material The material used on the mesh
  45957. * @returns true if it can be rendered otherwise false
  45958. */
  45959. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45960. /**
  45961. * Returns true if the mesh should render, otherwise false.
  45962. * @param mesh The mesh to render
  45963. * @returns true if it should render otherwise false
  45964. */
  45965. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45966. /**
  45967. * Renders the submesh passed in parameter to the generation map.
  45968. */
  45969. protected _renderSubMesh(subMesh: SubMesh): void;
  45970. /**
  45971. * Rebuild the required buffers.
  45972. * @hidden Internal use only.
  45973. */ rebuild(): void;
  45974. /**
  45975. * Dispose only the render target textures and post process.
  45976. */
  45977. private _disposeTextureAndPostProcesses;
  45978. /**
  45979. * Dispose the highlight layer and free resources.
  45980. */
  45981. dispose(): void;
  45982. /**
  45983. * Gets the class name of the effect layer
  45984. * @returns the string with the class name of the effect layer
  45985. */
  45986. getClassName(): string;
  45987. /**
  45988. * Creates an effect layer from parsed effect layer data
  45989. * @param parsedEffectLayer defines effect layer data
  45990. * @param scene defines the current scene
  45991. * @param rootUrl defines the root URL containing the effect layer information
  45992. * @returns a parsed effect Layer
  45993. */
  45994. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45995. }
  45996. }
  45997. declare module BABYLON {
  45998. interface AbstractScene {
  45999. /**
  46000. * The list of effect layers (highlights/glow) added to the scene
  46001. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46002. * @see http://doc.babylonjs.com/how_to/glow_layer
  46003. */
  46004. effectLayers: Array<EffectLayer>;
  46005. /**
  46006. * Removes the given effect layer from this scene.
  46007. * @param toRemove defines the effect layer to remove
  46008. * @returns the index of the removed effect layer
  46009. */
  46010. removeEffectLayer(toRemove: EffectLayer): number;
  46011. /**
  46012. * Adds the given effect layer to this scene
  46013. * @param newEffectLayer defines the effect layer to add
  46014. */
  46015. addEffectLayer(newEffectLayer: EffectLayer): void;
  46016. }
  46017. /**
  46018. * Defines the layer scene component responsible to manage any effect layers
  46019. * in a given scene.
  46020. */
  46021. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46022. /**
  46023. * The component name helpfull to identify the component in the list of scene components.
  46024. */
  46025. readonly name: string;
  46026. /**
  46027. * The scene the component belongs to.
  46028. */
  46029. scene: Scene;
  46030. private _engine;
  46031. private _renderEffects;
  46032. private _needStencil;
  46033. private _previousStencilState;
  46034. /**
  46035. * Creates a new instance of the component for the given scene
  46036. * @param scene Defines the scene to register the component in
  46037. */
  46038. constructor(scene: Scene);
  46039. /**
  46040. * Registers the component in a given scene
  46041. */
  46042. register(): void;
  46043. /**
  46044. * Rebuilds the elements related to this component in case of
  46045. * context lost for instance.
  46046. */
  46047. rebuild(): void;
  46048. /**
  46049. * Serializes the component data to the specified json object
  46050. * @param serializationObject The object to serialize to
  46051. */
  46052. serialize(serializationObject: any): void;
  46053. /**
  46054. * Adds all the element from the container to the scene
  46055. * @param container the container holding the elements
  46056. */
  46057. addFromContainer(container: AbstractScene): void;
  46058. /**
  46059. * Removes all the elements in the container from the scene
  46060. * @param container contains the elements to remove
  46061. * @param dispose if the removed element should be disposed (default: false)
  46062. */
  46063. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46064. /**
  46065. * Disposes the component and the associated ressources.
  46066. */
  46067. dispose(): void;
  46068. private _isReadyForMesh;
  46069. private _renderMainTexture;
  46070. private _setStencil;
  46071. private _setStencilBack;
  46072. private _draw;
  46073. private _drawCamera;
  46074. private _drawRenderingGroup;
  46075. }
  46076. }
  46077. declare module BABYLON {
  46078. /** @hidden */
  46079. export var glowMapMergePixelShader: {
  46080. name: string;
  46081. shader: string;
  46082. };
  46083. }
  46084. declare module BABYLON {
  46085. /** @hidden */
  46086. export var glowMapMergeVertexShader: {
  46087. name: string;
  46088. shader: string;
  46089. };
  46090. }
  46091. declare module BABYLON {
  46092. interface AbstractScene {
  46093. /**
  46094. * Return a the first highlight layer of the scene with a given name.
  46095. * @param name The name of the highlight layer to look for.
  46096. * @return The highlight layer if found otherwise null.
  46097. */
  46098. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46099. }
  46100. /**
  46101. * Glow layer options. This helps customizing the behaviour
  46102. * of the glow layer.
  46103. */
  46104. export interface IGlowLayerOptions {
  46105. /**
  46106. * Multiplication factor apply to the canvas size to compute the render target size
  46107. * used to generated the glowing objects (the smaller the faster).
  46108. */
  46109. mainTextureRatio: number;
  46110. /**
  46111. * Enforces a fixed size texture to ensure resize independant blur.
  46112. */
  46113. mainTextureFixedSize?: number;
  46114. /**
  46115. * How big is the kernel of the blur texture.
  46116. */
  46117. blurKernelSize: number;
  46118. /**
  46119. * The camera attached to the layer.
  46120. */
  46121. camera: Nullable<Camera>;
  46122. /**
  46123. * Enable MSAA by chosing the number of samples.
  46124. */
  46125. mainTextureSamples?: number;
  46126. /**
  46127. * The rendering group to draw the layer in.
  46128. */
  46129. renderingGroupId: number;
  46130. }
  46131. /**
  46132. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46133. *
  46134. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46135. * glowy meshes to your scene.
  46136. *
  46137. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46138. */
  46139. export class GlowLayer extends EffectLayer {
  46140. /**
  46141. * Effect Name of the layer.
  46142. */
  46143. static readonly EffectName: string;
  46144. /**
  46145. * The default blur kernel size used for the glow.
  46146. */
  46147. static DefaultBlurKernelSize: number;
  46148. /**
  46149. * The default texture size ratio used for the glow.
  46150. */
  46151. static DefaultTextureRatio: number;
  46152. /**
  46153. * Sets the kernel size of the blur.
  46154. */
  46155. /**
  46156. * Gets the kernel size of the blur.
  46157. */
  46158. blurKernelSize: number;
  46159. /**
  46160. * Sets the glow intensity.
  46161. */
  46162. /**
  46163. * Gets the glow intensity.
  46164. */
  46165. intensity: number;
  46166. private _options;
  46167. private _intensity;
  46168. private _horizontalBlurPostprocess1;
  46169. private _verticalBlurPostprocess1;
  46170. private _horizontalBlurPostprocess2;
  46171. private _verticalBlurPostprocess2;
  46172. private _blurTexture1;
  46173. private _blurTexture2;
  46174. private _postProcesses1;
  46175. private _postProcesses2;
  46176. private _includedOnlyMeshes;
  46177. private _excludedMeshes;
  46178. /**
  46179. * Callback used to let the user override the color selection on a per mesh basis
  46180. */
  46181. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46182. /**
  46183. * Callback used to let the user override the texture selection on a per mesh basis
  46184. */
  46185. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46186. /**
  46187. * Instantiates a new glow Layer and references it to the scene.
  46188. * @param name The name of the layer
  46189. * @param scene The scene to use the layer in
  46190. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46191. */
  46192. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46193. /**
  46194. * Get the effect name of the layer.
  46195. * @return The effect name
  46196. */
  46197. getEffectName(): string;
  46198. /**
  46199. * Create the merge effect. This is the shader use to blit the information back
  46200. * to the main canvas at the end of the scene rendering.
  46201. */
  46202. protected _createMergeEffect(): Effect;
  46203. /**
  46204. * Creates the render target textures and post processes used in the glow layer.
  46205. */
  46206. protected _createTextureAndPostProcesses(): void;
  46207. /**
  46208. * Checks for the readiness of the element composing the layer.
  46209. * @param subMesh the mesh to check for
  46210. * @param useInstances specify wether or not to use instances to render the mesh
  46211. * @param emissiveTexture the associated emissive texture used to generate the glow
  46212. * @return true if ready otherwise, false
  46213. */
  46214. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46215. /**
  46216. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46217. */
  46218. needStencil(): boolean;
  46219. /**
  46220. * Returns true if the mesh can be rendered, otherwise false.
  46221. * @param mesh The mesh to render
  46222. * @param material The material used on the mesh
  46223. * @returns true if it can be rendered otherwise false
  46224. */
  46225. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46226. /**
  46227. * Implementation specific of rendering the generating effect on the main canvas.
  46228. * @param effect The effect used to render through
  46229. */
  46230. protected _internalRender(effect: Effect): void;
  46231. /**
  46232. * Sets the required values for both the emissive texture and and the main color.
  46233. */
  46234. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46235. /**
  46236. * Returns true if the mesh should render, otherwise false.
  46237. * @param mesh The mesh to render
  46238. * @returns true if it should render otherwise false
  46239. */
  46240. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46241. /**
  46242. * Adds specific effects defines.
  46243. * @param defines The defines to add specifics to.
  46244. */
  46245. protected _addCustomEffectDefines(defines: string[]): void;
  46246. /**
  46247. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46248. * @param mesh The mesh to exclude from the glow layer
  46249. */
  46250. addExcludedMesh(mesh: Mesh): void;
  46251. /**
  46252. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46253. * @param mesh The mesh to remove
  46254. */
  46255. removeExcludedMesh(mesh: Mesh): void;
  46256. /**
  46257. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46258. * @param mesh The mesh to include in the glow layer
  46259. */
  46260. addIncludedOnlyMesh(mesh: Mesh): void;
  46261. /**
  46262. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46263. * @param mesh The mesh to remove
  46264. */
  46265. removeIncludedOnlyMesh(mesh: Mesh): void;
  46266. /**
  46267. * Determine if a given mesh will be used in the glow layer
  46268. * @param mesh The mesh to test
  46269. * @returns true if the mesh will be highlighted by the current glow layer
  46270. */
  46271. hasMesh(mesh: AbstractMesh): boolean;
  46272. /**
  46273. * Free any resources and references associated to a mesh.
  46274. * Internal use
  46275. * @param mesh The mesh to free.
  46276. * @hidden
  46277. */ disposeMesh(mesh: Mesh): void;
  46278. /**
  46279. * Gets the class name of the effect layer
  46280. * @returns the string with the class name of the effect layer
  46281. */
  46282. getClassName(): string;
  46283. /**
  46284. * Serializes this glow layer
  46285. * @returns a serialized glow layer object
  46286. */
  46287. serialize(): any;
  46288. /**
  46289. * Creates a Glow Layer from parsed glow layer data
  46290. * @param parsedGlowLayer defines glow layer data
  46291. * @param scene defines the current scene
  46292. * @param rootUrl defines the root URL containing the glow layer information
  46293. * @returns a parsed Glow Layer
  46294. */
  46295. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46296. }
  46297. }
  46298. declare module BABYLON {
  46299. /** @hidden */
  46300. export var glowBlurPostProcessPixelShader: {
  46301. name: string;
  46302. shader: string;
  46303. };
  46304. }
  46305. declare module BABYLON {
  46306. interface AbstractScene {
  46307. /**
  46308. * Return a the first highlight layer of the scene with a given name.
  46309. * @param name The name of the highlight layer to look for.
  46310. * @return The highlight layer if found otherwise null.
  46311. */
  46312. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46313. }
  46314. /**
  46315. * Highlight layer options. This helps customizing the behaviour
  46316. * of the highlight layer.
  46317. */
  46318. export interface IHighlightLayerOptions {
  46319. /**
  46320. * Multiplication factor apply to the canvas size to compute the render target size
  46321. * used to generated the glowing objects (the smaller the faster).
  46322. */
  46323. mainTextureRatio: number;
  46324. /**
  46325. * Enforces a fixed size texture to ensure resize independant blur.
  46326. */
  46327. mainTextureFixedSize?: number;
  46328. /**
  46329. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46330. * of the picture to blur (the smaller the faster).
  46331. */
  46332. blurTextureSizeRatio: number;
  46333. /**
  46334. * How big in texel of the blur texture is the vertical blur.
  46335. */
  46336. blurVerticalSize: number;
  46337. /**
  46338. * How big in texel of the blur texture is the horizontal blur.
  46339. */
  46340. blurHorizontalSize: number;
  46341. /**
  46342. * Alpha blending mode used to apply the blur. Default is combine.
  46343. */
  46344. alphaBlendingMode: number;
  46345. /**
  46346. * The camera attached to the layer.
  46347. */
  46348. camera: Nullable<Camera>;
  46349. /**
  46350. * Should we display highlight as a solid stroke?
  46351. */
  46352. isStroke?: boolean;
  46353. /**
  46354. * The rendering group to draw the layer in.
  46355. */
  46356. renderingGroupId: number;
  46357. }
  46358. /**
  46359. * The highlight layer Helps adding a glow effect around a mesh.
  46360. *
  46361. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46362. * glowy meshes to your scene.
  46363. *
  46364. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46365. */
  46366. export class HighlightLayer extends EffectLayer {
  46367. name: string;
  46368. /**
  46369. * Effect Name of the highlight layer.
  46370. */
  46371. static readonly EffectName: string;
  46372. /**
  46373. * The neutral color used during the preparation of the glow effect.
  46374. * This is black by default as the blend operation is a blend operation.
  46375. */
  46376. static NeutralColor: Color4;
  46377. /**
  46378. * Stencil value used for glowing meshes.
  46379. */
  46380. static GlowingMeshStencilReference: number;
  46381. /**
  46382. * Stencil value used for the other meshes in the scene.
  46383. */
  46384. static NormalMeshStencilReference: number;
  46385. /**
  46386. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46387. */
  46388. innerGlow: boolean;
  46389. /**
  46390. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46391. */
  46392. outerGlow: boolean;
  46393. /**
  46394. * Specifies the horizontal size of the blur.
  46395. */
  46396. /**
  46397. * Gets the horizontal size of the blur.
  46398. */
  46399. blurHorizontalSize: number;
  46400. /**
  46401. * Specifies the vertical size of the blur.
  46402. */
  46403. /**
  46404. * Gets the vertical size of the blur.
  46405. */
  46406. blurVerticalSize: number;
  46407. /**
  46408. * An event triggered when the highlight layer is being blurred.
  46409. */
  46410. onBeforeBlurObservable: Observable<HighlightLayer>;
  46411. /**
  46412. * An event triggered when the highlight layer has been blurred.
  46413. */
  46414. onAfterBlurObservable: Observable<HighlightLayer>;
  46415. private _instanceGlowingMeshStencilReference;
  46416. private _options;
  46417. private _downSamplePostprocess;
  46418. private _horizontalBlurPostprocess;
  46419. private _verticalBlurPostprocess;
  46420. private _blurTexture;
  46421. private _meshes;
  46422. private _excludedMeshes;
  46423. /**
  46424. * Instantiates a new highlight Layer and references it to the scene..
  46425. * @param name The name of the layer
  46426. * @param scene The scene to use the layer in
  46427. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46428. */
  46429. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46430. /**
  46431. * Get the effect name of the layer.
  46432. * @return The effect name
  46433. */
  46434. getEffectName(): string;
  46435. /**
  46436. * Create the merge effect. This is the shader use to blit the information back
  46437. * to the main canvas at the end of the scene rendering.
  46438. */
  46439. protected _createMergeEffect(): Effect;
  46440. /**
  46441. * Creates the render target textures and post processes used in the highlight layer.
  46442. */
  46443. protected _createTextureAndPostProcesses(): void;
  46444. /**
  46445. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46446. */
  46447. needStencil(): boolean;
  46448. /**
  46449. * Checks for the readiness of the element composing the layer.
  46450. * @param subMesh the mesh to check for
  46451. * @param useInstances specify wether or not to use instances to render the mesh
  46452. * @param emissiveTexture the associated emissive texture used to generate the glow
  46453. * @return true if ready otherwise, false
  46454. */
  46455. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46456. /**
  46457. * Implementation specific of rendering the generating effect on the main canvas.
  46458. * @param effect The effect used to render through
  46459. */
  46460. protected _internalRender(effect: Effect): void;
  46461. /**
  46462. * Returns true if the layer contains information to display, otherwise false.
  46463. */
  46464. shouldRender(): boolean;
  46465. /**
  46466. * Returns true if the mesh should render, otherwise false.
  46467. * @param mesh The mesh to render
  46468. * @returns true if it should render otherwise false
  46469. */
  46470. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46471. /**
  46472. * Sets the required values for both the emissive texture and and the main color.
  46473. */
  46474. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46475. /**
  46476. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46477. * @param mesh The mesh to exclude from the highlight layer
  46478. */
  46479. addExcludedMesh(mesh: Mesh): void;
  46480. /**
  46481. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46482. * @param mesh The mesh to highlight
  46483. */
  46484. removeExcludedMesh(mesh: Mesh): void;
  46485. /**
  46486. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46487. * @param mesh mesh to test
  46488. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46489. */
  46490. hasMesh(mesh: AbstractMesh): boolean;
  46491. /**
  46492. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46493. * @param mesh The mesh to highlight
  46494. * @param color The color of the highlight
  46495. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46496. */
  46497. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46498. /**
  46499. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46500. * @param mesh The mesh to highlight
  46501. */
  46502. removeMesh(mesh: Mesh): void;
  46503. /**
  46504. * Force the stencil to the normal expected value for none glowing parts
  46505. */
  46506. private _defaultStencilReference;
  46507. /**
  46508. * Free any resources and references associated to a mesh.
  46509. * Internal use
  46510. * @param mesh The mesh to free.
  46511. * @hidden
  46512. */ disposeMesh(mesh: Mesh): void;
  46513. /**
  46514. * Dispose the highlight layer and free resources.
  46515. */
  46516. dispose(): void;
  46517. /**
  46518. * Gets the class name of the effect layer
  46519. * @returns the string with the class name of the effect layer
  46520. */
  46521. getClassName(): string;
  46522. /**
  46523. * Serializes this Highlight layer
  46524. * @returns a serialized Highlight layer object
  46525. */
  46526. serialize(): any;
  46527. /**
  46528. * Creates a Highlight layer from parsed Highlight layer data
  46529. * @param parsedHightlightLayer defines the Highlight layer data
  46530. * @param scene defines the current scene
  46531. * @param rootUrl defines the root URL containing the Highlight layer information
  46532. * @returns a parsed Highlight layer
  46533. */
  46534. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46535. }
  46536. }
  46537. declare module BABYLON {
  46538. /** @hidden */
  46539. export var lensFlarePixelShader: {
  46540. name: string;
  46541. shader: string;
  46542. };
  46543. }
  46544. declare module BABYLON {
  46545. /** @hidden */
  46546. export var lensFlareVertexShader: {
  46547. name: string;
  46548. shader: string;
  46549. };
  46550. }
  46551. declare module BABYLON {
  46552. /**
  46553. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46554. * It is usually composed of several `lensFlare`.
  46555. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46556. */
  46557. export class LensFlareSystem {
  46558. /**
  46559. * Define the name of the lens flare system
  46560. */
  46561. name: string;
  46562. /**
  46563. * List of lens flares used in this system.
  46564. */
  46565. lensFlares: LensFlare[];
  46566. /**
  46567. * Define a limit from the border the lens flare can be visible.
  46568. */
  46569. borderLimit: number;
  46570. /**
  46571. * Define a viewport border we do not want to see the lens flare in.
  46572. */
  46573. viewportBorder: number;
  46574. /**
  46575. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46576. */
  46577. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46578. /**
  46579. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46580. */
  46581. layerMask: number;
  46582. /**
  46583. * Define the id of the lens flare system in the scene.
  46584. * (equal to name by default)
  46585. */
  46586. id: string;
  46587. private _scene;
  46588. private _emitter;
  46589. private _vertexBuffers;
  46590. private _indexBuffer;
  46591. private _effect;
  46592. private _positionX;
  46593. private _positionY;
  46594. private _isEnabled;
  46595. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46596. /**
  46597. * Instantiates a lens flare system.
  46598. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46599. * It is usually composed of several `lensFlare`.
  46600. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46601. * @param name Define the name of the lens flare system in the scene
  46602. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46603. * @param scene Define the scene the lens flare system belongs to
  46604. */
  46605. constructor(
  46606. /**
  46607. * Define the name of the lens flare system
  46608. */
  46609. name: string, emitter: any, scene: Scene);
  46610. /**
  46611. * Define if the lens flare system is enabled.
  46612. */
  46613. isEnabled: boolean;
  46614. /**
  46615. * Get the scene the effects belongs to.
  46616. * @returns the scene holding the lens flare system
  46617. */
  46618. getScene(): Scene;
  46619. /**
  46620. * Get the emitter of the lens flare system.
  46621. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46622. * @returns the emitter of the lens flare system
  46623. */
  46624. getEmitter(): any;
  46625. /**
  46626. * Set the emitter of the lens flare system.
  46627. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46628. * @param newEmitter Define the new emitter of the system
  46629. */
  46630. setEmitter(newEmitter: any): void;
  46631. /**
  46632. * Get the lens flare system emitter position.
  46633. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46634. * @returns the position
  46635. */
  46636. getEmitterPosition(): Vector3;
  46637. /**
  46638. * @hidden
  46639. */
  46640. computeEffectivePosition(globalViewport: Viewport): boolean;
  46641. /** @hidden */ isVisible(): boolean;
  46642. /**
  46643. * @hidden
  46644. */
  46645. render(): boolean;
  46646. /**
  46647. * Dispose and release the lens flare with its associated resources.
  46648. */
  46649. dispose(): void;
  46650. /**
  46651. * Parse a lens flare system from a JSON repressentation
  46652. * @param parsedLensFlareSystem Define the JSON to parse
  46653. * @param scene Define the scene the parsed system should be instantiated in
  46654. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46655. * @returns the parsed system
  46656. */
  46657. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46658. /**
  46659. * Serialize the current Lens Flare System into a JSON representation.
  46660. * @returns the serialized JSON
  46661. */
  46662. serialize(): any;
  46663. }
  46664. }
  46665. declare module BABYLON {
  46666. /**
  46667. * This represents one of the lens effect in a `lensFlareSystem`.
  46668. * It controls one of the indiviual texture used in the effect.
  46669. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46670. */
  46671. export class LensFlare {
  46672. /**
  46673. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46674. */
  46675. size: number;
  46676. /**
  46677. * 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.
  46678. */
  46679. position: number;
  46680. /**
  46681. * Define the lens color.
  46682. */
  46683. color: Color3;
  46684. /**
  46685. * Define the lens texture.
  46686. */
  46687. texture: Nullable<Texture>;
  46688. /**
  46689. * Define the alpha mode to render this particular lens.
  46690. */
  46691. alphaMode: number;
  46692. private _system;
  46693. /**
  46694. * Creates a new Lens Flare.
  46695. * This represents one of the lens effect in a `lensFlareSystem`.
  46696. * It controls one of the indiviual texture used in the effect.
  46697. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46698. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46699. * @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.
  46700. * @param color Define the lens color
  46701. * @param imgUrl Define the lens texture url
  46702. * @param system Define the `lensFlareSystem` this flare is part of
  46703. * @returns The newly created Lens Flare
  46704. */
  46705. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46706. /**
  46707. * Instantiates a new Lens Flare.
  46708. * This represents one of the lens effect in a `lensFlareSystem`.
  46709. * It controls one of the indiviual texture used in the effect.
  46710. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46711. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46712. * @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.
  46713. * @param color Define the lens color
  46714. * @param imgUrl Define the lens texture url
  46715. * @param system Define the `lensFlareSystem` this flare is part of
  46716. */
  46717. constructor(
  46718. /**
  46719. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46720. */
  46721. size: number,
  46722. /**
  46723. * 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.
  46724. */
  46725. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46726. /**
  46727. * Dispose and release the lens flare with its associated resources.
  46728. */
  46729. dispose(): void;
  46730. }
  46731. }
  46732. declare module BABYLON {
  46733. interface AbstractScene {
  46734. /**
  46735. * The list of lens flare system added to the scene
  46736. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46737. */
  46738. lensFlareSystems: Array<LensFlareSystem>;
  46739. /**
  46740. * Removes the given lens flare system from this scene.
  46741. * @param toRemove The lens flare system to remove
  46742. * @returns The index of the removed lens flare system
  46743. */
  46744. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46745. /**
  46746. * Adds the given lens flare system to this scene
  46747. * @param newLensFlareSystem The lens flare system to add
  46748. */
  46749. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46750. /**
  46751. * Gets a lens flare system using its name
  46752. * @param name defines the name to look for
  46753. * @returns the lens flare system or null if not found
  46754. */
  46755. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46756. /**
  46757. * Gets a lens flare system using its id
  46758. * @param id defines the id to look for
  46759. * @returns the lens flare system or null if not found
  46760. */
  46761. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46762. }
  46763. /**
  46764. * Defines the lens flare scene component responsible to manage any lens flares
  46765. * in a given scene.
  46766. */
  46767. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46768. /**
  46769. * The component name helpfull to identify the component in the list of scene components.
  46770. */
  46771. readonly name: string;
  46772. /**
  46773. * The scene the component belongs to.
  46774. */
  46775. scene: Scene;
  46776. /**
  46777. * Creates a new instance of the component for the given scene
  46778. * @param scene Defines the scene to register the component in
  46779. */
  46780. constructor(scene: Scene);
  46781. /**
  46782. * Registers the component in a given scene
  46783. */
  46784. register(): void;
  46785. /**
  46786. * Rebuilds the elements related to this component in case of
  46787. * context lost for instance.
  46788. */
  46789. rebuild(): void;
  46790. /**
  46791. * Adds all the element from the container to the scene
  46792. * @param container the container holding the elements
  46793. */
  46794. addFromContainer(container: AbstractScene): void;
  46795. /**
  46796. * Removes all the elements in the container from the scene
  46797. * @param container contains the elements to remove
  46798. * @param dispose if the removed element should be disposed (default: false)
  46799. */
  46800. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46801. /**
  46802. * Serializes the component data to the specified json object
  46803. * @param serializationObject The object to serialize to
  46804. */
  46805. serialize(serializationObject: any): void;
  46806. /**
  46807. * Disposes the component and the associated ressources.
  46808. */
  46809. dispose(): void;
  46810. private _draw;
  46811. }
  46812. }
  46813. declare module BABYLON {
  46814. /**
  46815. * Defines the shadow generator component responsible to manage any shadow generators
  46816. * in a given scene.
  46817. */
  46818. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46819. /**
  46820. * The component name helpfull to identify the component in the list of scene components.
  46821. */
  46822. readonly name: string;
  46823. /**
  46824. * The scene the component belongs to.
  46825. */
  46826. scene: Scene;
  46827. /**
  46828. * Creates a new instance of the component for the given scene
  46829. * @param scene Defines the scene to register the component in
  46830. */
  46831. constructor(scene: Scene);
  46832. /**
  46833. * Registers the component in a given scene
  46834. */
  46835. register(): void;
  46836. /**
  46837. * Rebuilds the elements related to this component in case of
  46838. * context lost for instance.
  46839. */
  46840. rebuild(): void;
  46841. /**
  46842. * Serializes the component data to the specified json object
  46843. * @param serializationObject The object to serialize to
  46844. */
  46845. serialize(serializationObject: any): void;
  46846. /**
  46847. * Adds all the element from the container to the scene
  46848. * @param container the container holding the elements
  46849. */
  46850. addFromContainer(container: AbstractScene): void;
  46851. /**
  46852. * Removes all the elements in the container from the scene
  46853. * @param container contains the elements to remove
  46854. * @param dispose if the removed element should be disposed (default: false)
  46855. */
  46856. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46857. /**
  46858. * Rebuilds the elements related to this component in case of
  46859. * context lost for instance.
  46860. */
  46861. dispose(): void;
  46862. private _gatherRenderTargets;
  46863. }
  46864. }
  46865. declare module BABYLON {
  46866. /**
  46867. * A point light is a light defined by an unique point in world space.
  46868. * The light is emitted in every direction from this point.
  46869. * A good example of a point light is a standard light bulb.
  46870. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46871. */
  46872. export class PointLight extends ShadowLight {
  46873. private _shadowAngle;
  46874. /**
  46875. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46876. * This specifies what angle the shadow will use to be created.
  46877. *
  46878. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46879. */
  46880. /**
  46881. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46882. * This specifies what angle the shadow will use to be created.
  46883. *
  46884. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46885. */
  46886. shadowAngle: number;
  46887. /**
  46888. * Gets the direction if it has been set.
  46889. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46890. */
  46891. /**
  46892. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46893. */
  46894. direction: Vector3;
  46895. /**
  46896. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46897. * A PointLight emits the light in every direction.
  46898. * It can cast shadows.
  46899. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46900. * ```javascript
  46901. * var pointLight = new PointLight("pl", camera.position, scene);
  46902. * ```
  46903. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46904. * @param name The light friendly name
  46905. * @param position The position of the point light in the scene
  46906. * @param scene The scene the lights belongs to
  46907. */
  46908. constructor(name: string, position: Vector3, scene: Scene);
  46909. /**
  46910. * Returns the string "PointLight"
  46911. * @returns the class name
  46912. */
  46913. getClassName(): string;
  46914. /**
  46915. * Returns the integer 0.
  46916. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46917. */
  46918. getTypeID(): number;
  46919. /**
  46920. * Specifies wether or not the shadowmap should be a cube texture.
  46921. * @returns true if the shadowmap needs to be a cube texture.
  46922. */
  46923. needCube(): boolean;
  46924. /**
  46925. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46926. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46927. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46928. */
  46929. getShadowDirection(faceIndex?: number): Vector3;
  46930. /**
  46931. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46932. * - fov = PI / 2
  46933. * - aspect ratio : 1.0
  46934. * - z-near and far equal to the active camera minZ and maxZ.
  46935. * Returns the PointLight.
  46936. */
  46937. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46938. protected _buildUniformLayout(): void;
  46939. /**
  46940. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46941. * @param effect The effect to update
  46942. * @param lightIndex The index of the light in the effect to update
  46943. * @returns The point light
  46944. */
  46945. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46946. /**
  46947. * Prepares the list of defines specific to the light type.
  46948. * @param defines the list of defines
  46949. * @param lightIndex defines the index of the light for the effect
  46950. */
  46951. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46952. }
  46953. }
  46954. declare module BABYLON {
  46955. /**
  46956. * Header information of HDR texture files.
  46957. */
  46958. export interface HDRInfo {
  46959. /**
  46960. * The height of the texture in pixels.
  46961. */
  46962. height: number;
  46963. /**
  46964. * The width of the texture in pixels.
  46965. */
  46966. width: number;
  46967. /**
  46968. * The index of the beginning of the data in the binary file.
  46969. */
  46970. dataPosition: number;
  46971. }
  46972. /**
  46973. * This groups tools to convert HDR texture to native colors array.
  46974. */
  46975. export class HDRTools {
  46976. private static Ldexp;
  46977. private static Rgbe2float;
  46978. private static readStringLine;
  46979. /**
  46980. * Reads header information from an RGBE texture stored in a native array.
  46981. * More information on this format are available here:
  46982. * https://en.wikipedia.org/wiki/RGBE_image_format
  46983. *
  46984. * @param uint8array The binary file stored in native array.
  46985. * @return The header information.
  46986. */
  46987. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  46988. /**
  46989. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  46990. * This RGBE texture needs to store the information as a panorama.
  46991. *
  46992. * More information on this format are available here:
  46993. * https://en.wikipedia.org/wiki/RGBE_image_format
  46994. *
  46995. * @param buffer The binary file stored in an array buffer.
  46996. * @param size The expected size of the extracted cubemap.
  46997. * @return The Cube Map information.
  46998. */
  46999. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47000. /**
  47001. * Returns the pixels data extracted from an RGBE texture.
  47002. * This pixels will be stored left to right up to down in the R G B order in one array.
  47003. *
  47004. * More information on this format are available here:
  47005. * https://en.wikipedia.org/wiki/RGBE_image_format
  47006. *
  47007. * @param uint8array The binary file stored in an array buffer.
  47008. * @param hdrInfo The header information of the file.
  47009. * @return The pixels data in RGB right to left up to down order.
  47010. */
  47011. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47012. private static RGBE_ReadPixels_RLE;
  47013. }
  47014. }
  47015. declare module BABYLON {
  47016. /**
  47017. * This represents a texture coming from an HDR input.
  47018. *
  47019. * The only supported format is currently panorama picture stored in RGBE format.
  47020. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47021. */
  47022. export class HDRCubeTexture extends BaseTexture {
  47023. private static _facesMapping;
  47024. private _generateHarmonics;
  47025. private _noMipmap;
  47026. private _textureMatrix;
  47027. private _size;
  47028. private _onLoad;
  47029. private _onError;
  47030. /**
  47031. * The texture URL.
  47032. */
  47033. url: string;
  47034. /**
  47035. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47036. */
  47037. coordinatesMode: number;
  47038. protected _isBlocking: boolean;
  47039. /**
  47040. * Sets wether or not the texture is blocking during loading.
  47041. */
  47042. /**
  47043. * Gets wether or not the texture is blocking during loading.
  47044. */
  47045. isBlocking: boolean;
  47046. protected _rotationY: number;
  47047. /**
  47048. * Sets texture matrix rotation angle around Y axis in radians.
  47049. */
  47050. /**
  47051. * Gets texture matrix rotation angle around Y axis radians.
  47052. */
  47053. rotationY: number;
  47054. /**
  47055. * Gets or sets the center of the bounding box associated with the cube texture
  47056. * It must define where the camera used to render the texture was set
  47057. */
  47058. boundingBoxPosition: Vector3;
  47059. private _boundingBoxSize;
  47060. /**
  47061. * Gets or sets the size of the bounding box associated with the cube texture
  47062. * When defined, the cubemap will switch to local mode
  47063. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47064. * @example https://www.babylonjs-playground.com/#RNASML
  47065. */
  47066. boundingBoxSize: Vector3;
  47067. /**
  47068. * Instantiates an HDRTexture from the following parameters.
  47069. *
  47070. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47071. * @param scene The scene the texture will be used in
  47072. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47073. * @param noMipmap Forces to not generate the mipmap if true
  47074. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47075. * @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)
  47076. * @param reserved Reserved flag for internal use.
  47077. */
  47078. 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>);
  47079. /**
  47080. * Get the current class name of the texture useful for serialization or dynamic coding.
  47081. * @returns "HDRCubeTexture"
  47082. */
  47083. getClassName(): string;
  47084. /**
  47085. * Occurs when the file is raw .hdr file.
  47086. */
  47087. private loadTexture;
  47088. clone(): HDRCubeTexture;
  47089. delayLoad(): void;
  47090. /**
  47091. * Get the texture reflection matrix used to rotate/transform the reflection.
  47092. * @returns the reflection matrix
  47093. */
  47094. getReflectionTextureMatrix(): Matrix;
  47095. /**
  47096. * Set the texture reflection matrix used to rotate/transform the reflection.
  47097. * @param value Define the reflection matrix to set
  47098. */
  47099. setReflectionTextureMatrix(value: Matrix): void;
  47100. /**
  47101. * Parses a JSON representation of an HDR Texture in order to create the texture
  47102. * @param parsedTexture Define the JSON representation
  47103. * @param scene Define the scene the texture should be created in
  47104. * @param rootUrl Define the root url in case we need to load relative dependencies
  47105. * @returns the newly created texture after parsing
  47106. */
  47107. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47108. serialize(): any;
  47109. }
  47110. }
  47111. declare module BABYLON {
  47112. /**
  47113. * Class used to control physics engine
  47114. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47115. */
  47116. export class PhysicsEngine implements IPhysicsEngine {
  47117. private _physicsPlugin;
  47118. /**
  47119. * Global value used to control the smallest number supported by the simulation
  47120. */
  47121. static Epsilon: number;
  47122. private _impostors;
  47123. private _joints;
  47124. /**
  47125. * Gets the gravity vector used by the simulation
  47126. */
  47127. gravity: Vector3;
  47128. /**
  47129. * Factory used to create the default physics plugin.
  47130. * @returns The default physics plugin
  47131. */
  47132. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47133. /**
  47134. * Creates a new Physics Engine
  47135. * @param gravity defines the gravity vector used by the simulation
  47136. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47137. */
  47138. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47139. /**
  47140. * Sets the gravity vector used by the simulation
  47141. * @param gravity defines the gravity vector to use
  47142. */
  47143. setGravity(gravity: Vector3): void;
  47144. /**
  47145. * Set the time step of the physics engine.
  47146. * Default is 1/60.
  47147. * To slow it down, enter 1/600 for example.
  47148. * To speed it up, 1/30
  47149. * @param newTimeStep defines the new timestep to apply to this world.
  47150. */
  47151. setTimeStep(newTimeStep?: number): void;
  47152. /**
  47153. * Get the time step of the physics engine.
  47154. * @returns the current time step
  47155. */
  47156. getTimeStep(): number;
  47157. /**
  47158. * Release all resources
  47159. */
  47160. dispose(): void;
  47161. /**
  47162. * Gets the name of the current physics plugin
  47163. * @returns the name of the plugin
  47164. */
  47165. getPhysicsPluginName(): string;
  47166. /**
  47167. * Adding a new impostor for the impostor tracking.
  47168. * This will be done by the impostor itself.
  47169. * @param impostor the impostor to add
  47170. */
  47171. addImpostor(impostor: PhysicsImpostor): void;
  47172. /**
  47173. * Remove an impostor from the engine.
  47174. * This impostor and its mesh will not longer be updated by the physics engine.
  47175. * @param impostor the impostor to remove
  47176. */
  47177. removeImpostor(impostor: PhysicsImpostor): void;
  47178. /**
  47179. * Add a joint to the physics engine
  47180. * @param mainImpostor defines the main impostor to which the joint is added.
  47181. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47182. * @param joint defines the joint that will connect both impostors.
  47183. */
  47184. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47185. /**
  47186. * Removes a joint from the simulation
  47187. * @param mainImpostor defines the impostor used with the joint
  47188. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47189. * @param joint defines the joint to remove
  47190. */
  47191. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47192. /**
  47193. * Called by the scene. No need to call it.
  47194. * @param delta defines the timespam between frames
  47195. */ step(delta: number): void;
  47196. /**
  47197. * Gets the current plugin used to run the simulation
  47198. * @returns current plugin
  47199. */
  47200. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47201. /**
  47202. * Gets the list of physic impostors
  47203. * @returns an array of PhysicsImpostor
  47204. */
  47205. getImpostors(): Array<PhysicsImpostor>;
  47206. /**
  47207. * Gets the impostor for a physics enabled object
  47208. * @param object defines the object impersonated by the impostor
  47209. * @returns the PhysicsImpostor or null if not found
  47210. */
  47211. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47212. /**
  47213. * Gets the impostor for a physics body object
  47214. * @param body defines physics body used by the impostor
  47215. * @returns the PhysicsImpostor or null if not found
  47216. */
  47217. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47218. /**
  47219. * Does a raycast in the physics world
  47220. * @param from when should the ray start?
  47221. * @param to when should the ray end?
  47222. * @returns PhysicsRaycastResult
  47223. */
  47224. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47225. }
  47226. }
  47227. declare module BABYLON {
  47228. /** @hidden */
  47229. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47230. private _useDeltaForWorldStep;
  47231. world: any;
  47232. name: string;
  47233. private _physicsMaterials;
  47234. private _fixedTimeStep;
  47235. private _cannonRaycastResult;
  47236. private _raycastResult;
  47237. private _removeAfterStep;
  47238. BJSCANNON: any;
  47239. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47240. setGravity(gravity: Vector3): void;
  47241. setTimeStep(timeStep: number): void;
  47242. getTimeStep(): number;
  47243. executeStep(delta: number): void;
  47244. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47245. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47246. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47247. private _processChildMeshes;
  47248. removePhysicsBody(impostor: PhysicsImpostor): void;
  47249. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47250. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47251. private _addMaterial;
  47252. private _checkWithEpsilon;
  47253. private _createShape;
  47254. private _createHeightmap;
  47255. private _minus90X;
  47256. private _plus90X;
  47257. private _tmpPosition;
  47258. private _tmpDeltaPosition;
  47259. private _tmpUnityRotation;
  47260. private _updatePhysicsBodyTransformation;
  47261. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47262. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47263. isSupported(): boolean;
  47264. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47265. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47266. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47267. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47268. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47269. getBodyMass(impostor: PhysicsImpostor): number;
  47270. getBodyFriction(impostor: PhysicsImpostor): number;
  47271. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47272. getBodyRestitution(impostor: PhysicsImpostor): number;
  47273. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47274. sleepBody(impostor: PhysicsImpostor): void;
  47275. wakeUpBody(impostor: PhysicsImpostor): void;
  47276. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47277. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47278. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47279. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47280. getRadius(impostor: PhysicsImpostor): number;
  47281. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47282. dispose(): void;
  47283. private _extendNamespace;
  47284. /**
  47285. * Does a raycast in the physics world
  47286. * @param from when should the ray start?
  47287. * @param to when should the ray end?
  47288. * @returns PhysicsRaycastResult
  47289. */
  47290. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47291. }
  47292. }
  47293. declare module BABYLON {
  47294. /** @hidden */
  47295. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47296. world: any;
  47297. name: string;
  47298. BJSOIMO: any;
  47299. private _raycastResult;
  47300. constructor(iterations?: number, oimoInjection?: any);
  47301. setGravity(gravity: Vector3): void;
  47302. setTimeStep(timeStep: number): void;
  47303. getTimeStep(): number;
  47304. private _tmpImpostorsArray;
  47305. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47306. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47307. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47308. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47309. private _tmpPositionVector;
  47310. removePhysicsBody(impostor: PhysicsImpostor): void;
  47311. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47312. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47313. isSupported(): boolean;
  47314. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47315. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47316. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47317. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47318. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47319. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47320. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47321. getBodyMass(impostor: PhysicsImpostor): number;
  47322. getBodyFriction(impostor: PhysicsImpostor): number;
  47323. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47324. getBodyRestitution(impostor: PhysicsImpostor): number;
  47325. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47326. sleepBody(impostor: PhysicsImpostor): void;
  47327. wakeUpBody(impostor: PhysicsImpostor): void;
  47328. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47329. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47330. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47331. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47332. getRadius(impostor: PhysicsImpostor): number;
  47333. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47334. dispose(): void;
  47335. /**
  47336. * Does a raycast in the physics world
  47337. * @param from when should the ray start?
  47338. * @param to when should the ray end?
  47339. * @returns PhysicsRaycastResult
  47340. */
  47341. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47342. }
  47343. }
  47344. declare module BABYLON {
  47345. /**
  47346. * Class containing static functions to help procedurally build meshes
  47347. */
  47348. export class RibbonBuilder {
  47349. /**
  47350. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47351. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47352. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47353. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47354. * * 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
  47355. * * 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
  47356. * * 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
  47357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47358. * * If you create a double-sided mesh, you can choose what parts of 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
  47359. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47360. * * 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
  47361. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47362. * * 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
  47363. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47365. * @param name defines the name of the mesh
  47366. * @param options defines the options used to create the mesh
  47367. * @param scene defines the hosting scene
  47368. * @returns the ribbon mesh
  47369. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47370. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47371. */
  47372. static CreateRibbon(name: string, options: {
  47373. pathArray: Vector3[][];
  47374. closeArray?: boolean;
  47375. closePath?: boolean;
  47376. offset?: number;
  47377. updatable?: boolean;
  47378. sideOrientation?: number;
  47379. frontUVs?: Vector4;
  47380. backUVs?: Vector4;
  47381. instance?: Mesh;
  47382. invertUV?: boolean;
  47383. uvs?: Vector2[];
  47384. colors?: Color4[];
  47385. }, scene?: Nullable<Scene>): Mesh;
  47386. }
  47387. }
  47388. declare module BABYLON {
  47389. /**
  47390. * Class containing static functions to help procedurally build meshes
  47391. */
  47392. export class ShapeBuilder {
  47393. /**
  47394. * 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.
  47395. * * 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.
  47396. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47397. * * 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.
  47398. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47399. * * 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
  47400. * * 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
  47401. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47403. * * If you create a double-sided mesh, you can choose what parts of 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
  47404. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47406. * @param name defines the name of the mesh
  47407. * @param options defines the options used to create the mesh
  47408. * @param scene defines the hosting scene
  47409. * @returns the extruded shape mesh
  47410. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47412. */
  47413. static ExtrudeShape(name: string, options: {
  47414. shape: Vector3[];
  47415. path: Vector3[];
  47416. scale?: number;
  47417. rotation?: number;
  47418. cap?: number;
  47419. updatable?: boolean;
  47420. sideOrientation?: number;
  47421. frontUVs?: Vector4;
  47422. backUVs?: Vector4;
  47423. instance?: Mesh;
  47424. invertUV?: boolean;
  47425. }, scene?: Nullable<Scene>): Mesh;
  47426. /**
  47427. * Creates an custom extruded shape mesh.
  47428. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47429. * * 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.
  47430. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47431. * * 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
  47432. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47433. * * 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
  47434. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47435. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47436. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47437. * * 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
  47438. * * 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
  47439. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47441. * * If you create a double-sided mesh, you can choose what parts of 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
  47442. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47444. * @param name defines the name of the mesh
  47445. * @param options defines the options used to create the mesh
  47446. * @param scene defines the hosting scene
  47447. * @returns the custom extruded shape mesh
  47448. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47449. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47450. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47451. */
  47452. static ExtrudeShapeCustom(name: string, options: {
  47453. shape: Vector3[];
  47454. path: Vector3[];
  47455. scaleFunction?: any;
  47456. rotationFunction?: any;
  47457. ribbonCloseArray?: boolean;
  47458. ribbonClosePath?: boolean;
  47459. cap?: number;
  47460. updatable?: boolean;
  47461. sideOrientation?: number;
  47462. frontUVs?: Vector4;
  47463. backUVs?: Vector4;
  47464. instance?: Mesh;
  47465. invertUV?: boolean;
  47466. }, scene?: Nullable<Scene>): Mesh;
  47467. private static _ExtrudeShapeGeneric;
  47468. }
  47469. }
  47470. declare module BABYLON {
  47471. /**
  47472. * AmmoJS Physics plugin
  47473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  47474. * @see https://github.com/kripken/ammo.js/
  47475. */
  47476. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  47477. private _useDeltaForWorldStep;
  47478. /**
  47479. * Reference to the Ammo library
  47480. */
  47481. bjsAMMO: any;
  47482. /**
  47483. * Created ammoJS world which physics bodies are added to
  47484. */
  47485. world: any;
  47486. /**
  47487. * Name of the plugin
  47488. */
  47489. name: string;
  47490. private _timeStep;
  47491. private _fixedTimeStep;
  47492. private _maxSteps;
  47493. private _tmpQuaternion;
  47494. private _tmpAmmoTransform;
  47495. private _tmpAmmoQuaternion;
  47496. private _tmpAmmoConcreteContactResultCallback;
  47497. private _collisionConfiguration;
  47498. private _dispatcher;
  47499. private _overlappingPairCache;
  47500. private _solver;
  47501. private _softBodySolver;
  47502. private _tmpAmmoVectorA;
  47503. private _tmpAmmoVectorB;
  47504. private _tmpAmmoVectorC;
  47505. private _tmpAmmoVectorD;
  47506. private _tmpContactCallbackResult;
  47507. private _tmpAmmoVectorRCA;
  47508. private _tmpAmmoVectorRCB;
  47509. private _raycastResult;
  47510. private static readonly DISABLE_COLLISION_FLAG;
  47511. private static readonly KINEMATIC_FLAG;
  47512. private static readonly DISABLE_DEACTIVATION_FLAG;
  47513. /**
  47514. * Initializes the ammoJS plugin
  47515. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  47516. * @param ammoInjection can be used to inject your own ammo reference
  47517. */
  47518. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  47519. /**
  47520. * Sets the gravity of the physics world (m/(s^2))
  47521. * @param gravity Gravity to set
  47522. */
  47523. setGravity(gravity: Vector3): void;
  47524. /**
  47525. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  47526. * @param timeStep timestep to use in seconds
  47527. */
  47528. setTimeStep(timeStep: number): void;
  47529. /**
  47530. * 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)
  47531. * @param fixedTimeStep fixedTimeStep to use in seconds
  47532. */
  47533. setFixedTimeStep(fixedTimeStep: number): void;
  47534. /**
  47535. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  47536. * @param maxSteps the maximum number of steps by the physics engine per frame
  47537. */
  47538. setMaxSteps(maxSteps: number): void;
  47539. /**
  47540. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  47541. * @returns the current timestep in seconds
  47542. */
  47543. getTimeStep(): number;
  47544. private _isImpostorInContact;
  47545. private _isImpostorPairInContact;
  47546. private _stepSimulation;
  47547. /**
  47548. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  47549. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  47550. * After the step the babylon meshes are set to the position of the physics imposters
  47551. * @param delta amount of time to step forward
  47552. * @param impostors array of imposters to update before/after the step
  47553. */
  47554. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47555. /**
  47556. * Update babylon mesh to match physics world object
  47557. * @param impostor imposter to match
  47558. */
  47559. private _afterSoftStep;
  47560. /**
  47561. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47562. * @param impostor imposter to match
  47563. */
  47564. private _ropeStep;
  47565. /**
  47566. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47567. * @param impostor imposter to match
  47568. */
  47569. private _softbodyOrClothStep;
  47570. private _tmpVector;
  47571. private _tmpMatrix;
  47572. /**
  47573. * Applies an impulse on the imposter
  47574. * @param impostor imposter to apply impulse to
  47575. * @param force amount of force to be applied to the imposter
  47576. * @param contactPoint the location to apply the impulse on the imposter
  47577. */
  47578. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47579. /**
  47580. * Applies a force on the imposter
  47581. * @param impostor imposter to apply force
  47582. * @param force amount of force to be applied to the imposter
  47583. * @param contactPoint the location to apply the force on the imposter
  47584. */
  47585. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47586. /**
  47587. * Creates a physics body using the plugin
  47588. * @param impostor the imposter to create the physics body on
  47589. */
  47590. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47591. /**
  47592. * Removes the physics body from the imposter and disposes of the body's memory
  47593. * @param impostor imposter to remove the physics body from
  47594. */
  47595. removePhysicsBody(impostor: PhysicsImpostor): void;
  47596. /**
  47597. * Generates a joint
  47598. * @param impostorJoint the imposter joint to create the joint with
  47599. */
  47600. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47601. /**
  47602. * Removes a joint
  47603. * @param impostorJoint the imposter joint to remove the joint from
  47604. */
  47605. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47606. private _addMeshVerts;
  47607. /**
  47608. * Initialise the soft body vertices to match its object's (mesh) vertices
  47609. * Softbody vertices (nodes) are in world space and to match this
  47610. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  47611. * @param impostor to create the softbody for
  47612. */
  47613. private _softVertexData;
  47614. /**
  47615. * Create an impostor's soft body
  47616. * @param impostor to create the softbody for
  47617. */
  47618. private _createSoftbody;
  47619. /**
  47620. * Create cloth for an impostor
  47621. * @param impostor to create the softbody for
  47622. */
  47623. private _createCloth;
  47624. /**
  47625. * Create rope for an impostor
  47626. * @param impostor to create the softbody for
  47627. */
  47628. private _createRope;
  47629. private _addHullVerts;
  47630. private _createShape;
  47631. /**
  47632. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  47633. * @param impostor imposter containing the physics body and babylon object
  47634. */
  47635. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47636. /**
  47637. * Sets the babylon object's position/rotation from the physics body's position/rotation
  47638. * @param impostor imposter containing the physics body and babylon object
  47639. * @param newPosition new position
  47640. * @param newRotation new rotation
  47641. */
  47642. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47643. /**
  47644. * If this plugin is supported
  47645. * @returns true if its supported
  47646. */
  47647. isSupported(): boolean;
  47648. /**
  47649. * Sets the linear velocity of the physics body
  47650. * @param impostor imposter to set the velocity on
  47651. * @param velocity velocity to set
  47652. */
  47653. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47654. /**
  47655. * Sets the angular velocity of the physics body
  47656. * @param impostor imposter to set the velocity on
  47657. * @param velocity velocity to set
  47658. */
  47659. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47660. /**
  47661. * gets the linear velocity
  47662. * @param impostor imposter to get linear velocity from
  47663. * @returns linear velocity
  47664. */
  47665. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47666. /**
  47667. * gets the angular velocity
  47668. * @param impostor imposter to get angular velocity from
  47669. * @returns angular velocity
  47670. */
  47671. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47672. /**
  47673. * Sets the mass of physics body
  47674. * @param impostor imposter to set the mass on
  47675. * @param mass mass to set
  47676. */
  47677. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47678. /**
  47679. * Gets the mass of the physics body
  47680. * @param impostor imposter to get the mass from
  47681. * @returns mass
  47682. */
  47683. getBodyMass(impostor: PhysicsImpostor): number;
  47684. /**
  47685. * Gets friction of the impostor
  47686. * @param impostor impostor to get friction from
  47687. * @returns friction value
  47688. */
  47689. getBodyFriction(impostor: PhysicsImpostor): number;
  47690. /**
  47691. * Sets friction of the impostor
  47692. * @param impostor impostor to set friction on
  47693. * @param friction friction value
  47694. */
  47695. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47696. /**
  47697. * Gets restitution of the impostor
  47698. * @param impostor impostor to get restitution from
  47699. * @returns restitution value
  47700. */
  47701. getBodyRestitution(impostor: PhysicsImpostor): number;
  47702. /**
  47703. * Sets resitution of the impostor
  47704. * @param impostor impostor to set resitution on
  47705. * @param restitution resitution value
  47706. */
  47707. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47708. /**
  47709. * Gets pressure inside the impostor
  47710. * @param impostor impostor to get pressure from
  47711. * @returns pressure value
  47712. */
  47713. getBodyPressure(impostor: PhysicsImpostor): number;
  47714. /**
  47715. * Sets pressure inside a soft body impostor
  47716. * Cloth and rope must remain 0 pressure
  47717. * @param impostor impostor to set pressure on
  47718. * @param pressure pressure value
  47719. */
  47720. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  47721. /**
  47722. * Gets stiffness of the impostor
  47723. * @param impostor impostor to get stiffness from
  47724. * @returns pressure value
  47725. */
  47726. getBodyStiffness(impostor: PhysicsImpostor): number;
  47727. /**
  47728. * Sets stiffness of the impostor
  47729. * @param impostor impostor to set stiffness on
  47730. * @param stiffness stiffness value from 0 to 1
  47731. */
  47732. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  47733. /**
  47734. * Gets velocityIterations of the impostor
  47735. * @param impostor impostor to get velocity iterations from
  47736. * @returns velocityIterations value
  47737. */
  47738. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  47739. /**
  47740. * Sets velocityIterations of the impostor
  47741. * @param impostor impostor to set velocity iterations on
  47742. * @param velocityIterations velocityIterations value
  47743. */
  47744. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  47745. /**
  47746. * Gets positionIterations of the impostor
  47747. * @param impostor impostor to get position iterations from
  47748. * @returns positionIterations value
  47749. */
  47750. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  47751. /**
  47752. * Sets positionIterations of the impostor
  47753. * @param impostor impostor to set position on
  47754. * @param positionIterations positionIterations value
  47755. */
  47756. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  47757. /**
  47758. * Append an anchor to a cloth object
  47759. * @param impostor is the cloth impostor to add anchor to
  47760. * @param otherImpostor is the rigid impostor to anchor to
  47761. * @param width ratio across width from 0 to 1
  47762. * @param height ratio up height from 0 to 1
  47763. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  47764. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  47765. */
  47766. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  47767. /**
  47768. * Append an hook to a rope object
  47769. * @param impostor is the rope impostor to add hook to
  47770. * @param otherImpostor is the rigid impostor to hook to
  47771. * @param length ratio along the rope from 0 to 1
  47772. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  47773. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  47774. */
  47775. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  47776. /**
  47777. * Sleeps the physics body and stops it from being active
  47778. * @param impostor impostor to sleep
  47779. */
  47780. sleepBody(impostor: PhysicsImpostor): void;
  47781. /**
  47782. * Activates the physics body
  47783. * @param impostor impostor to activate
  47784. */
  47785. wakeUpBody(impostor: PhysicsImpostor): void;
  47786. /**
  47787. * Updates the distance parameters of the joint
  47788. * @param joint joint to update
  47789. * @param maxDistance maximum distance of the joint
  47790. * @param minDistance minimum distance of the joint
  47791. */
  47792. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47793. /**
  47794. * Sets a motor on the joint
  47795. * @param joint joint to set motor on
  47796. * @param speed speed of the motor
  47797. * @param maxForce maximum force of the motor
  47798. * @param motorIndex index of the motor
  47799. */
  47800. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47801. /**
  47802. * Sets the motors limit
  47803. * @param joint joint to set limit on
  47804. * @param upperLimit upper limit
  47805. * @param lowerLimit lower limit
  47806. */
  47807. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47808. /**
  47809. * Syncs the position and rotation of a mesh with the impostor
  47810. * @param mesh mesh to sync
  47811. * @param impostor impostor to update the mesh with
  47812. */
  47813. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47814. /**
  47815. * Gets the radius of the impostor
  47816. * @param impostor impostor to get radius from
  47817. * @returns the radius
  47818. */
  47819. getRadius(impostor: PhysicsImpostor): number;
  47820. /**
  47821. * Gets the box size of the impostor
  47822. * @param impostor impostor to get box size from
  47823. * @param result the resulting box size
  47824. */
  47825. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47826. /**
  47827. * Disposes of the impostor
  47828. */
  47829. dispose(): void;
  47830. /**
  47831. * Does a raycast in the physics world
  47832. * @param from when should the ray start?
  47833. * @param to when should the ray end?
  47834. * @returns PhysicsRaycastResult
  47835. */
  47836. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47837. }
  47838. }
  47839. declare module BABYLON {
  47840. interface AbstractScene {
  47841. /**
  47842. * The list of reflection probes added to the scene
  47843. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47844. */
  47845. reflectionProbes: Array<ReflectionProbe>;
  47846. /**
  47847. * Removes the given reflection probe from this scene.
  47848. * @param toRemove The reflection probe to remove
  47849. * @returns The index of the removed reflection probe
  47850. */
  47851. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47852. /**
  47853. * Adds the given reflection probe to this scene.
  47854. * @param newReflectionProbe The reflection probe to add
  47855. */
  47856. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47857. }
  47858. /**
  47859. * Class used to generate realtime reflection / refraction cube textures
  47860. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47861. */
  47862. export class ReflectionProbe {
  47863. /** defines the name of the probe */
  47864. name: string;
  47865. private _scene;
  47866. private _renderTargetTexture;
  47867. private _projectionMatrix;
  47868. private _viewMatrix;
  47869. private _target;
  47870. private _add;
  47871. private _attachedMesh;
  47872. private _invertYAxis;
  47873. /** Gets or sets probe position (center of the cube map) */
  47874. position: Vector3;
  47875. /**
  47876. * Creates a new reflection probe
  47877. * @param name defines the name of the probe
  47878. * @param size defines the texture resolution (for each face)
  47879. * @param scene defines the hosting scene
  47880. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47881. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47882. */
  47883. constructor(
  47884. /** defines the name of the probe */
  47885. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47886. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47887. samples: number;
  47888. /** Gets or sets the refresh rate to use (on every frame by default) */
  47889. refreshRate: number;
  47890. /**
  47891. * Gets the hosting scene
  47892. * @returns a Scene
  47893. */
  47894. getScene(): Scene;
  47895. /** Gets the internal CubeTexture used to render to */
  47896. readonly cubeTexture: RenderTargetTexture;
  47897. /** Gets the list of meshes to render */
  47898. readonly renderList: Nullable<AbstractMesh[]>;
  47899. /**
  47900. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47901. * @param mesh defines the mesh to attach to
  47902. */
  47903. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47904. /**
  47905. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47906. * @param renderingGroupId The rendering group id corresponding to its index
  47907. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47908. */
  47909. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47910. /**
  47911. * Clean all associated resources
  47912. */
  47913. dispose(): void;
  47914. /**
  47915. * Converts the reflection probe information to a readable string for debug purpose.
  47916. * @param fullDetails Supports for multiple levels of logging within scene loading
  47917. * @returns the human readable reflection probe info
  47918. */
  47919. toString(fullDetails?: boolean): string;
  47920. /**
  47921. * Get the class name of the relfection probe.
  47922. * @returns "ReflectionProbe"
  47923. */
  47924. getClassName(): string;
  47925. /**
  47926. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47927. * @returns The JSON representation of the texture
  47928. */
  47929. serialize(): any;
  47930. /**
  47931. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47932. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47933. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47934. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47935. * @returns The parsed reflection probe if successful
  47936. */
  47937. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47938. }
  47939. }
  47940. declare module BABYLON {
  47941. /** @hidden */
  47942. export var _BabylonLoaderRegistered: boolean;
  47943. }
  47944. declare module BABYLON {
  47945. /**
  47946. * The Physically based simple base material of BJS.
  47947. *
  47948. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47949. * It is used as the base class for both the specGloss and metalRough conventions.
  47950. */
  47951. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47952. /**
  47953. * Number of Simultaneous lights allowed on the material.
  47954. */
  47955. maxSimultaneousLights: number;
  47956. /**
  47957. * If sets to true, disables all the lights affecting the material.
  47958. */
  47959. disableLighting: boolean;
  47960. /**
  47961. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47962. */
  47963. environmentTexture: BaseTexture;
  47964. /**
  47965. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47966. */
  47967. invertNormalMapX: boolean;
  47968. /**
  47969. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47970. */
  47971. invertNormalMapY: boolean;
  47972. /**
  47973. * Normal map used in the model.
  47974. */
  47975. normalTexture: BaseTexture;
  47976. /**
  47977. * Emissivie color used to self-illuminate the model.
  47978. */
  47979. emissiveColor: Color3;
  47980. /**
  47981. * Emissivie texture used to self-illuminate the model.
  47982. */
  47983. emissiveTexture: BaseTexture;
  47984. /**
  47985. * Occlusion Channel Strenght.
  47986. */
  47987. occlusionStrength: number;
  47988. /**
  47989. * Occlusion Texture of the material (adding extra occlusion effects).
  47990. */
  47991. occlusionTexture: BaseTexture;
  47992. /**
  47993. * Defines the alpha limits in alpha test mode.
  47994. */
  47995. alphaCutOff: number;
  47996. /**
  47997. * Gets the current double sided mode.
  47998. */
  47999. /**
  48000. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48001. */
  48002. doubleSided: boolean;
  48003. /**
  48004. * Stores the pre-calculated light information of a mesh in a texture.
  48005. */
  48006. lightmapTexture: BaseTexture;
  48007. /**
  48008. * If true, the light map contains occlusion information instead of lighting info.
  48009. */
  48010. useLightmapAsShadowmap: boolean;
  48011. /**
  48012. * Instantiates a new PBRMaterial instance.
  48013. *
  48014. * @param name The material name
  48015. * @param scene The scene the material will be use in.
  48016. */
  48017. constructor(name: string, scene: Scene);
  48018. getClassName(): string;
  48019. }
  48020. }
  48021. declare module BABYLON {
  48022. /**
  48023. * The PBR material of BJS following the metal roughness convention.
  48024. *
  48025. * This fits to the PBR convention in the GLTF definition:
  48026. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48027. */
  48028. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48029. /**
  48030. * The base color has two different interpretations depending on the value of metalness.
  48031. * When the material is a metal, the base color is the specific measured reflectance value
  48032. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48033. * of the material.
  48034. */
  48035. baseColor: Color3;
  48036. /**
  48037. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48038. * well as opacity information in the alpha channel.
  48039. */
  48040. baseTexture: BaseTexture;
  48041. /**
  48042. * Specifies the metallic scalar value of the material.
  48043. * Can also be used to scale the metalness values of the metallic texture.
  48044. */
  48045. metallic: number;
  48046. /**
  48047. * Specifies the roughness scalar value of the material.
  48048. * Can also be used to scale the roughness values of the metallic texture.
  48049. */
  48050. roughness: number;
  48051. /**
  48052. * Texture containing both the metallic value in the B channel and the
  48053. * roughness value in the G channel to keep better precision.
  48054. */
  48055. metallicRoughnessTexture: BaseTexture;
  48056. /**
  48057. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48058. *
  48059. * @param name The material name
  48060. * @param scene The scene the material will be use in.
  48061. */
  48062. constructor(name: string, scene: Scene);
  48063. /**
  48064. * Return the currrent class name of the material.
  48065. */
  48066. getClassName(): string;
  48067. /**
  48068. * Makes a duplicate of the current material.
  48069. * @param name - name to use for the new material.
  48070. */
  48071. clone(name: string): PBRMetallicRoughnessMaterial;
  48072. /**
  48073. * Serialize the material to a parsable JSON object.
  48074. */
  48075. serialize(): any;
  48076. /**
  48077. * Parses a JSON object correponding to the serialize function.
  48078. */
  48079. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48080. }
  48081. }
  48082. declare module BABYLON {
  48083. /**
  48084. * The PBR material of BJS following the specular glossiness convention.
  48085. *
  48086. * This fits to the PBR convention in the GLTF definition:
  48087. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48088. */
  48089. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48090. /**
  48091. * Specifies the diffuse color of the material.
  48092. */
  48093. diffuseColor: Color3;
  48094. /**
  48095. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48096. * channel.
  48097. */
  48098. diffuseTexture: BaseTexture;
  48099. /**
  48100. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48101. */
  48102. specularColor: Color3;
  48103. /**
  48104. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48105. */
  48106. glossiness: number;
  48107. /**
  48108. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48109. */
  48110. specularGlossinessTexture: BaseTexture;
  48111. /**
  48112. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48113. *
  48114. * @param name The material name
  48115. * @param scene The scene the material will be use in.
  48116. */
  48117. constructor(name: string, scene: Scene);
  48118. /**
  48119. * Return the currrent class name of the material.
  48120. */
  48121. getClassName(): string;
  48122. /**
  48123. * Makes a duplicate of the current material.
  48124. * @param name - name to use for the new material.
  48125. */
  48126. clone(name: string): PBRSpecularGlossinessMaterial;
  48127. /**
  48128. * Serialize the material to a parsable JSON object.
  48129. */
  48130. serialize(): any;
  48131. /**
  48132. * Parses a JSON object correponding to the serialize function.
  48133. */
  48134. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48135. }
  48136. }
  48137. declare module BABYLON {
  48138. /**
  48139. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48140. * It can help converting any input color in a desired output one. This can then be used to create effects
  48141. * from sepia, black and white to sixties or futuristic rendering...
  48142. *
  48143. * The only supported format is currently 3dl.
  48144. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48145. */
  48146. export class ColorGradingTexture extends BaseTexture {
  48147. /**
  48148. * The current texture matrix. (will always be identity in color grading texture)
  48149. */
  48150. private _textureMatrix;
  48151. /**
  48152. * The texture URL.
  48153. */
  48154. url: string;
  48155. /**
  48156. * Empty line regex stored for GC.
  48157. */
  48158. private static _noneEmptyLineRegex;
  48159. private _engine;
  48160. /**
  48161. * Instantiates a ColorGradingTexture from the following parameters.
  48162. *
  48163. * @param url The location of the color gradind data (currently only supporting 3dl)
  48164. * @param scene The scene the texture will be used in
  48165. */
  48166. constructor(url: string, scene: Scene);
  48167. /**
  48168. * Returns the texture matrix used in most of the material.
  48169. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48170. */
  48171. getTextureMatrix(): Matrix;
  48172. /**
  48173. * Occurs when the file being loaded is a .3dl LUT file.
  48174. */
  48175. private load3dlTexture;
  48176. /**
  48177. * Starts the loading process of the texture.
  48178. */
  48179. private loadTexture;
  48180. /**
  48181. * Clones the color gradind texture.
  48182. */
  48183. clone(): ColorGradingTexture;
  48184. /**
  48185. * Called during delayed load for textures.
  48186. */
  48187. delayLoad(): void;
  48188. /**
  48189. * Parses a color grading texture serialized by Babylon.
  48190. * @param parsedTexture The texture information being parsedTexture
  48191. * @param scene The scene to load the texture in
  48192. * @param rootUrl The root url of the data assets to load
  48193. * @return A color gradind texture
  48194. */
  48195. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48196. /**
  48197. * Serializes the LUT texture to json format.
  48198. */
  48199. serialize(): any;
  48200. }
  48201. }
  48202. declare module BABYLON {
  48203. /**
  48204. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48205. */
  48206. export class EquiRectangularCubeTexture extends BaseTexture {
  48207. /** The six faces of the cube. */
  48208. private static _FacesMapping;
  48209. private _noMipmap;
  48210. private _onLoad;
  48211. private _onError;
  48212. /** The size of the cubemap. */
  48213. private _size;
  48214. /** The buffer of the image. */
  48215. private _buffer;
  48216. /** The width of the input image. */
  48217. private _width;
  48218. /** The height of the input image. */
  48219. private _height;
  48220. /** The URL to the image. */
  48221. url: string;
  48222. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48223. coordinatesMode: number;
  48224. /**
  48225. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48226. * @param url The location of the image
  48227. * @param scene The scene the texture will be used in
  48228. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48229. * @param noMipmap Forces to not generate the mipmap if true
  48230. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48231. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48232. * @param onLoad — defines a callback called when texture is loaded
  48233. * @param onError — defines a callback called if there is an error
  48234. */
  48235. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48236. /**
  48237. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48238. */
  48239. private loadImage;
  48240. /**
  48241. * Convert the image buffer into a cubemap and create a CubeTexture.
  48242. */
  48243. private loadTexture;
  48244. /**
  48245. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48246. * @param buffer The ArrayBuffer that should be converted.
  48247. * @returns The buffer as Float32Array.
  48248. */
  48249. private getFloat32ArrayFromArrayBuffer;
  48250. /**
  48251. * Get the current class name of the texture useful for serialization or dynamic coding.
  48252. * @returns "EquiRectangularCubeTexture"
  48253. */
  48254. getClassName(): string;
  48255. /**
  48256. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48257. * @returns A clone of the current EquiRectangularCubeTexture.
  48258. */
  48259. clone(): EquiRectangularCubeTexture;
  48260. }
  48261. }
  48262. declare module BABYLON {
  48263. /**
  48264. * Based on jsTGALoader - Javascript loader for TGA file
  48265. * By Vincent Thibault
  48266. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48267. */
  48268. export class TGATools {
  48269. private static _TYPE_INDEXED;
  48270. private static _TYPE_RGB;
  48271. private static _TYPE_GREY;
  48272. private static _TYPE_RLE_INDEXED;
  48273. private static _TYPE_RLE_RGB;
  48274. private static _TYPE_RLE_GREY;
  48275. private static _ORIGIN_MASK;
  48276. private static _ORIGIN_SHIFT;
  48277. private static _ORIGIN_BL;
  48278. private static _ORIGIN_BR;
  48279. private static _ORIGIN_UL;
  48280. private static _ORIGIN_UR;
  48281. /**
  48282. * Gets the header of a TGA file
  48283. * @param data defines the TGA data
  48284. * @returns the header
  48285. */
  48286. static GetTGAHeader(data: Uint8Array): any;
  48287. /**
  48288. * Uploads TGA content to a Babylon Texture
  48289. * @hidden
  48290. */
  48291. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48292. /** @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;
  48293. /** @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;
  48294. /** @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;
  48295. /** @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;
  48296. /** @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;
  48297. /** @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;
  48298. }
  48299. }
  48300. declare module BABYLON {
  48301. /**
  48302. * Implementation of the TGA Texture Loader.
  48303. * @hidden
  48304. */
  48305. export class _TGATextureLoader implements IInternalTextureLoader {
  48306. /**
  48307. * Defines wether the loader supports cascade loading the different faces.
  48308. */
  48309. readonly supportCascades: boolean;
  48310. /**
  48311. * This returns if the loader support the current file information.
  48312. * @param extension defines the file extension of the file being loaded
  48313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48314. * @param fallback defines the fallback internal texture if any
  48315. * @param isBase64 defines whether the texture is encoded as a base64
  48316. * @param isBuffer defines whether the texture data are stored as a buffer
  48317. * @returns true if the loader can load the specified file
  48318. */
  48319. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48320. /**
  48321. * Transform the url before loading if required.
  48322. * @param rootUrl the url of the texture
  48323. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48324. * @returns the transformed texture
  48325. */
  48326. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48327. /**
  48328. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48329. * @param rootUrl the url of the texture
  48330. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48331. * @returns the fallback texture
  48332. */
  48333. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48334. /**
  48335. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48336. * @param data contains the texture data
  48337. * @param texture defines the BabylonJS internal texture
  48338. * @param createPolynomials will be true if polynomials have been requested
  48339. * @param onLoad defines the callback to trigger once the texture is ready
  48340. * @param onError defines the callback to trigger in case of error
  48341. */
  48342. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48343. /**
  48344. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48345. * @param data contains the texture data
  48346. * @param texture defines the BabylonJS internal texture
  48347. * @param callback defines the method to call once ready to upload
  48348. */
  48349. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48350. }
  48351. }
  48352. declare module BABYLON {
  48353. /**
  48354. * 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.
  48355. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48356. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48357. */
  48358. export class CustomProceduralTexture extends ProceduralTexture {
  48359. private _animate;
  48360. private _time;
  48361. private _config;
  48362. private _texturePath;
  48363. /**
  48364. * Instantiates a new Custom Procedural Texture.
  48365. * 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.
  48366. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48367. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48368. * @param name Define the name of the texture
  48369. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48370. * @param size Define the size of the texture to create
  48371. * @param scene Define the scene the texture belongs to
  48372. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48373. * @param generateMipMaps Define if the texture should creates mip maps or not
  48374. */
  48375. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48376. private _loadJson;
  48377. /**
  48378. * Is the texture ready to be used ? (rendered at least once)
  48379. * @returns true if ready, otherwise, false.
  48380. */
  48381. isReady(): boolean;
  48382. /**
  48383. * Render the texture to its associated render target.
  48384. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48385. */
  48386. render(useCameraPostProcess?: boolean): void;
  48387. /**
  48388. * Update the list of dependant textures samplers in the shader.
  48389. */
  48390. updateTextures(): void;
  48391. /**
  48392. * Update the uniform values of the procedural texture in the shader.
  48393. */
  48394. updateShaderUniforms(): void;
  48395. /**
  48396. * Define if the texture animates or not.
  48397. */
  48398. animate: boolean;
  48399. }
  48400. }
  48401. declare module BABYLON {
  48402. /** @hidden */
  48403. export var noisePixelShader: {
  48404. name: string;
  48405. shader: string;
  48406. };
  48407. }
  48408. declare module BABYLON {
  48409. /**
  48410. * Class used to generate noise procedural textures
  48411. */
  48412. export class NoiseProceduralTexture extends ProceduralTexture {
  48413. private _time;
  48414. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48415. brightness: number;
  48416. /** Defines the number of octaves to process */
  48417. octaves: number;
  48418. /** Defines the level of persistence (0.8 by default) */
  48419. persistence: number;
  48420. /** Gets or sets animation speed factor (default is 1) */
  48421. animationSpeedFactor: number;
  48422. /**
  48423. * Creates a new NoiseProceduralTexture
  48424. * @param name defines the name fo the texture
  48425. * @param size defines the size of the texture (default is 256)
  48426. * @param scene defines the hosting scene
  48427. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48428. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48429. */
  48430. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48431. private _updateShaderUniforms;
  48432. protected _getDefines(): string;
  48433. /** Generate the current state of the procedural texture */
  48434. render(useCameraPostProcess?: boolean): void;
  48435. /**
  48436. * Serializes this noise procedural texture
  48437. * @returns a serialized noise procedural texture object
  48438. */
  48439. serialize(): any;
  48440. /**
  48441. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48442. * @param parsedTexture defines parsed texture data
  48443. * @param scene defines the current scene
  48444. * @param rootUrl defines the root URL containing noise procedural texture information
  48445. * @returns a parsed NoiseProceduralTexture
  48446. */
  48447. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48448. }
  48449. }
  48450. declare module BABYLON {
  48451. /**
  48452. * Raw cube texture where the raw buffers are passed in
  48453. */
  48454. export class RawCubeTexture extends CubeTexture {
  48455. /**
  48456. * Creates a cube texture where the raw buffers are passed in.
  48457. * @param scene defines the scene the texture is attached to
  48458. * @param data defines the array of data to use to create each face
  48459. * @param size defines the size of the textures
  48460. * @param format defines the format of the data
  48461. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48462. * @param generateMipMaps defines if the engine should generate the mip levels
  48463. * @param invertY defines if data must be stored with Y axis inverted
  48464. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48465. * @param compression defines the compression used (null by default)
  48466. */
  48467. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48468. /**
  48469. * Updates the raw cube texture.
  48470. * @param data defines the data to store
  48471. * @param format defines the data format
  48472. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48473. * @param invertY defines if data must be stored with Y axis inverted
  48474. * @param compression defines the compression used (null by default)
  48475. * @param level defines which level of the texture to update
  48476. */
  48477. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48478. /**
  48479. * Updates a raw cube texture with RGBD encoded data.
  48480. * @param data defines the array of data [mipmap][face] to use to create each face
  48481. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48482. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48483. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48484. * @returns a promsie that resolves when the operation is complete
  48485. */
  48486. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48487. /**
  48488. * Clones the raw cube texture.
  48489. * @return a new cube texture
  48490. */
  48491. clone(): CubeTexture;
  48492. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48493. }
  48494. }
  48495. declare module BABYLON {
  48496. /**
  48497. * Class used to store 3D textures containing user data
  48498. */
  48499. export class RawTexture3D extends Texture {
  48500. /** Gets or sets the texture format to use */
  48501. format: number;
  48502. private _engine;
  48503. /**
  48504. * Create a new RawTexture3D
  48505. * @param data defines the data of the texture
  48506. * @param width defines the width of the texture
  48507. * @param height defines the height of the texture
  48508. * @param depth defines the depth of the texture
  48509. * @param format defines the texture format to use
  48510. * @param scene defines the hosting scene
  48511. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48512. * @param invertY defines if texture must be stored with Y axis inverted
  48513. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48514. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48515. */
  48516. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48517. /** Gets or sets the texture format to use */
  48518. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48519. /**
  48520. * Update the texture with new data
  48521. * @param data defines the data to store in the texture
  48522. */
  48523. update(data: ArrayBufferView): void;
  48524. }
  48525. }
  48526. declare module BABYLON {
  48527. /**
  48528. * Creates a refraction texture used by refraction channel of the standard material.
  48529. * It is like a mirror but to see through a material.
  48530. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48531. */
  48532. export class RefractionTexture extends RenderTargetTexture {
  48533. /**
  48534. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48535. * 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.
  48536. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48537. */
  48538. refractionPlane: Plane;
  48539. /**
  48540. * Define how deep under the surface we should see.
  48541. */
  48542. depth: number;
  48543. /**
  48544. * Creates a refraction texture used by refraction channel of the standard material.
  48545. * It is like a mirror but to see through a material.
  48546. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48547. * @param name Define the texture name
  48548. * @param size Define the size of the underlying texture
  48549. * @param scene Define the scene the refraction belongs to
  48550. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48551. */
  48552. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48553. /**
  48554. * Clone the refraction texture.
  48555. * @returns the cloned texture
  48556. */
  48557. clone(): RefractionTexture;
  48558. /**
  48559. * Serialize the texture to a JSON representation you could use in Parse later on
  48560. * @returns the serialized JSON representation
  48561. */
  48562. serialize(): any;
  48563. }
  48564. }
  48565. declare module BABYLON {
  48566. /**
  48567. * Helper class to push actions to a pool of workers.
  48568. */
  48569. export class WorkerPool implements IDisposable {
  48570. private _workerInfos;
  48571. private _pendingActions;
  48572. /**
  48573. * Constructor
  48574. * @param workers Array of workers to use for actions
  48575. */
  48576. constructor(workers: Array<Worker>);
  48577. /**
  48578. * Terminates all workers and clears any pending actions.
  48579. */
  48580. dispose(): void;
  48581. /**
  48582. * Pushes an action to the worker pool. If all the workers are active, the action will be
  48583. * pended until a worker has completed its action.
  48584. * @param action The action to perform. Call onComplete when the action is complete.
  48585. */
  48586. push(action: (worker: Worker, onComplete: () => void) => void): void;
  48587. private _execute;
  48588. }
  48589. }
  48590. declare module BABYLON {
  48591. /**
  48592. * Configuration for Draco compression
  48593. */
  48594. export interface IDracoCompressionConfiguration {
  48595. /**
  48596. * Configuration for the decoder.
  48597. */
  48598. decoder?: {
  48599. /**
  48600. * The url to the WebAssembly module.
  48601. */
  48602. wasmUrl?: string;
  48603. /**
  48604. * The url to the WebAssembly binary.
  48605. */
  48606. wasmBinaryUrl?: string;
  48607. /**
  48608. * The url to the fallback JavaScript module.
  48609. */
  48610. fallbackUrl?: string;
  48611. };
  48612. }
  48613. /**
  48614. * Draco compression (https://google.github.io/draco/)
  48615. *
  48616. * This class wraps the Draco module.
  48617. *
  48618. * **Encoder**
  48619. *
  48620. * The encoder is not currently implemented.
  48621. *
  48622. * **Decoder**
  48623. *
  48624. * 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.
  48625. *
  48626. * To update the configuration, use the following code:
  48627. * ```javascript
  48628. * DracoCompression.Configuration = {
  48629. * decoder: {
  48630. * wasmUrl: "<url to the WebAssembly library>",
  48631. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48632. * fallbackUrl: "<url to the fallback JavaScript library>",
  48633. * }
  48634. * };
  48635. * ```
  48636. *
  48637. * 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.
  48638. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48639. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48640. *
  48641. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48642. * ```javascript
  48643. * var dracoCompression = new DracoCompression();
  48644. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48645. * [VertexBuffer.PositionKind]: 0
  48646. * });
  48647. * ```
  48648. *
  48649. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48650. */
  48651. export class DracoCompression implements IDisposable {
  48652. private _workerPoolPromise;
  48653. /**
  48654. * The configuration. Defaults to the following urls:
  48655. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48656. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48657. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48658. */
  48659. static Configuration: IDracoCompressionConfiguration;
  48660. /**
  48661. * Returns true if the decoder is available.
  48662. */
  48663. static readonly DecoderAvailable: boolean;
  48664. /**
  48665. * Default number of workers to create when creating the draco compression object.
  48666. */
  48667. static DefaultNumWorkers: number;
  48668. private static GetDefaultNumWorkers;
  48669. /**
  48670. * Constructor
  48671. * @param numWorkers The number of workers for async operations
  48672. */
  48673. constructor(numWorkers?: number);
  48674. /**
  48675. * Stop all async operations and release resources.
  48676. */
  48677. dispose(): void;
  48678. /**
  48679. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  48680. * @returns a promise that resolves when ready
  48681. */
  48682. whenReadyAsync(): Promise<void>;
  48683. /**
  48684. * Decode Draco compressed mesh data to vertex data.
  48685. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48686. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48687. * @returns A promise that resolves with the decoded vertex data
  48688. */
  48689. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  48690. [kind: string]: number;
  48691. }): Promise<VertexData>;
  48692. /**
  48693. * The worker function that gets converted to a blob url to pass into a worker.
  48694. */
  48695. private static _Worker;
  48696. private _loadDecoderWasmBinaryAsync;
  48697. }
  48698. }
  48699. declare module BABYLON {
  48700. /**
  48701. * Class for building Constructive Solid Geometry
  48702. */
  48703. export class CSG {
  48704. private polygons;
  48705. /**
  48706. * The world matrix
  48707. */
  48708. matrix: Matrix;
  48709. /**
  48710. * Stores the position
  48711. */
  48712. position: Vector3;
  48713. /**
  48714. * Stores the rotation
  48715. */
  48716. rotation: Vector3;
  48717. /**
  48718. * Stores the rotation quaternion
  48719. */
  48720. rotationQuaternion: Nullable<Quaternion>;
  48721. /**
  48722. * Stores the scaling vector
  48723. */
  48724. scaling: Vector3;
  48725. /**
  48726. * Convert the Mesh to CSG
  48727. * @param mesh The Mesh to convert to CSG
  48728. * @returns A new CSG from the Mesh
  48729. */
  48730. static FromMesh(mesh: Mesh): CSG;
  48731. /**
  48732. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48733. * @param polygons Polygons used to construct a CSG solid
  48734. */
  48735. private static FromPolygons;
  48736. /**
  48737. * Clones, or makes a deep copy, of the CSG
  48738. * @returns A new CSG
  48739. */
  48740. clone(): CSG;
  48741. /**
  48742. * Unions this CSG with another CSG
  48743. * @param csg The CSG to union against this CSG
  48744. * @returns The unioned CSG
  48745. */
  48746. union(csg: CSG): CSG;
  48747. /**
  48748. * Unions this CSG with another CSG in place
  48749. * @param csg The CSG to union against this CSG
  48750. */
  48751. unionInPlace(csg: CSG): void;
  48752. /**
  48753. * Subtracts this CSG with another CSG
  48754. * @param csg The CSG to subtract against this CSG
  48755. * @returns A new CSG
  48756. */
  48757. subtract(csg: CSG): CSG;
  48758. /**
  48759. * Subtracts this CSG with another CSG in place
  48760. * @param csg The CSG to subtact against this CSG
  48761. */
  48762. subtractInPlace(csg: CSG): void;
  48763. /**
  48764. * Intersect this CSG with another CSG
  48765. * @param csg The CSG to intersect against this CSG
  48766. * @returns A new CSG
  48767. */
  48768. intersect(csg: CSG): CSG;
  48769. /**
  48770. * Intersects this CSG with another CSG in place
  48771. * @param csg The CSG to intersect against this CSG
  48772. */
  48773. intersectInPlace(csg: CSG): void;
  48774. /**
  48775. * Return a new CSG solid with solid and empty space switched. This solid is
  48776. * not modified.
  48777. * @returns A new CSG solid with solid and empty space switched
  48778. */
  48779. inverse(): CSG;
  48780. /**
  48781. * Inverses the CSG in place
  48782. */
  48783. inverseInPlace(): void;
  48784. /**
  48785. * This is used to keep meshes transformations so they can be restored
  48786. * when we build back a Babylon Mesh
  48787. * NB : All CSG operations are performed in world coordinates
  48788. * @param csg The CSG to copy the transform attributes from
  48789. * @returns This CSG
  48790. */
  48791. copyTransformAttributes(csg: CSG): CSG;
  48792. /**
  48793. * Build Raw mesh from CSG
  48794. * Coordinates here are in world space
  48795. * @param name The name of the mesh geometry
  48796. * @param scene The Scene
  48797. * @param keepSubMeshes Specifies if the submeshes should be kept
  48798. * @returns A new Mesh
  48799. */
  48800. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48801. /**
  48802. * Build Mesh from CSG taking material and transforms into account
  48803. * @param name The name of the Mesh
  48804. * @param material The material of the Mesh
  48805. * @param scene The Scene
  48806. * @param keepSubMeshes Specifies if submeshes should be kept
  48807. * @returns The new Mesh
  48808. */
  48809. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48810. }
  48811. }
  48812. declare module BABYLON {
  48813. /**
  48814. * Class used to create a trail following a mesh
  48815. */
  48816. export class TrailMesh extends Mesh {
  48817. private _generator;
  48818. private _autoStart;
  48819. private _running;
  48820. private _diameter;
  48821. private _length;
  48822. private _sectionPolygonPointsCount;
  48823. private _sectionVectors;
  48824. private _sectionNormalVectors;
  48825. private _beforeRenderObserver;
  48826. /**
  48827. * @constructor
  48828. * @param name The value used by scene.getMeshByName() to do a lookup.
  48829. * @param generator The mesh to generate a trail.
  48830. * @param scene The scene to add this mesh to.
  48831. * @param diameter Diameter of trailing mesh. Default is 1.
  48832. * @param length Length of trailing mesh. Default is 60.
  48833. * @param autoStart Automatically start trailing mesh. Default true.
  48834. */
  48835. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  48836. /**
  48837. * "TrailMesh"
  48838. * @returns "TrailMesh"
  48839. */
  48840. getClassName(): string;
  48841. private _createMesh;
  48842. /**
  48843. * Start trailing mesh.
  48844. */
  48845. start(): void;
  48846. /**
  48847. * Stop trailing mesh.
  48848. */
  48849. stop(): void;
  48850. /**
  48851. * Update trailing mesh geometry.
  48852. */
  48853. update(): void;
  48854. /**
  48855. * Returns a new TrailMesh object.
  48856. * @param name is a string, the name given to the new mesh
  48857. * @param newGenerator use new generator object for cloned trail mesh
  48858. * @returns a new mesh
  48859. */
  48860. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  48861. /**
  48862. * Serializes this trail mesh
  48863. * @param serializationObject object to write serialization to
  48864. */
  48865. serialize(serializationObject: any): void;
  48866. /**
  48867. * Parses a serialized trail mesh
  48868. * @param parsedMesh the serialized mesh
  48869. * @param scene the scene to create the trail mesh in
  48870. * @returns the created trail mesh
  48871. */
  48872. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  48873. }
  48874. }
  48875. declare module BABYLON {
  48876. /**
  48877. * Class containing static functions to help procedurally build meshes
  48878. */
  48879. export class TorusKnotBuilder {
  48880. /**
  48881. * Creates a torus knot mesh
  48882. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48883. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48884. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48885. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48887. * * If you create a double-sided mesh, you can choose what parts of 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
  48888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48889. * @param name defines the name of the mesh
  48890. * @param options defines the options used to create the mesh
  48891. * @param scene defines the hosting scene
  48892. * @returns the torus knot mesh
  48893. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48894. */
  48895. static CreateTorusKnot(name: string, options: {
  48896. radius?: number;
  48897. tube?: number;
  48898. radialSegments?: number;
  48899. tubularSegments?: number;
  48900. p?: number;
  48901. q?: number;
  48902. updatable?: boolean;
  48903. sideOrientation?: number;
  48904. frontUVs?: Vector4;
  48905. backUVs?: Vector4;
  48906. }, scene: any): Mesh;
  48907. }
  48908. }
  48909. declare module BABYLON {
  48910. /**
  48911. * Polygon
  48912. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  48913. */
  48914. export class Polygon {
  48915. /**
  48916. * Creates a rectangle
  48917. * @param xmin bottom X coord
  48918. * @param ymin bottom Y coord
  48919. * @param xmax top X coord
  48920. * @param ymax top Y coord
  48921. * @returns points that make the resulting rectation
  48922. */
  48923. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  48924. /**
  48925. * Creates a circle
  48926. * @param radius radius of circle
  48927. * @param cx scale in x
  48928. * @param cy scale in y
  48929. * @param numberOfSides number of sides that make up the circle
  48930. * @returns points that make the resulting circle
  48931. */
  48932. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  48933. /**
  48934. * Creates a polygon from input string
  48935. * @param input Input polygon data
  48936. * @returns the parsed points
  48937. */
  48938. static Parse(input: string): Vector2[];
  48939. /**
  48940. * Starts building a polygon from x and y coordinates
  48941. * @param x x coordinate
  48942. * @param y y coordinate
  48943. * @returns the started path2
  48944. */
  48945. static StartingAt(x: number, y: number): Path2;
  48946. }
  48947. /**
  48948. * Builds a polygon
  48949. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  48950. */
  48951. export class PolygonMeshBuilder {
  48952. private _points;
  48953. private _outlinepoints;
  48954. private _holes;
  48955. private _name;
  48956. private _scene;
  48957. private _epoints;
  48958. private _eholes;
  48959. private _addToepoint;
  48960. /**
  48961. * Babylon reference to the earcut plugin.
  48962. */
  48963. bjsEarcut: any;
  48964. /**
  48965. * Creates a PolygonMeshBuilder
  48966. * @param name name of the builder
  48967. * @param contours Path of the polygon
  48968. * @param scene scene to add to when creating the mesh
  48969. * @param earcutInjection can be used to inject your own earcut reference
  48970. */
  48971. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  48972. /**
  48973. * Adds a whole within the polygon
  48974. * @param hole Array of points defining the hole
  48975. * @returns this
  48976. */
  48977. addHole(hole: Vector2[]): PolygonMeshBuilder;
  48978. /**
  48979. * Creates the polygon
  48980. * @param updatable If the mesh should be updatable
  48981. * @param depth The depth of the mesh created
  48982. * @returns the created mesh
  48983. */
  48984. build(updatable?: boolean, depth?: number): Mesh;
  48985. /**
  48986. * Creates the polygon
  48987. * @param depth The depth of the mesh created
  48988. * @returns the created VertexData
  48989. */
  48990. buildVertexData(depth?: number): VertexData;
  48991. /**
  48992. * Adds a side to the polygon
  48993. * @param positions points that make the polygon
  48994. * @param normals normals of the polygon
  48995. * @param uvs uvs of the polygon
  48996. * @param indices indices of the polygon
  48997. * @param bounds bounds of the polygon
  48998. * @param points points of the polygon
  48999. * @param depth depth of the polygon
  49000. * @param flip flip of the polygon
  49001. */
  49002. private addSide;
  49003. }
  49004. }
  49005. declare module BABYLON {
  49006. /**
  49007. * Class containing static functions to help procedurally build meshes
  49008. */
  49009. export class PolygonBuilder {
  49010. /**
  49011. * Creates a polygon mesh
  49012. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49013. * * 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
  49014. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49017. * * Remember you can only change the shape positions, not their number when updating a polygon
  49018. * @param name defines the name of the mesh
  49019. * @param options defines the options used to create the mesh
  49020. * @param scene defines the hosting scene
  49021. * @param earcutInjection can be used to inject your own earcut reference
  49022. * @returns the polygon mesh
  49023. */
  49024. static CreatePolygon(name: string, options: {
  49025. shape: Vector3[];
  49026. holes?: Vector3[][];
  49027. depth?: number;
  49028. faceUV?: Vector4[];
  49029. faceColors?: Color4[];
  49030. updatable?: boolean;
  49031. sideOrientation?: number;
  49032. frontUVs?: Vector4;
  49033. backUVs?: Vector4;
  49034. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49035. /**
  49036. * Creates an extruded polygon mesh, with depth in the Y direction.
  49037. * * 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)
  49038. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49039. * @param name defines the name of the mesh
  49040. * @param options defines the options used to create the mesh
  49041. * @param scene defines the hosting scene
  49042. * @param earcutInjection can be used to inject your own earcut reference
  49043. * @returns the polygon mesh
  49044. */
  49045. static ExtrudePolygon(name: string, options: {
  49046. shape: Vector3[];
  49047. holes?: Vector3[][];
  49048. depth?: number;
  49049. faceUV?: Vector4[];
  49050. faceColors?: Color4[];
  49051. updatable?: boolean;
  49052. sideOrientation?: number;
  49053. frontUVs?: Vector4;
  49054. backUVs?: Vector4;
  49055. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49056. }
  49057. }
  49058. declare module BABYLON {
  49059. /**
  49060. * Class containing static functions to help procedurally build meshes
  49061. */
  49062. export class LatheBuilder {
  49063. /**
  49064. * Creates lathe mesh.
  49065. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49066. * * 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
  49067. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49068. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49069. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49070. * * 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
  49071. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49072. * * 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
  49073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49074. * * If you create a double-sided mesh, you can choose what parts of 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
  49075. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49077. * @param name defines the name of the mesh
  49078. * @param options defines the options used to create the mesh
  49079. * @param scene defines the hosting scene
  49080. * @returns the lathe mesh
  49081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49082. */
  49083. static CreateLathe(name: string, options: {
  49084. shape: Vector3[];
  49085. radius?: number;
  49086. tessellation?: number;
  49087. clip?: number;
  49088. arc?: number;
  49089. closed?: boolean;
  49090. updatable?: boolean;
  49091. sideOrientation?: number;
  49092. frontUVs?: Vector4;
  49093. backUVs?: Vector4;
  49094. cap?: number;
  49095. invertUV?: boolean;
  49096. }, scene?: Nullable<Scene>): Mesh;
  49097. }
  49098. }
  49099. declare module BABYLON {
  49100. /**
  49101. * Class containing static functions to help procedurally build meshes
  49102. */
  49103. export class TubeBuilder {
  49104. /**
  49105. * Creates a tube mesh.
  49106. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49107. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49108. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49109. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49110. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49111. * * 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)
  49112. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49113. * * 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
  49114. * * 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
  49115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49116. * * If you create a double-sided mesh, you can choose what parts of 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
  49117. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49119. * @param name defines the name of the mesh
  49120. * @param options defines the options used to create the mesh
  49121. * @param scene defines the hosting scene
  49122. * @returns the tube mesh
  49123. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49124. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49125. */
  49126. static CreateTube(name: string, options: {
  49127. path: Vector3[];
  49128. radius?: number;
  49129. tessellation?: number;
  49130. radiusFunction?: {
  49131. (i: number, distance: number): number;
  49132. };
  49133. cap?: number;
  49134. arc?: number;
  49135. updatable?: boolean;
  49136. sideOrientation?: number;
  49137. frontUVs?: Vector4;
  49138. backUVs?: Vector4;
  49139. instance?: Mesh;
  49140. invertUV?: boolean;
  49141. }, scene?: Nullable<Scene>): Mesh;
  49142. }
  49143. }
  49144. declare module BABYLON {
  49145. /**
  49146. * Class containing static functions to help procedurally build meshes
  49147. */
  49148. export class IcoSphereBuilder {
  49149. /**
  49150. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49151. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49152. * * 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`)
  49153. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49154. * * 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
  49155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49156. * * If you create a double-sided mesh, you can choose what parts of 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
  49157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49158. * @param name defines the name of the mesh
  49159. * @param options defines the options used to create the mesh
  49160. * @param scene defines the hosting scene
  49161. * @returns the icosahedron mesh
  49162. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49163. */
  49164. static CreateIcoSphere(name: string, options: {
  49165. radius?: number;
  49166. radiusX?: number;
  49167. radiusY?: number;
  49168. radiusZ?: number;
  49169. flat?: boolean;
  49170. subdivisions?: number;
  49171. sideOrientation?: number;
  49172. frontUVs?: Vector4;
  49173. backUVs?: Vector4;
  49174. updatable?: boolean;
  49175. }, scene?: Nullable<Scene>): Mesh;
  49176. }
  49177. }
  49178. declare module BABYLON {
  49179. /**
  49180. * Class containing static functions to help procedurally build meshes
  49181. */
  49182. export class DecalBuilder {
  49183. /**
  49184. * Creates a decal mesh.
  49185. * 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
  49186. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49187. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49188. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49189. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49190. * @param name defines the name of the mesh
  49191. * @param sourceMesh defines the mesh where the decal must be applied
  49192. * @param options defines the options used to create the mesh
  49193. * @param scene defines the hosting scene
  49194. * @returns the decal mesh
  49195. * @see https://doc.babylonjs.com/how_to/decals
  49196. */
  49197. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49198. position?: Vector3;
  49199. normal?: Vector3;
  49200. size?: Vector3;
  49201. angle?: number;
  49202. }): Mesh;
  49203. }
  49204. }
  49205. declare module BABYLON {
  49206. /**
  49207. * Class containing static functions to help procedurally build meshes
  49208. */
  49209. export class MeshBuilder {
  49210. /**
  49211. * Creates a box mesh
  49212. * * The parameter `size` sets the size (float) of each box side (default 1)
  49213. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49214. * * 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)
  49215. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49217. * * If you create a double-sided mesh, you can choose what parts of 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
  49218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49219. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49220. * @param name defines the name of the mesh
  49221. * @param options defines the options used to create the mesh
  49222. * @param scene defines the hosting scene
  49223. * @returns the box mesh
  49224. */
  49225. static CreateBox(name: string, options: {
  49226. size?: number;
  49227. width?: number;
  49228. height?: number;
  49229. depth?: number;
  49230. faceUV?: Vector4[];
  49231. faceColors?: Color4[];
  49232. sideOrientation?: number;
  49233. frontUVs?: Vector4;
  49234. backUVs?: Vector4;
  49235. updatable?: boolean;
  49236. }, scene?: Nullable<Scene>): Mesh;
  49237. /**
  49238. * Creates a sphere mesh
  49239. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49240. * * 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`)
  49241. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49242. * * 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
  49243. * * 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)
  49244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49245. * * If you create a double-sided mesh, you can choose what parts of 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
  49246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49247. * @param name defines the name of the mesh
  49248. * @param options defines the options used to create the mesh
  49249. * @param scene defines the hosting scene
  49250. * @returns the sphere mesh
  49251. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49252. */
  49253. static CreateSphere(name: string, options: {
  49254. segments?: number;
  49255. diameter?: number;
  49256. diameterX?: number;
  49257. diameterY?: number;
  49258. diameterZ?: number;
  49259. arc?: number;
  49260. slice?: number;
  49261. sideOrientation?: number;
  49262. frontUVs?: Vector4;
  49263. backUVs?: Vector4;
  49264. updatable?: boolean;
  49265. }, scene?: Nullable<Scene>): Mesh;
  49266. /**
  49267. * Creates a plane polygonal mesh. By default, this is a disc
  49268. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49269. * * 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
  49270. * * 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
  49271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49272. * * If you create a double-sided mesh, you can choose what parts of 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
  49273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49274. * @param name defines the name of the mesh
  49275. * @param options defines the options used to create the mesh
  49276. * @param scene defines the hosting scene
  49277. * @returns the plane polygonal mesh
  49278. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49279. */
  49280. static CreateDisc(name: string, options: {
  49281. radius?: number;
  49282. tessellation?: number;
  49283. arc?: number;
  49284. updatable?: boolean;
  49285. sideOrientation?: number;
  49286. frontUVs?: Vector4;
  49287. backUVs?: Vector4;
  49288. }, scene?: Nullable<Scene>): Mesh;
  49289. /**
  49290. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49291. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49292. * * 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`)
  49293. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49294. * * 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
  49295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49296. * * If you create a double-sided mesh, you can choose what parts of 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
  49297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49298. * @param name defines the name of the mesh
  49299. * @param options defines the options used to create the mesh
  49300. * @param scene defines the hosting scene
  49301. * @returns the icosahedron mesh
  49302. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49303. */
  49304. static CreateIcoSphere(name: string, options: {
  49305. radius?: number;
  49306. radiusX?: number;
  49307. radiusY?: number;
  49308. radiusZ?: number;
  49309. flat?: boolean;
  49310. subdivisions?: number;
  49311. sideOrientation?: number;
  49312. frontUVs?: Vector4;
  49313. backUVs?: Vector4;
  49314. updatable?: boolean;
  49315. }, scene?: Nullable<Scene>): Mesh;
  49316. /**
  49317. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49318. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49319. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49320. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49321. * * 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
  49322. * * 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
  49323. * * 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
  49324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49325. * * If you create a double-sided mesh, you can choose what parts of 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
  49326. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49327. * * 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
  49328. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49329. * * 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
  49330. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49332. * @param name defines the name of the mesh
  49333. * @param options defines the options used to create the mesh
  49334. * @param scene defines the hosting scene
  49335. * @returns the ribbon mesh
  49336. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49337. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49338. */
  49339. static CreateRibbon(name: string, options: {
  49340. pathArray: Vector3[][];
  49341. closeArray?: boolean;
  49342. closePath?: boolean;
  49343. offset?: number;
  49344. updatable?: boolean;
  49345. sideOrientation?: number;
  49346. frontUVs?: Vector4;
  49347. backUVs?: Vector4;
  49348. instance?: Mesh;
  49349. invertUV?: boolean;
  49350. uvs?: Vector2[];
  49351. colors?: Color4[];
  49352. }, scene?: Nullable<Scene>): Mesh;
  49353. /**
  49354. * Creates a cylinder or a cone mesh
  49355. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49356. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49357. * * 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.
  49358. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49359. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49360. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49361. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49362. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49363. * * 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).
  49364. * * 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
  49365. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49366. * * 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
  49367. * * 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.
  49368. * * If `enclose` is false, a ring surface is one element.
  49369. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49370. * * 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
  49371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49372. * * If you create a double-sided mesh, you can choose what parts of 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
  49373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49374. * @param name defines the name of the mesh
  49375. * @param options defines the options used to create the mesh
  49376. * @param scene defines the hosting scene
  49377. * @returns the cylinder mesh
  49378. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49379. */
  49380. static CreateCylinder(name: string, options: {
  49381. height?: number;
  49382. diameterTop?: number;
  49383. diameterBottom?: number;
  49384. diameter?: number;
  49385. tessellation?: number;
  49386. subdivisions?: number;
  49387. arc?: number;
  49388. faceColors?: Color4[];
  49389. faceUV?: Vector4[];
  49390. updatable?: boolean;
  49391. hasRings?: boolean;
  49392. enclose?: boolean;
  49393. sideOrientation?: number;
  49394. frontUVs?: Vector4;
  49395. backUVs?: Vector4;
  49396. }, scene?: Nullable<Scene>): Mesh;
  49397. /**
  49398. * Creates a torus mesh
  49399. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49400. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49401. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49403. * * If you create a double-sided mesh, you can choose what parts of 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
  49404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49405. * @param name defines the name of the mesh
  49406. * @param options defines the options used to create the mesh
  49407. * @param scene defines the hosting scene
  49408. * @returns the torus mesh
  49409. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49410. */
  49411. static CreateTorus(name: string, options: {
  49412. diameter?: number;
  49413. thickness?: number;
  49414. tessellation?: number;
  49415. updatable?: boolean;
  49416. sideOrientation?: number;
  49417. frontUVs?: Vector4;
  49418. backUVs?: Vector4;
  49419. }, scene?: Nullable<Scene>): Mesh;
  49420. /**
  49421. * Creates a torus knot mesh
  49422. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49423. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49424. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49425. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49427. * * If you create a double-sided mesh, you can choose what parts of 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
  49428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49429. * @param name defines the name of the mesh
  49430. * @param options defines the options used to create the mesh
  49431. * @param scene defines the hosting scene
  49432. * @returns the torus knot mesh
  49433. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49434. */
  49435. static CreateTorusKnot(name: string, options: {
  49436. radius?: number;
  49437. tube?: number;
  49438. radialSegments?: number;
  49439. tubularSegments?: number;
  49440. p?: number;
  49441. q?: number;
  49442. updatable?: boolean;
  49443. sideOrientation?: number;
  49444. frontUVs?: Vector4;
  49445. backUVs?: Vector4;
  49446. }, scene?: Nullable<Scene>): Mesh;
  49447. /**
  49448. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49449. * * 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
  49450. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49451. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49452. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49453. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49454. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49455. * * 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
  49456. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49459. * @param name defines the name of the new line system
  49460. * @param options defines the options used to create the line system
  49461. * @param scene defines the hosting scene
  49462. * @returns a new line system mesh
  49463. */
  49464. static CreateLineSystem(name: string, options: {
  49465. lines: Vector3[][];
  49466. updatable?: boolean;
  49467. instance?: Nullable<LinesMesh>;
  49468. colors?: Nullable<Color4[][]>;
  49469. useVertexAlpha?: boolean;
  49470. }, scene: Nullable<Scene>): LinesMesh;
  49471. /**
  49472. * Creates a line mesh
  49473. * 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
  49474. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49475. * * The parameter `points` is an array successive Vector3
  49476. * * 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
  49477. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49478. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49479. * * When updating an instance, remember that only point positions can change, not the number of points
  49480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49482. * @param name defines the name of the new line system
  49483. * @param options defines the options used to create the line system
  49484. * @param scene defines the hosting scene
  49485. * @returns a new line mesh
  49486. */
  49487. static CreateLines(name: string, options: {
  49488. points: Vector3[];
  49489. updatable?: boolean;
  49490. instance?: Nullable<LinesMesh>;
  49491. colors?: Color4[];
  49492. useVertexAlpha?: boolean;
  49493. }, scene?: Nullable<Scene>): LinesMesh;
  49494. /**
  49495. * Creates a dashed line mesh
  49496. * * 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
  49497. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49498. * * The parameter `points` is an array successive Vector3
  49499. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49500. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49501. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49502. * * 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
  49503. * * When updating an instance, remember that only point positions can change, not the number of points
  49504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49505. * @param name defines the name of the mesh
  49506. * @param options defines the options used to create the mesh
  49507. * @param scene defines the hosting scene
  49508. * @returns the dashed line mesh
  49509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49510. */
  49511. static CreateDashedLines(name: string, options: {
  49512. points: Vector3[];
  49513. dashSize?: number;
  49514. gapSize?: number;
  49515. dashNb?: number;
  49516. updatable?: boolean;
  49517. instance?: LinesMesh;
  49518. }, scene?: Nullable<Scene>): LinesMesh;
  49519. /**
  49520. * 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.
  49521. * * 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.
  49522. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49523. * * 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.
  49524. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49525. * * 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
  49526. * * 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
  49527. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49529. * * If you create a double-sided mesh, you can choose what parts of 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
  49530. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49532. * @param name defines the name of the mesh
  49533. * @param options defines the options used to create the mesh
  49534. * @param scene defines the hosting scene
  49535. * @returns the extruded shape mesh
  49536. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49538. */
  49539. static ExtrudeShape(name: string, options: {
  49540. shape: Vector3[];
  49541. path: Vector3[];
  49542. scale?: number;
  49543. rotation?: number;
  49544. cap?: number;
  49545. updatable?: boolean;
  49546. sideOrientation?: number;
  49547. frontUVs?: Vector4;
  49548. backUVs?: Vector4;
  49549. instance?: Mesh;
  49550. invertUV?: boolean;
  49551. }, scene?: Nullable<Scene>): Mesh;
  49552. /**
  49553. * Creates an custom extruded shape mesh.
  49554. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49555. * * 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.
  49556. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49557. * * 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
  49558. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49559. * * 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
  49560. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49561. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49562. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49563. * * 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
  49564. * * 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
  49565. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49567. * * If you create a double-sided mesh, you can choose what parts of 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
  49568. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49570. * @param name defines the name of the mesh
  49571. * @param options defines the options used to create the mesh
  49572. * @param scene defines the hosting scene
  49573. * @returns the custom extruded shape mesh
  49574. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49575. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49577. */
  49578. static ExtrudeShapeCustom(name: string, options: {
  49579. shape: Vector3[];
  49580. path: Vector3[];
  49581. scaleFunction?: any;
  49582. rotationFunction?: any;
  49583. ribbonCloseArray?: boolean;
  49584. ribbonClosePath?: boolean;
  49585. cap?: number;
  49586. updatable?: boolean;
  49587. sideOrientation?: number;
  49588. frontUVs?: Vector4;
  49589. backUVs?: Vector4;
  49590. instance?: Mesh;
  49591. invertUV?: boolean;
  49592. }, scene?: Nullable<Scene>): Mesh;
  49593. /**
  49594. * Creates lathe mesh.
  49595. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49596. * * 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
  49597. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49598. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49599. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49600. * * 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
  49601. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49602. * * 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
  49603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49604. * * If you create a double-sided mesh, you can choose what parts of 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
  49605. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49607. * @param name defines the name of the mesh
  49608. * @param options defines the options used to create the mesh
  49609. * @param scene defines the hosting scene
  49610. * @returns the lathe mesh
  49611. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49612. */
  49613. static CreateLathe(name: string, options: {
  49614. shape: Vector3[];
  49615. radius?: number;
  49616. tessellation?: number;
  49617. clip?: number;
  49618. arc?: number;
  49619. closed?: boolean;
  49620. updatable?: boolean;
  49621. sideOrientation?: number;
  49622. frontUVs?: Vector4;
  49623. backUVs?: Vector4;
  49624. cap?: number;
  49625. invertUV?: boolean;
  49626. }, scene?: Nullable<Scene>): Mesh;
  49627. /**
  49628. * Creates a plane mesh
  49629. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49630. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49631. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49633. * * If you create a double-sided mesh, you can choose what parts of 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
  49634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49635. * @param name defines the name of the mesh
  49636. * @param options defines the options used to create the mesh
  49637. * @param scene defines the hosting scene
  49638. * @returns the plane mesh
  49639. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49640. */
  49641. static CreatePlane(name: string, options: {
  49642. size?: number;
  49643. width?: number;
  49644. height?: number;
  49645. sideOrientation?: number;
  49646. frontUVs?: Vector4;
  49647. backUVs?: Vector4;
  49648. updatable?: boolean;
  49649. sourcePlane?: Plane;
  49650. }, scene?: Nullable<Scene>): Mesh;
  49651. /**
  49652. * Creates a ground mesh
  49653. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49654. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49656. * @param name defines the name of the mesh
  49657. * @param options defines the options used to create the mesh
  49658. * @param scene defines the hosting scene
  49659. * @returns the ground mesh
  49660. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49661. */
  49662. static CreateGround(name: string, options: {
  49663. width?: number;
  49664. height?: number;
  49665. subdivisions?: number;
  49666. subdivisionsX?: number;
  49667. subdivisionsY?: number;
  49668. updatable?: boolean;
  49669. }, scene?: Nullable<Scene>): Mesh;
  49670. /**
  49671. * Creates a tiled ground mesh
  49672. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49673. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49674. * * 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
  49675. * * 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
  49676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49677. * @param name defines the name of the mesh
  49678. * @param options defines the options used to create the mesh
  49679. * @param scene defines the hosting scene
  49680. * @returns the tiled ground mesh
  49681. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49682. */
  49683. static CreateTiledGround(name: string, options: {
  49684. xmin: number;
  49685. zmin: number;
  49686. xmax: number;
  49687. zmax: number;
  49688. subdivisions?: {
  49689. w: number;
  49690. h: number;
  49691. };
  49692. precision?: {
  49693. w: number;
  49694. h: number;
  49695. };
  49696. updatable?: boolean;
  49697. }, scene?: Nullable<Scene>): Mesh;
  49698. /**
  49699. * Creates a ground mesh from a height map
  49700. * * The parameter `url` sets the URL of the height map image resource.
  49701. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49702. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49703. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49704. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49705. * * 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.
  49706. * * 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).
  49707. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49709. * @param name defines the name of the mesh
  49710. * @param url defines the url to the height map
  49711. * @param options defines the options used to create the mesh
  49712. * @param scene defines the hosting scene
  49713. * @returns the ground mesh
  49714. * @see https://doc.babylonjs.com/babylon101/height_map
  49715. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49716. */
  49717. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49718. width?: number;
  49719. height?: number;
  49720. subdivisions?: number;
  49721. minHeight?: number;
  49722. maxHeight?: number;
  49723. colorFilter?: Color3;
  49724. alphaFilter?: number;
  49725. updatable?: boolean;
  49726. onReady?: (mesh: GroundMesh) => void;
  49727. }, scene?: Nullable<Scene>): GroundMesh;
  49728. /**
  49729. * Creates a polygon mesh
  49730. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49731. * * 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
  49732. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49735. * * Remember you can only change the shape positions, not their number when updating a polygon
  49736. * @param name defines the name of the mesh
  49737. * @param options defines the options used to create the mesh
  49738. * @param scene defines the hosting scene
  49739. * @param earcutInjection can be used to inject your own earcut reference
  49740. * @returns the polygon mesh
  49741. */
  49742. static CreatePolygon(name: string, options: {
  49743. shape: Vector3[];
  49744. holes?: Vector3[][];
  49745. depth?: number;
  49746. faceUV?: Vector4[];
  49747. faceColors?: Color4[];
  49748. updatable?: boolean;
  49749. sideOrientation?: number;
  49750. frontUVs?: Vector4;
  49751. backUVs?: Vector4;
  49752. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49753. /**
  49754. * Creates an extruded polygon mesh, with depth in the Y direction.
  49755. * * 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)
  49756. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49757. * @param name defines the name of the mesh
  49758. * @param options defines the options used to create the mesh
  49759. * @param scene defines the hosting scene
  49760. * @param earcutInjection can be used to inject your own earcut reference
  49761. * @returns the polygon mesh
  49762. */
  49763. static ExtrudePolygon(name: string, options: {
  49764. shape: Vector3[];
  49765. holes?: Vector3[][];
  49766. depth?: number;
  49767. faceUV?: Vector4[];
  49768. faceColors?: Color4[];
  49769. updatable?: boolean;
  49770. sideOrientation?: number;
  49771. frontUVs?: Vector4;
  49772. backUVs?: Vector4;
  49773. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49774. /**
  49775. * Creates a tube mesh.
  49776. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49777. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49778. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49779. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49780. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49781. * * 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)
  49782. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49783. * * 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
  49784. * * 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
  49785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49786. * * If you create a double-sided mesh, you can choose what parts of 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
  49787. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49789. * @param name defines the name of the mesh
  49790. * @param options defines the options used to create the mesh
  49791. * @param scene defines the hosting scene
  49792. * @returns the tube mesh
  49793. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49794. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49795. */
  49796. static CreateTube(name: string, options: {
  49797. path: Vector3[];
  49798. radius?: number;
  49799. tessellation?: number;
  49800. radiusFunction?: {
  49801. (i: number, distance: number): number;
  49802. };
  49803. cap?: number;
  49804. arc?: number;
  49805. updatable?: boolean;
  49806. sideOrientation?: number;
  49807. frontUVs?: Vector4;
  49808. backUVs?: Vector4;
  49809. instance?: Mesh;
  49810. invertUV?: boolean;
  49811. }, scene?: Nullable<Scene>): Mesh;
  49812. /**
  49813. * Creates a polyhedron mesh
  49814. * * 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
  49815. * * The parameter `size` (positive float, default 1) sets the polygon size
  49816. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49817. * * 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`
  49818. * * 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
  49819. * * 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)`)
  49820. * * 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
  49821. * * 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
  49822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49823. * * If you create a double-sided mesh, you can choose what parts of 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
  49824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49825. * @param name defines the name of the mesh
  49826. * @param options defines the options used to create the mesh
  49827. * @param scene defines the hosting scene
  49828. * @returns the polyhedron mesh
  49829. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49830. */
  49831. static CreatePolyhedron(name: string, options: {
  49832. type?: number;
  49833. size?: number;
  49834. sizeX?: number;
  49835. sizeY?: number;
  49836. sizeZ?: number;
  49837. custom?: any;
  49838. faceUV?: Vector4[];
  49839. faceColors?: Color4[];
  49840. flat?: boolean;
  49841. updatable?: boolean;
  49842. sideOrientation?: number;
  49843. frontUVs?: Vector4;
  49844. backUVs?: Vector4;
  49845. }, scene?: Nullable<Scene>): Mesh;
  49846. /**
  49847. * Creates a decal mesh.
  49848. * 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
  49849. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49850. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49851. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49852. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49853. * @param name defines the name of the mesh
  49854. * @param sourceMesh defines the mesh where the decal must be applied
  49855. * @param options defines the options used to create the mesh
  49856. * @param scene defines the hosting scene
  49857. * @returns the decal mesh
  49858. * @see https://doc.babylonjs.com/how_to/decals
  49859. */
  49860. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49861. position?: Vector3;
  49862. normal?: Vector3;
  49863. size?: Vector3;
  49864. angle?: number;
  49865. }): Mesh;
  49866. }
  49867. }
  49868. declare module BABYLON {
  49869. /**
  49870. * A simplifier interface for future simplification implementations
  49871. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49872. */
  49873. export interface ISimplifier {
  49874. /**
  49875. * Simplification of a given mesh according to the given settings.
  49876. * Since this requires computation, it is assumed that the function runs async.
  49877. * @param settings The settings of the simplification, including quality and distance
  49878. * @param successCallback A callback that will be called after the mesh was simplified.
  49879. * @param errorCallback in case of an error, this callback will be called. optional.
  49880. */
  49881. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49882. }
  49883. /**
  49884. * Expected simplification settings.
  49885. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49886. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49887. */
  49888. export interface ISimplificationSettings {
  49889. /**
  49890. * Gets or sets the expected quality
  49891. */
  49892. quality: number;
  49893. /**
  49894. * Gets or sets the distance when this optimized version should be used
  49895. */
  49896. distance: number;
  49897. /**
  49898. * Gets an already optimized mesh
  49899. */
  49900. optimizeMesh?: boolean;
  49901. }
  49902. /**
  49903. * Class used to specify simplification options
  49904. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49905. */
  49906. export class SimplificationSettings implements ISimplificationSettings {
  49907. /** expected quality */
  49908. quality: number;
  49909. /** distance when this optimized version should be used */
  49910. distance: number;
  49911. /** already optimized mesh */
  49912. optimizeMesh?: boolean | undefined;
  49913. /**
  49914. * Creates a SimplificationSettings
  49915. * @param quality expected quality
  49916. * @param distance distance when this optimized version should be used
  49917. * @param optimizeMesh already optimized mesh
  49918. */
  49919. constructor(
  49920. /** expected quality */
  49921. quality: number,
  49922. /** distance when this optimized version should be used */
  49923. distance: number,
  49924. /** already optimized mesh */
  49925. optimizeMesh?: boolean | undefined);
  49926. }
  49927. /**
  49928. * Interface used to define a simplification task
  49929. */
  49930. export interface ISimplificationTask {
  49931. /**
  49932. * Array of settings
  49933. */
  49934. settings: Array<ISimplificationSettings>;
  49935. /**
  49936. * Simplification type
  49937. */
  49938. simplificationType: SimplificationType;
  49939. /**
  49940. * Mesh to simplify
  49941. */
  49942. mesh: Mesh;
  49943. /**
  49944. * Callback called on success
  49945. */
  49946. successCallback?: () => void;
  49947. /**
  49948. * Defines if parallel processing can be used
  49949. */
  49950. parallelProcessing: boolean;
  49951. }
  49952. /**
  49953. * Queue used to order the simplification tasks
  49954. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49955. */
  49956. export class SimplificationQueue {
  49957. private _simplificationArray;
  49958. /**
  49959. * Gets a boolean indicating that the process is still running
  49960. */
  49961. running: boolean;
  49962. /**
  49963. * Creates a new queue
  49964. */
  49965. constructor();
  49966. /**
  49967. * Adds a new simplification task
  49968. * @param task defines a task to add
  49969. */
  49970. addTask(task: ISimplificationTask): void;
  49971. /**
  49972. * Execute next task
  49973. */
  49974. executeNext(): void;
  49975. /**
  49976. * Execute a simplification task
  49977. * @param task defines the task to run
  49978. */
  49979. runSimplification(task: ISimplificationTask): void;
  49980. private getSimplifier;
  49981. }
  49982. /**
  49983. * The implemented types of simplification
  49984. * At the moment only Quadratic Error Decimation is implemented
  49985. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49986. */
  49987. export enum SimplificationType {
  49988. /** Quadratic error decimation */
  49989. QUADRATIC = 0
  49990. }
  49991. }
  49992. declare module BABYLON {
  49993. interface Scene {
  49994. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  49995. /**
  49996. * Gets or sets the simplification queue attached to the scene
  49997. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49998. */
  49999. simplificationQueue: SimplificationQueue;
  50000. }
  50001. interface Mesh {
  50002. /**
  50003. * Simplify the mesh according to the given array of settings.
  50004. * Function will return immediately and will simplify async
  50005. * @param settings a collection of simplification settings
  50006. * @param parallelProcessing should all levels calculate parallel or one after the other
  50007. * @param simplificationType the type of simplification to run
  50008. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50009. * @returns the current mesh
  50010. */
  50011. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50012. }
  50013. /**
  50014. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50015. * created in a scene
  50016. */
  50017. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50018. /**
  50019. * The component name helpfull to identify the component in the list of scene components.
  50020. */
  50021. readonly name: string;
  50022. /**
  50023. * The scene the component belongs to.
  50024. */
  50025. scene: Scene;
  50026. /**
  50027. * Creates a new instance of the component for the given scene
  50028. * @param scene Defines the scene to register the component in
  50029. */
  50030. constructor(scene: Scene);
  50031. /**
  50032. * Registers the component in a given scene
  50033. */
  50034. register(): void;
  50035. /**
  50036. * Rebuilds the elements related to this component in case of
  50037. * context lost for instance.
  50038. */
  50039. rebuild(): void;
  50040. /**
  50041. * Disposes the component and the associated ressources
  50042. */
  50043. dispose(): void;
  50044. private _beforeCameraUpdate;
  50045. }
  50046. }
  50047. declare module BABYLON {
  50048. /**
  50049. * Class used to enable access to IndexedDB
  50050. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50051. */
  50052. export class Database implements IOfflineProvider {
  50053. private _callbackManifestChecked;
  50054. private _currentSceneUrl;
  50055. private _db;
  50056. private _enableSceneOffline;
  50057. private _enableTexturesOffline;
  50058. private _manifestVersionFound;
  50059. private _mustUpdateRessources;
  50060. private _hasReachedQuota;
  50061. private _isSupported;
  50062. private _idbFactory;
  50063. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50064. private static IsUASupportingBlobStorage;
  50065. /**
  50066. * Gets a boolean indicating if Database storate is enabled (off by default)
  50067. */
  50068. static IDBStorageEnabled: boolean;
  50069. /**
  50070. * Gets a boolean indicating if scene must be saved in the database
  50071. */
  50072. readonly enableSceneOffline: boolean;
  50073. /**
  50074. * Gets a boolean indicating if textures must be saved in the database
  50075. */
  50076. readonly enableTexturesOffline: boolean;
  50077. /**
  50078. * Creates a new Database
  50079. * @param urlToScene defines the url to load the scene
  50080. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50081. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50082. */
  50083. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50084. private static _ParseURL;
  50085. private static _ReturnFullUrlLocation;
  50086. private _checkManifestFile;
  50087. /**
  50088. * Open the database and make it available
  50089. * @param successCallback defines the callback to call on success
  50090. * @param errorCallback defines the callback to call on error
  50091. */
  50092. open(successCallback: () => void, errorCallback: () => void): void;
  50093. /**
  50094. * Loads an image from the database
  50095. * @param url defines the url to load from
  50096. * @param image defines the target DOM image
  50097. */
  50098. loadImage(url: string, image: HTMLImageElement): void;
  50099. private _loadImageFromDBAsync;
  50100. private _saveImageIntoDBAsync;
  50101. private _checkVersionFromDB;
  50102. private _loadVersionFromDBAsync;
  50103. private _saveVersionIntoDBAsync;
  50104. /**
  50105. * Loads a file from database
  50106. * @param url defines the URL to load from
  50107. * @param sceneLoaded defines a callback to call on success
  50108. * @param progressCallBack defines a callback to call when progress changed
  50109. * @param errorCallback defines a callback to call on error
  50110. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50111. */
  50112. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50113. private _loadFileAsync;
  50114. private _saveFileAsync;
  50115. /**
  50116. * Validates if xhr data is correct
  50117. * @param xhr defines the request to validate
  50118. * @param dataType defines the expected data type
  50119. * @returns true if data is correct
  50120. */
  50121. private static _ValidateXHRData;
  50122. }
  50123. }
  50124. declare module BABYLON {
  50125. /** @hidden */
  50126. export var gpuUpdateParticlesPixelShader: {
  50127. name: string;
  50128. shader: string;
  50129. };
  50130. }
  50131. declare module BABYLON {
  50132. /** @hidden */
  50133. export var gpuUpdateParticlesVertexShader: {
  50134. name: string;
  50135. shader: string;
  50136. };
  50137. }
  50138. declare module BABYLON {
  50139. /** @hidden */
  50140. export var clipPlaneFragmentDeclaration2: {
  50141. name: string;
  50142. shader: string;
  50143. };
  50144. }
  50145. declare module BABYLON {
  50146. /** @hidden */
  50147. export var gpuRenderParticlesPixelShader: {
  50148. name: string;
  50149. shader: string;
  50150. };
  50151. }
  50152. declare module BABYLON {
  50153. /** @hidden */
  50154. export var clipPlaneVertexDeclaration2: {
  50155. name: string;
  50156. shader: string;
  50157. };
  50158. }
  50159. declare module BABYLON {
  50160. /** @hidden */
  50161. export var gpuRenderParticlesVertexShader: {
  50162. name: string;
  50163. shader: string;
  50164. };
  50165. }
  50166. declare module BABYLON {
  50167. /**
  50168. * This represents a GPU particle system in Babylon
  50169. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50170. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50171. */
  50172. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50173. /**
  50174. * The layer mask we are rendering the particles through.
  50175. */
  50176. layerMask: number;
  50177. private _capacity;
  50178. private _activeCount;
  50179. private _currentActiveCount;
  50180. private _accumulatedCount;
  50181. private _renderEffect;
  50182. private _updateEffect;
  50183. private _buffer0;
  50184. private _buffer1;
  50185. private _spriteBuffer;
  50186. private _updateVAO;
  50187. private _renderVAO;
  50188. private _targetIndex;
  50189. private _sourceBuffer;
  50190. private _targetBuffer;
  50191. private _engine;
  50192. private _currentRenderId;
  50193. private _started;
  50194. private _stopped;
  50195. private _timeDelta;
  50196. private _randomTexture;
  50197. private _randomTexture2;
  50198. private _attributesStrideSize;
  50199. private _updateEffectOptions;
  50200. private _randomTextureSize;
  50201. private _actualFrame;
  50202. private readonly _rawTextureWidth;
  50203. /**
  50204. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50205. */
  50206. static readonly IsSupported: boolean;
  50207. /**
  50208. * An event triggered when the system is disposed.
  50209. */
  50210. onDisposeObservable: Observable<GPUParticleSystem>;
  50211. /**
  50212. * Gets the maximum number of particles active at the same time.
  50213. * @returns The max number of active particles.
  50214. */
  50215. getCapacity(): number;
  50216. /**
  50217. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50218. * to override the particles.
  50219. */
  50220. forceDepthWrite: boolean;
  50221. /**
  50222. * Gets or set the number of active particles
  50223. */
  50224. activeParticleCount: number;
  50225. private _preWarmDone;
  50226. /**
  50227. * Is this system ready to be used/rendered
  50228. * @return true if the system is ready
  50229. */
  50230. isReady(): boolean;
  50231. /**
  50232. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50233. * @returns True if it has been started, otherwise false.
  50234. */
  50235. isStarted(): boolean;
  50236. /**
  50237. * Starts the particle system and begins to emit
  50238. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50239. */
  50240. start(delay?: number): void;
  50241. /**
  50242. * Stops the particle system.
  50243. */
  50244. stop(): void;
  50245. /**
  50246. * Remove all active particles
  50247. */
  50248. reset(): void;
  50249. /**
  50250. * Returns the string "GPUParticleSystem"
  50251. * @returns a string containing the class name
  50252. */
  50253. getClassName(): string;
  50254. private _colorGradientsTexture;
  50255. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50256. /**
  50257. * Adds a new color gradient
  50258. * @param gradient defines the gradient to use (between 0 and 1)
  50259. * @param color1 defines the color to affect to the specified gradient
  50260. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50261. * @returns the current particle system
  50262. */
  50263. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50264. /**
  50265. * Remove a specific color gradient
  50266. * @param gradient defines the gradient to remove
  50267. * @returns the current particle system
  50268. */
  50269. removeColorGradient(gradient: number): GPUParticleSystem;
  50270. private _angularSpeedGradientsTexture;
  50271. private _sizeGradientsTexture;
  50272. private _velocityGradientsTexture;
  50273. private _limitVelocityGradientsTexture;
  50274. private _dragGradientsTexture;
  50275. private _addFactorGradient;
  50276. /**
  50277. * Adds a new size gradient
  50278. * @param gradient defines the gradient to use (between 0 and 1)
  50279. * @param factor defines the size factor to affect to the specified gradient
  50280. * @returns the current particle system
  50281. */
  50282. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50283. /**
  50284. * Remove a specific size gradient
  50285. * @param gradient defines the gradient to remove
  50286. * @returns the current particle system
  50287. */
  50288. removeSizeGradient(gradient: number): GPUParticleSystem;
  50289. /**
  50290. * Adds a new angular speed gradient
  50291. * @param gradient defines the gradient to use (between 0 and 1)
  50292. * @param factor defines the angular speed to affect to the specified gradient
  50293. * @returns the current particle system
  50294. */
  50295. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50296. /**
  50297. * Remove a specific angular speed gradient
  50298. * @param gradient defines the gradient to remove
  50299. * @returns the current particle system
  50300. */
  50301. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50302. /**
  50303. * Adds a new velocity gradient
  50304. * @param gradient defines the gradient to use (between 0 and 1)
  50305. * @param factor defines the velocity to affect to the specified gradient
  50306. * @returns the current particle system
  50307. */
  50308. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50309. /**
  50310. * Remove a specific velocity gradient
  50311. * @param gradient defines the gradient to remove
  50312. * @returns the current particle system
  50313. */
  50314. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50315. /**
  50316. * Adds a new limit velocity gradient
  50317. * @param gradient defines the gradient to use (between 0 and 1)
  50318. * @param factor defines the limit velocity value to affect to the specified gradient
  50319. * @returns the current particle system
  50320. */
  50321. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50322. /**
  50323. * Remove a specific limit velocity gradient
  50324. * @param gradient defines the gradient to remove
  50325. * @returns the current particle system
  50326. */
  50327. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50328. /**
  50329. * Adds a new drag gradient
  50330. * @param gradient defines the gradient to use (between 0 and 1)
  50331. * @param factor defines the drag value to affect to the specified gradient
  50332. * @returns the current particle system
  50333. */
  50334. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50335. /**
  50336. * Remove a specific drag gradient
  50337. * @param gradient defines the gradient to remove
  50338. * @returns the current particle system
  50339. */
  50340. removeDragGradient(gradient: number): GPUParticleSystem;
  50341. /**
  50342. * Not supported by GPUParticleSystem
  50343. * @param gradient defines the gradient to use (between 0 and 1)
  50344. * @param factor defines the emit rate value to affect to the specified gradient
  50345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50346. * @returns the current particle system
  50347. */
  50348. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50349. /**
  50350. * Not supported by GPUParticleSystem
  50351. * @param gradient defines the gradient to remove
  50352. * @returns the current particle system
  50353. */
  50354. removeEmitRateGradient(gradient: number): IParticleSystem;
  50355. /**
  50356. * Not supported by GPUParticleSystem
  50357. * @param gradient defines the gradient to use (between 0 and 1)
  50358. * @param factor defines the start size value to affect to the specified gradient
  50359. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50360. * @returns the current particle system
  50361. */
  50362. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50363. /**
  50364. * Not supported by GPUParticleSystem
  50365. * @param gradient defines the gradient to remove
  50366. * @returns the current particle system
  50367. */
  50368. removeStartSizeGradient(gradient: number): IParticleSystem;
  50369. /**
  50370. * Not supported by GPUParticleSystem
  50371. * @param gradient defines the gradient to use (between 0 and 1)
  50372. * @param min defines the color remap minimal range
  50373. * @param max defines the color remap maximal range
  50374. * @returns the current particle system
  50375. */
  50376. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50377. /**
  50378. * Not supported by GPUParticleSystem
  50379. * @param gradient defines the gradient to remove
  50380. * @returns the current particle system
  50381. */
  50382. removeColorRemapGradient(): IParticleSystem;
  50383. /**
  50384. * Not supported by GPUParticleSystem
  50385. * @param gradient defines the gradient to use (between 0 and 1)
  50386. * @param min defines the alpha remap minimal range
  50387. * @param max defines the alpha remap maximal range
  50388. * @returns the current particle system
  50389. */
  50390. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50391. /**
  50392. * Not supported by GPUParticleSystem
  50393. * @param gradient defines the gradient to remove
  50394. * @returns the current particle system
  50395. */
  50396. removeAlphaRemapGradient(): IParticleSystem;
  50397. /**
  50398. * Not supported by GPUParticleSystem
  50399. * @param gradient defines the gradient to use (between 0 and 1)
  50400. * @param color defines the color to affect to the specified gradient
  50401. * @returns the current particle system
  50402. */
  50403. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50404. /**
  50405. * Not supported by GPUParticleSystem
  50406. * @param gradient defines the gradient to remove
  50407. * @returns the current particle system
  50408. */
  50409. removeRampGradient(): IParticleSystem;
  50410. /**
  50411. * Not supported by GPUParticleSystem
  50412. * @returns the list of ramp gradients
  50413. */
  50414. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50415. /**
  50416. * Not supported by GPUParticleSystem
  50417. * Gets or sets a boolean indicating that ramp gradients must be used
  50418. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50419. */
  50420. useRampGradients: boolean;
  50421. /**
  50422. * Not supported by GPUParticleSystem
  50423. * @param gradient defines the gradient to use (between 0 and 1)
  50424. * @param factor defines the life time factor to affect to the specified gradient
  50425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50426. * @returns the current particle system
  50427. */
  50428. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50429. /**
  50430. * Not supported by GPUParticleSystem
  50431. * @param gradient defines the gradient to remove
  50432. * @returns the current particle system
  50433. */
  50434. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50435. /**
  50436. * Instantiates a GPU particle system.
  50437. * 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.
  50438. * @param name The name of the particle system
  50439. * @param options The options used to create the system
  50440. * @param scene The scene the particle system belongs to
  50441. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50442. */
  50443. constructor(name: string, options: Partial<{
  50444. capacity: number;
  50445. randomTextureSize: number;
  50446. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50447. protected _reset(): void;
  50448. private _createUpdateVAO;
  50449. private _createRenderVAO;
  50450. private _initialize;
  50451. /** @hidden */ recreateUpdateEffect(): void;
  50452. /** @hidden */ recreateRenderEffect(): void;
  50453. /**
  50454. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50455. * @param preWarm defines if we are in the pre-warmimg phase
  50456. */
  50457. animate(preWarm?: boolean): void;
  50458. private _createFactorGradientTexture;
  50459. private _createSizeGradientTexture;
  50460. private _createAngularSpeedGradientTexture;
  50461. private _createVelocityGradientTexture;
  50462. private _createLimitVelocityGradientTexture;
  50463. private _createDragGradientTexture;
  50464. private _createColorGradientTexture;
  50465. /**
  50466. * Renders the particle system in its current state
  50467. * @param preWarm defines if the system should only update the particles but not render them
  50468. * @returns the current number of particles
  50469. */
  50470. render(preWarm?: boolean): number;
  50471. /**
  50472. * Rebuilds the particle system
  50473. */
  50474. rebuild(): void;
  50475. private _releaseBuffers;
  50476. private _releaseVAOs;
  50477. /**
  50478. * Disposes the particle system and free the associated resources
  50479. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50480. */
  50481. dispose(disposeTexture?: boolean): void;
  50482. /**
  50483. * Clones the particle system.
  50484. * @param name The name of the cloned object
  50485. * @param newEmitter The new emitter to use
  50486. * @returns the cloned particle system
  50487. */
  50488. clone(name: string, newEmitter: any): GPUParticleSystem;
  50489. /**
  50490. * Serializes the particle system to a JSON object.
  50491. * @returns the JSON object
  50492. */
  50493. serialize(): any;
  50494. /**
  50495. * Parses a JSON object to create a GPU particle system.
  50496. * @param parsedParticleSystem The JSON object to parse
  50497. * @param scene The scene to create the particle system in
  50498. * @param rootUrl The root url to use to load external dependencies like texture
  50499. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50500. * @returns the parsed GPU particle system
  50501. */
  50502. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50503. }
  50504. }
  50505. declare module BABYLON {
  50506. /**
  50507. * Represents a set of particle systems working together to create a specific effect
  50508. */
  50509. export class ParticleSystemSet implements IDisposable {
  50510. private _emitterCreationOptions;
  50511. private _emitterNode;
  50512. /**
  50513. * Gets the particle system list
  50514. */
  50515. systems: IParticleSystem[];
  50516. /**
  50517. * Gets the emitter node used with this set
  50518. */
  50519. readonly emitterNode: Nullable<TransformNode>;
  50520. /**
  50521. * Creates a new emitter mesh as a sphere
  50522. * @param options defines the options used to create the sphere
  50523. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50524. * @param scene defines the hosting scene
  50525. */
  50526. setEmitterAsSphere(options: {
  50527. diameter: number;
  50528. segments: number;
  50529. color: Color3;
  50530. }, renderingGroupId: number, scene: Scene): void;
  50531. /**
  50532. * Starts all particle systems of the set
  50533. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50534. */
  50535. start(emitter?: AbstractMesh): void;
  50536. /**
  50537. * Release all associated resources
  50538. */
  50539. dispose(): void;
  50540. /**
  50541. * Serialize the set into a JSON compatible object
  50542. * @returns a JSON compatible representation of the set
  50543. */
  50544. serialize(): any;
  50545. /**
  50546. * Parse a new ParticleSystemSet from a serialized source
  50547. * @param data defines a JSON compatible representation of the set
  50548. * @param scene defines the hosting scene
  50549. * @param gpu defines if we want GPU particles or CPU particles
  50550. * @returns a new ParticleSystemSet
  50551. */
  50552. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50553. }
  50554. }
  50555. declare module BABYLON {
  50556. /**
  50557. * This class is made for on one-liner static method to help creating particle system set.
  50558. */
  50559. export class ParticleHelper {
  50560. /**
  50561. * Gets or sets base Assets URL
  50562. */
  50563. static BaseAssetsUrl: string;
  50564. /**
  50565. * Create a default particle system that you can tweak
  50566. * @param emitter defines the emitter to use
  50567. * @param capacity defines the system capacity (default is 500 particles)
  50568. * @param scene defines the hosting scene
  50569. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50570. * @returns the new Particle system
  50571. */
  50572. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50573. /**
  50574. * This is the main static method (one-liner) of this helper to create different particle systems
  50575. * @param type This string represents the type to the particle system to create
  50576. * @param scene The scene where the particle system should live
  50577. * @param gpu If the system will use gpu
  50578. * @returns the ParticleSystemSet created
  50579. */
  50580. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50581. /**
  50582. * Static function used to export a particle system to a ParticleSystemSet variable.
  50583. * Please note that the emitter shape is not exported
  50584. * @param systems defines the particle systems to export
  50585. * @returns the created particle system set
  50586. */
  50587. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50588. }
  50589. }
  50590. declare module BABYLON {
  50591. interface Engine {
  50592. /**
  50593. * Create an effect to use with particle systems.
  50594. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50595. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50596. * @param uniformsNames defines a list of attribute names
  50597. * @param samplers defines an array of string used to represent textures
  50598. * @param defines defines the string containing the defines to use to compile the shaders
  50599. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50600. * @param onCompiled defines a function to call when the effect creation is successful
  50601. * @param onError defines a function to call when the effect creation has failed
  50602. * @returns the new Effect
  50603. */
  50604. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50605. }
  50606. interface Mesh {
  50607. /**
  50608. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50609. * @returns an array of IParticleSystem
  50610. */
  50611. getEmittedParticleSystems(): IParticleSystem[];
  50612. /**
  50613. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50614. * @returns an array of IParticleSystem
  50615. */
  50616. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50617. }
  50618. /**
  50619. * @hidden
  50620. */
  50621. export var _IDoNeedToBeInTheBuild: number;
  50622. }
  50623. declare module BABYLON {
  50624. interface Scene {
  50625. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  50626. /**
  50627. * Gets the current physics engine
  50628. * @returns a IPhysicsEngine or null if none attached
  50629. */
  50630. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50631. /**
  50632. * Enables physics to the current scene
  50633. * @param gravity defines the scene's gravity for the physics engine
  50634. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50635. * @return a boolean indicating if the physics engine was initialized
  50636. */
  50637. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50638. /**
  50639. * Disables and disposes the physics engine associated with the scene
  50640. */
  50641. disablePhysicsEngine(): void;
  50642. /**
  50643. * Gets a boolean indicating if there is an active physics engine
  50644. * @returns a boolean indicating if there is an active physics engine
  50645. */
  50646. isPhysicsEnabled(): boolean;
  50647. /**
  50648. * Deletes a physics compound impostor
  50649. * @param compound defines the compound to delete
  50650. */
  50651. deleteCompoundImpostor(compound: any): void;
  50652. /**
  50653. * An event triggered when physic simulation is about to be run
  50654. */
  50655. onBeforePhysicsObservable: Observable<Scene>;
  50656. /**
  50657. * An event triggered when physic simulation has been done
  50658. */
  50659. onAfterPhysicsObservable: Observable<Scene>;
  50660. }
  50661. interface AbstractMesh {
  50662. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  50663. /**
  50664. * Gets or sets impostor used for physic simulation
  50665. * @see http://doc.babylonjs.com/features/physics_engine
  50666. */
  50667. physicsImpostor: Nullable<PhysicsImpostor>;
  50668. /**
  50669. * Gets the current physics impostor
  50670. * @see http://doc.babylonjs.com/features/physics_engine
  50671. * @returns a physics impostor or null
  50672. */
  50673. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50674. /** Apply a physic impulse to the mesh
  50675. * @param force defines the force to apply
  50676. * @param contactPoint defines where to apply the force
  50677. * @returns the current mesh
  50678. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50679. */
  50680. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50681. /**
  50682. * Creates a physic joint between two meshes
  50683. * @param otherMesh defines the other mesh to use
  50684. * @param pivot1 defines the pivot to use on this mesh
  50685. * @param pivot2 defines the pivot to use on the other mesh
  50686. * @param options defines additional options (can be plugin dependent)
  50687. * @returns the current mesh
  50688. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50689. */
  50690. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50691. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  50692. }
  50693. /**
  50694. * Defines the physics engine scene component responsible to manage a physics engine
  50695. */
  50696. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50697. /**
  50698. * The component name helpful to identify the component in the list of scene components.
  50699. */
  50700. readonly name: string;
  50701. /**
  50702. * The scene the component belongs to.
  50703. */
  50704. scene: Scene;
  50705. /**
  50706. * Creates a new instance of the component for the given scene
  50707. * @param scene Defines the scene to register the component in
  50708. */
  50709. constructor(scene: Scene);
  50710. /**
  50711. * Registers the component in a given scene
  50712. */
  50713. register(): void;
  50714. /**
  50715. * Rebuilds the elements related to this component in case of
  50716. * context lost for instance.
  50717. */
  50718. rebuild(): void;
  50719. /**
  50720. * Disposes the component and the associated ressources
  50721. */
  50722. dispose(): void;
  50723. }
  50724. }
  50725. declare module BABYLON {
  50726. /**
  50727. * A helper for physics simulations
  50728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50729. */
  50730. export class PhysicsHelper {
  50731. private _scene;
  50732. private _physicsEngine;
  50733. /**
  50734. * Initializes the Physics helper
  50735. * @param scene Babylon.js scene
  50736. */
  50737. constructor(scene: Scene);
  50738. /**
  50739. * Applies a radial explosion impulse
  50740. * @param origin the origin of the explosion
  50741. * @param radiusOrEventOptions the radius or the options of radial explosion
  50742. * @param strength the explosion strength
  50743. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50744. * @returns A physics radial explosion event, or null
  50745. */
  50746. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50747. /**
  50748. * Applies a radial explosion force
  50749. * @param origin the origin of the explosion
  50750. * @param radiusOrEventOptions the radius or the options of radial explosion
  50751. * @param strength the explosion strength
  50752. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50753. * @returns A physics radial explosion event, or null
  50754. */
  50755. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50756. /**
  50757. * Creates a gravitational field
  50758. * @param origin the origin of the explosion
  50759. * @param radiusOrEventOptions the radius or the options of radial explosion
  50760. * @param strength the explosion strength
  50761. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50762. * @returns A physics gravitational field event, or null
  50763. */
  50764. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50765. /**
  50766. * Creates a physics updraft event
  50767. * @param origin the origin of the updraft
  50768. * @param radiusOrEventOptions the radius or the options of the updraft
  50769. * @param strength the strength of the updraft
  50770. * @param height the height of the updraft
  50771. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50772. * @returns A physics updraft event, or null
  50773. */
  50774. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50775. /**
  50776. * Creates a physics vortex event
  50777. * @param origin the of the vortex
  50778. * @param radiusOrEventOptions the radius or the options of the vortex
  50779. * @param strength the strength of the vortex
  50780. * @param height the height of the vortex
  50781. * @returns a Physics vortex event, or null
  50782. * A physics vortex event or null
  50783. */
  50784. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  50785. }
  50786. /**
  50787. * Represents a physics radial explosion event
  50788. */
  50789. class PhysicsRadialExplosionEvent {
  50790. private _scene;
  50791. private _options;
  50792. private _sphere;
  50793. private _dataFetched;
  50794. /**
  50795. * Initializes a radial explosioin event
  50796. * @param _scene BabylonJS scene
  50797. * @param _options The options for the vortex event
  50798. */
  50799. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  50800. /**
  50801. * Returns the data related to the radial explosion event (sphere).
  50802. * @returns The radial explosion event data
  50803. */
  50804. getData(): PhysicsRadialExplosionEventData;
  50805. /**
  50806. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50807. * @param impostor A physics imposter
  50808. * @param origin the origin of the explosion
  50809. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  50810. */
  50811. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  50812. /**
  50813. * Triggers affecterd impostors callbacks
  50814. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  50815. */
  50816. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  50817. /**
  50818. * Disposes the sphere.
  50819. * @param force Specifies if the sphere should be disposed by force
  50820. */
  50821. dispose(force?: boolean): void;
  50822. /*** Helpers ***/
  50823. private _prepareSphere;
  50824. private _intersectsWithSphere;
  50825. }
  50826. /**
  50827. * Represents a gravitational field event
  50828. */
  50829. class PhysicsGravitationalFieldEvent {
  50830. private _physicsHelper;
  50831. private _scene;
  50832. private _origin;
  50833. private _options;
  50834. private _tickCallback;
  50835. private _sphere;
  50836. private _dataFetched;
  50837. /**
  50838. * Initializes the physics gravitational field event
  50839. * @param _physicsHelper A physics helper
  50840. * @param _scene BabylonJS scene
  50841. * @param _origin The origin position of the gravitational field event
  50842. * @param _options The options for the vortex event
  50843. */
  50844. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  50845. /**
  50846. * Returns the data related to the gravitational field event (sphere).
  50847. * @returns A gravitational field event
  50848. */
  50849. getData(): PhysicsGravitationalFieldEventData;
  50850. /**
  50851. * Enables the gravitational field.
  50852. */
  50853. enable(): void;
  50854. /**
  50855. * Disables the gravitational field.
  50856. */
  50857. disable(): void;
  50858. /**
  50859. * Disposes the sphere.
  50860. * @param force The force to dispose from the gravitational field event
  50861. */
  50862. dispose(force?: boolean): void;
  50863. private _tick;
  50864. }
  50865. /**
  50866. * Represents a physics updraft event
  50867. */
  50868. class PhysicsUpdraftEvent {
  50869. private _scene;
  50870. private _origin;
  50871. private _options;
  50872. private _physicsEngine;
  50873. private _originTop;
  50874. private _originDirection;
  50875. private _tickCallback;
  50876. private _cylinder;
  50877. private _cylinderPosition;
  50878. private _dataFetched;
  50879. /**
  50880. * Initializes the physics updraft event
  50881. * @param _scene BabylonJS scene
  50882. * @param _origin The origin position of the updraft
  50883. * @param _options The options for the updraft event
  50884. */
  50885. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  50886. /**
  50887. * Returns the data related to the updraft event (cylinder).
  50888. * @returns A physics updraft event
  50889. */
  50890. getData(): PhysicsUpdraftEventData;
  50891. /**
  50892. * Enables the updraft.
  50893. */
  50894. enable(): void;
  50895. /**
  50896. * Disables the updraft.
  50897. */
  50898. disable(): void;
  50899. /**
  50900. * Disposes the cylinder.
  50901. * @param force Specifies if the updraft should be disposed by force
  50902. */
  50903. dispose(force?: boolean): void;
  50904. private getImpostorHitData;
  50905. private _tick;
  50906. /*** Helpers ***/
  50907. private _prepareCylinder;
  50908. private _intersectsWithCylinder;
  50909. }
  50910. /**
  50911. * Represents a physics vortex event
  50912. */
  50913. class PhysicsVortexEvent {
  50914. private _scene;
  50915. private _origin;
  50916. private _options;
  50917. private _physicsEngine;
  50918. private _originTop;
  50919. private _tickCallback;
  50920. private _cylinder;
  50921. private _cylinderPosition;
  50922. private _dataFetched;
  50923. /**
  50924. * Initializes the physics vortex event
  50925. * @param _scene The BabylonJS scene
  50926. * @param _origin The origin position of the vortex
  50927. * @param _options The options for the vortex event
  50928. */
  50929. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  50930. /**
  50931. * Returns the data related to the vortex event (cylinder).
  50932. * @returns The physics vortex event data
  50933. */
  50934. getData(): PhysicsVortexEventData;
  50935. /**
  50936. * Enables the vortex.
  50937. */
  50938. enable(): void;
  50939. /**
  50940. * Disables the cortex.
  50941. */
  50942. disable(): void;
  50943. /**
  50944. * Disposes the sphere.
  50945. * @param force
  50946. */
  50947. dispose(force?: boolean): void;
  50948. private getImpostorHitData;
  50949. private _tick;
  50950. /*** Helpers ***/
  50951. private _prepareCylinder;
  50952. private _intersectsWithCylinder;
  50953. }
  50954. /**
  50955. * Options fot the radial explosion event
  50956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50957. */
  50958. export class PhysicsRadialExplosionEventOptions {
  50959. /**
  50960. * The radius of the sphere for the radial explosion.
  50961. */
  50962. radius: number;
  50963. /**
  50964. * The strenth of the explosion.
  50965. */
  50966. strength: number;
  50967. /**
  50968. * The strenght of the force in correspondence to the distance of the affected object
  50969. */
  50970. falloff: PhysicsRadialImpulseFalloff;
  50971. /**
  50972. * Sphere options for the radial explosion.
  50973. */
  50974. sphere: {
  50975. segments: number;
  50976. diameter: number;
  50977. };
  50978. /**
  50979. * Sphere options for the radial explosion.
  50980. */
  50981. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  50982. }
  50983. /**
  50984. * Options fot the updraft event
  50985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50986. */
  50987. export class PhysicsUpdraftEventOptions {
  50988. /**
  50989. * The radius of the cylinder for the vortex
  50990. */
  50991. radius: number;
  50992. /**
  50993. * The strenth of the updraft.
  50994. */
  50995. strength: number;
  50996. /**
  50997. * The height of the cylinder for the updraft.
  50998. */
  50999. height: number;
  51000. /**
  51001. * The mode for the the updraft.
  51002. */
  51003. updraftMode: PhysicsUpdraftMode;
  51004. }
  51005. /**
  51006. * Options fot the vortex event
  51007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51008. */
  51009. export class PhysicsVortexEventOptions {
  51010. /**
  51011. * The radius of the cylinder for the vortex
  51012. */
  51013. radius: number;
  51014. /**
  51015. * The strenth of the vortex.
  51016. */
  51017. strength: number;
  51018. /**
  51019. * The height of the cylinder for the vortex.
  51020. */
  51021. height: number;
  51022. /**
  51023. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51024. */
  51025. centripetalForceThreshold: number;
  51026. /**
  51027. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51028. */
  51029. centripetalForceMultiplier: number;
  51030. /**
  51031. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51032. */
  51033. centrifugalForceMultiplier: number;
  51034. /**
  51035. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51036. */
  51037. updraftForceMultiplier: number;
  51038. }
  51039. /**
  51040. * The strenght of the force in correspondence to the distance of the affected object
  51041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51042. */
  51043. export enum PhysicsRadialImpulseFalloff {
  51044. /** Defines that impulse is constant in strength across it's whole radius */
  51045. Constant = 0,
  51046. /** Defines that impulse gets weaker if it's further from the origin */
  51047. Linear = 1
  51048. }
  51049. /**
  51050. * The strength of the force in correspondence to the distance of the affected object
  51051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51052. */
  51053. export enum PhysicsUpdraftMode {
  51054. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51055. Center = 0,
  51056. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51057. Perpendicular = 1
  51058. }
  51059. /**
  51060. * Interface for a physics hit data
  51061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51062. */
  51063. export interface PhysicsHitData {
  51064. /**
  51065. * The force applied at the contact point
  51066. */
  51067. force: Vector3;
  51068. /**
  51069. * The contact point
  51070. */
  51071. contactPoint: Vector3;
  51072. /**
  51073. * The distance from the origin to the contact point
  51074. */
  51075. distanceFromOrigin: number;
  51076. }
  51077. /**
  51078. * Interface for radial explosion event data
  51079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51080. */
  51081. export interface PhysicsRadialExplosionEventData {
  51082. /**
  51083. * A sphere used for the radial explosion event
  51084. */
  51085. sphere: Mesh;
  51086. }
  51087. /**
  51088. * Interface for gravitational field event data
  51089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51090. */
  51091. export interface PhysicsGravitationalFieldEventData {
  51092. /**
  51093. * A sphere mesh used for the gravitational field event
  51094. */
  51095. sphere: Mesh;
  51096. }
  51097. /**
  51098. * Interface for updraft event data
  51099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51100. */
  51101. export interface PhysicsUpdraftEventData {
  51102. /**
  51103. * A cylinder used for the updraft event
  51104. */
  51105. cylinder: Mesh;
  51106. }
  51107. /**
  51108. * Interface for vortex event data
  51109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51110. */
  51111. export interface PhysicsVortexEventData {
  51112. /**
  51113. * A cylinder used for the vortex event
  51114. */
  51115. cylinder: Mesh;
  51116. }
  51117. /**
  51118. * Interface for an affected physics impostor
  51119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51120. */
  51121. export interface PhysicsAffectedImpostorWithData {
  51122. /**
  51123. * The impostor affected by the effect
  51124. */
  51125. impostor: PhysicsImpostor;
  51126. /**
  51127. * The data about the hit/horce from the explosion
  51128. */
  51129. hitData: PhysicsHitData;
  51130. }
  51131. }
  51132. declare module BABYLON {
  51133. /** @hidden */
  51134. export var blackAndWhitePixelShader: {
  51135. name: string;
  51136. shader: string;
  51137. };
  51138. }
  51139. declare module BABYLON {
  51140. /**
  51141. * Post process used to render in black and white
  51142. */
  51143. export class BlackAndWhitePostProcess extends PostProcess {
  51144. /**
  51145. * Linear about to convert he result to black and white (default: 1)
  51146. */
  51147. degree: number;
  51148. /**
  51149. * Creates a black and white post process
  51150. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51151. * @param name The name of the effect.
  51152. * @param options The required width/height ratio to downsize to before computing the render pass.
  51153. * @param camera The camera to apply the render pass to.
  51154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51155. * @param engine The engine which the post process will be applied. (default: current engine)
  51156. * @param reusable If the post process can be reused on the same frame. (default: false)
  51157. */
  51158. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51159. }
  51160. }
  51161. declare module BABYLON {
  51162. /**
  51163. * This represents a set of one or more post processes in Babylon.
  51164. * A post process can be used to apply a shader to a texture after it is rendered.
  51165. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51166. */
  51167. export class PostProcessRenderEffect {
  51168. private _postProcesses;
  51169. private _getPostProcesses;
  51170. private _singleInstance;
  51171. private _cameras;
  51172. private _indicesForCamera;
  51173. /**
  51174. * Name of the effect
  51175. * @hidden
  51176. */ name: string;
  51177. /**
  51178. * Instantiates a post process render effect.
  51179. * A post process can be used to apply a shader to a texture after it is rendered.
  51180. * @param engine The engine the effect is tied to
  51181. * @param name The name of the effect
  51182. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51183. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51184. */
  51185. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51186. /**
  51187. * Checks if all the post processes in the effect are supported.
  51188. */
  51189. readonly isSupported: boolean;
  51190. /**
  51191. * Updates the current state of the effect
  51192. * @hidden
  51193. */ update(): void;
  51194. /**
  51195. * Attaches the effect on cameras
  51196. * @param cameras The camera to attach to.
  51197. * @hidden
  51198. */ attachCameras(cameras: Camera): void;
  51199. /**
  51200. * Attaches the effect on cameras
  51201. * @param cameras The camera to attach to.
  51202. * @hidden
  51203. */ attachCameras(cameras: Camera[]): void;
  51204. /**
  51205. * Detatches the effect on cameras
  51206. * @param cameras The camera to detatch from.
  51207. * @hidden
  51208. */ detachCameras(cameras: Camera): void;
  51209. /**
  51210. * Detatches the effect on cameras
  51211. * @param cameras The camera to detatch from.
  51212. * @hidden
  51213. */ detachCameras(cameras: Camera[]): void;
  51214. /**
  51215. * Enables the effect on given cameras
  51216. * @param cameras The camera to enable.
  51217. * @hidden
  51218. */ enable(cameras: Camera): void;
  51219. /**
  51220. * Enables the effect on given cameras
  51221. * @param cameras The camera to enable.
  51222. * @hidden
  51223. */ enable(cameras: Nullable<Camera[]>): void;
  51224. /**
  51225. * Disables the effect on the given cameras
  51226. * @param cameras The camera to disable.
  51227. * @hidden
  51228. */ disable(cameras: Camera): void;
  51229. /**
  51230. * Disables the effect on the given cameras
  51231. * @param cameras The camera to disable.
  51232. * @hidden
  51233. */ disable(cameras: Nullable<Camera[]>): void;
  51234. /**
  51235. * Gets a list of the post processes contained in the effect.
  51236. * @param camera The camera to get the post processes on.
  51237. * @returns The list of the post processes in the effect.
  51238. */
  51239. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51240. }
  51241. }
  51242. declare module BABYLON {
  51243. /** @hidden */
  51244. export var extractHighlightsPixelShader: {
  51245. name: string;
  51246. shader: string;
  51247. };
  51248. }
  51249. declare module BABYLON {
  51250. /**
  51251. * 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.
  51252. */
  51253. export class ExtractHighlightsPostProcess extends PostProcess {
  51254. /**
  51255. * The luminance threshold, pixels below this value will be set to black.
  51256. */
  51257. threshold: number;
  51258. /** @hidden */ exposure: number;
  51259. /**
  51260. * Post process which has the input texture to be used when performing highlight extraction
  51261. * @hidden
  51262. */ inputPostProcess: Nullable<PostProcess>;
  51263. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51264. }
  51265. }
  51266. declare module BABYLON {
  51267. /** @hidden */
  51268. export var bloomMergePixelShader: {
  51269. name: string;
  51270. shader: string;
  51271. };
  51272. }
  51273. declare module BABYLON {
  51274. /**
  51275. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51276. */
  51277. export class BloomMergePostProcess extends PostProcess {
  51278. /** Weight of the bloom to be added to the original input. */
  51279. weight: number;
  51280. /**
  51281. * Creates a new instance of @see BloomMergePostProcess
  51282. * @param name The name of the effect.
  51283. * @param originalFromInput Post process which's input will be used for the merge.
  51284. * @param blurred Blurred highlights post process which's output will be used.
  51285. * @param weight Weight of the bloom to be added to the original input.
  51286. * @param options The required width/height ratio to downsize to before computing the render pass.
  51287. * @param camera The camera to apply the render pass to.
  51288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51289. * @param engine The engine which the post process will be applied. (default: current engine)
  51290. * @param reusable If the post process can be reused on the same frame. (default: false)
  51291. * @param textureType Type of textures used when performing the post process. (default: 0)
  51292. * @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)
  51293. */
  51294. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51295. /** Weight of the bloom to be added to the original input. */
  51296. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51297. }
  51298. }
  51299. declare module BABYLON {
  51300. /**
  51301. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51302. */
  51303. export class BloomEffect extends PostProcessRenderEffect {
  51304. private bloomScale;
  51305. /**
  51306. * @hidden Internal
  51307. */ effects: Array<PostProcess>;
  51308. /**
  51309. * @hidden Internal
  51310. */ downscale: ExtractHighlightsPostProcess;
  51311. private _blurX;
  51312. private _blurY;
  51313. private _merge;
  51314. /**
  51315. * The luminance threshold to find bright areas of the image to bloom.
  51316. */
  51317. threshold: number;
  51318. /**
  51319. * The strength of the bloom.
  51320. */
  51321. weight: number;
  51322. /**
  51323. * Specifies the size of the bloom blur kernel, relative to the final output size
  51324. */
  51325. kernel: number;
  51326. /**
  51327. * Creates a new instance of @see BloomEffect
  51328. * @param scene The scene the effect belongs to.
  51329. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51330. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51331. * @param bloomWeight The the strength of bloom.
  51332. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51333. * @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)
  51334. */
  51335. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51336. /**
  51337. * Disposes each of the internal effects for a given camera.
  51338. * @param camera The camera to dispose the effect on.
  51339. */
  51340. disposeEffects(camera: Camera): void;
  51341. /**
  51342. * @hidden Internal
  51343. */ updateEffects(): void;
  51344. /**
  51345. * Internal
  51346. * @returns if all the contained post processes are ready.
  51347. * @hidden
  51348. */ isReady(): boolean;
  51349. }
  51350. }
  51351. declare module BABYLON {
  51352. /** @hidden */
  51353. export var chromaticAberrationPixelShader: {
  51354. name: string;
  51355. shader: string;
  51356. };
  51357. }
  51358. declare module BABYLON {
  51359. /**
  51360. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51361. */
  51362. export class ChromaticAberrationPostProcess extends PostProcess {
  51363. /**
  51364. * The amount of seperation of rgb channels (default: 30)
  51365. */
  51366. aberrationAmount: number;
  51367. /**
  51368. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51369. */
  51370. radialIntensity: number;
  51371. /**
  51372. * 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))
  51373. */
  51374. direction: Vector2;
  51375. /**
  51376. * 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))
  51377. */
  51378. centerPosition: Vector2;
  51379. /**
  51380. * Creates a new instance ChromaticAberrationPostProcess
  51381. * @param name The name of the effect.
  51382. * @param screenWidth The width of the screen to apply the effect on.
  51383. * @param screenHeight The height of the screen to apply the effect on.
  51384. * @param options The required width/height ratio to downsize to before computing the render pass.
  51385. * @param camera The camera to apply the render pass to.
  51386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51387. * @param engine The engine which the post process will be applied. (default: current engine)
  51388. * @param reusable If the post process can be reused on the same frame. (default: false)
  51389. * @param textureType Type of textures used when performing the post process. (default: 0)
  51390. * @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)
  51391. */
  51392. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51393. }
  51394. }
  51395. declare module BABYLON {
  51396. /** @hidden */
  51397. export var circleOfConfusionPixelShader: {
  51398. name: string;
  51399. shader: string;
  51400. };
  51401. }
  51402. declare module BABYLON {
  51403. /**
  51404. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51405. */
  51406. export class CircleOfConfusionPostProcess extends PostProcess {
  51407. /**
  51408. * 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.
  51409. */
  51410. lensSize: number;
  51411. /**
  51412. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51413. */
  51414. fStop: number;
  51415. /**
  51416. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51417. */
  51418. focusDistance: number;
  51419. /**
  51420. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51421. */
  51422. focalLength: number;
  51423. private _depthTexture;
  51424. /**
  51425. * Creates a new instance CircleOfConfusionPostProcess
  51426. * @param name The name of the effect.
  51427. * @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.
  51428. * @param options The required width/height ratio to downsize to before computing the render pass.
  51429. * @param camera The camera to apply the render pass to.
  51430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51431. * @param engine The engine which the post process will be applied. (default: current engine)
  51432. * @param reusable If the post process can be reused on the same frame. (default: false)
  51433. * @param textureType Type of textures used when performing the post process. (default: 0)
  51434. * @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)
  51435. */
  51436. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51437. /**
  51438. * 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.
  51439. */
  51440. depthTexture: RenderTargetTexture;
  51441. }
  51442. }
  51443. declare module BABYLON {
  51444. /** @hidden */
  51445. export var colorCorrectionPixelShader: {
  51446. name: string;
  51447. shader: string;
  51448. };
  51449. }
  51450. declare module BABYLON {
  51451. /**
  51452. *
  51453. * This post-process allows the modification of rendered colors by using
  51454. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51455. *
  51456. * The object needs to be provided an url to a texture containing the color
  51457. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51458. * Use an image editing software to tweak the LUT to match your needs.
  51459. *
  51460. * For an example of a color LUT, see here:
  51461. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51462. * For explanations on color grading, see here:
  51463. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51464. *
  51465. */
  51466. export class ColorCorrectionPostProcess extends PostProcess {
  51467. private _colorTableTexture;
  51468. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51469. }
  51470. }
  51471. declare module BABYLON {
  51472. /** @hidden */
  51473. export var convolutionPixelShader: {
  51474. name: string;
  51475. shader: string;
  51476. };
  51477. }
  51478. declare module BABYLON {
  51479. /**
  51480. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51481. * input texture to perform effects such as edge detection or sharpening
  51482. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51483. */
  51484. export class ConvolutionPostProcess extends PostProcess {
  51485. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51486. kernel: number[];
  51487. /**
  51488. * Creates a new instance ConvolutionPostProcess
  51489. * @param name The name of the effect.
  51490. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51491. * @param options The required width/height ratio to downsize to before computing the render pass.
  51492. * @param camera The camera to apply the render pass to.
  51493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51494. * @param engine The engine which the post process will be applied. (default: current engine)
  51495. * @param reusable If the post process can be reused on the same frame. (default: false)
  51496. * @param textureType Type of textures used when performing the post process. (default: 0)
  51497. */
  51498. constructor(name: string,
  51499. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51500. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51501. /**
  51502. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51503. */
  51504. static EdgeDetect0Kernel: number[];
  51505. /**
  51506. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51507. */
  51508. static EdgeDetect1Kernel: number[];
  51509. /**
  51510. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51511. */
  51512. static EdgeDetect2Kernel: number[];
  51513. /**
  51514. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51515. */
  51516. static SharpenKernel: number[];
  51517. /**
  51518. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51519. */
  51520. static EmbossKernel: number[];
  51521. /**
  51522. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51523. */
  51524. static GaussianKernel: number[];
  51525. }
  51526. }
  51527. declare module BABYLON {
  51528. /**
  51529. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51530. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51531. * based on samples that have a large difference in distance than the center pixel.
  51532. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51533. */
  51534. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51535. direction: Vector2;
  51536. /**
  51537. * Creates a new instance CircleOfConfusionPostProcess
  51538. * @param name The name of the effect.
  51539. * @param scene The scene the effect belongs to.
  51540. * @param direction The direction the blur should be applied.
  51541. * @param kernel The size of the kernel used to blur.
  51542. * @param options The required width/height ratio to downsize to before computing the render pass.
  51543. * @param camera The camera to apply the render pass to.
  51544. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51545. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51547. * @param engine The engine which the post process will be applied. (default: current engine)
  51548. * @param reusable If the post process can be reused on the same frame. (default: false)
  51549. * @param textureType Type of textures used when performing the post process. (default: 0)
  51550. * @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)
  51551. */
  51552. 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);
  51553. }
  51554. }
  51555. declare module BABYLON {
  51556. /** @hidden */
  51557. export var depthOfFieldMergePixelShader: {
  51558. name: string;
  51559. shader: string;
  51560. };
  51561. }
  51562. declare module BABYLON {
  51563. /**
  51564. * Options to be set when merging outputs from the default pipeline.
  51565. */
  51566. export class DepthOfFieldMergePostProcessOptions {
  51567. /**
  51568. * The original image to merge on top of
  51569. */
  51570. originalFromInput: PostProcess;
  51571. /**
  51572. * Parameters to perform the merge of the depth of field effect
  51573. */
  51574. depthOfField?: {
  51575. circleOfConfusion: PostProcess;
  51576. blurSteps: Array<PostProcess>;
  51577. };
  51578. /**
  51579. * Parameters to perform the merge of bloom effect
  51580. */
  51581. bloom?: {
  51582. blurred: PostProcess;
  51583. weight: number;
  51584. };
  51585. }
  51586. /**
  51587. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51588. */
  51589. export class DepthOfFieldMergePostProcess extends PostProcess {
  51590. private blurSteps;
  51591. /**
  51592. * Creates a new instance of DepthOfFieldMergePostProcess
  51593. * @param name The name of the effect.
  51594. * @param originalFromInput Post process which's input will be used for the merge.
  51595. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51596. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51597. * @param options The required width/height ratio to downsize to before computing the render pass.
  51598. * @param camera The camera to apply the render pass to.
  51599. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51600. * @param engine The engine which the post process will be applied. (default: current engine)
  51601. * @param reusable If the post process can be reused on the same frame. (default: false)
  51602. * @param textureType Type of textures used when performing the post process. (default: 0)
  51603. * @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)
  51604. */
  51605. 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);
  51606. /**
  51607. * Updates the effect with the current post process compile time values and recompiles the shader.
  51608. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51609. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51610. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51611. * @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
  51612. * @param onCompiled Called when the shader has been compiled.
  51613. * @param onError Called if there is an error when compiling a shader.
  51614. */
  51615. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51616. }
  51617. }
  51618. declare module BABYLON {
  51619. /**
  51620. * Specifies the level of max blur that should be applied when using the depth of field effect
  51621. */
  51622. export enum DepthOfFieldEffectBlurLevel {
  51623. /**
  51624. * Subtle blur
  51625. */
  51626. Low = 0,
  51627. /**
  51628. * Medium blur
  51629. */
  51630. Medium = 1,
  51631. /**
  51632. * Large blur
  51633. */
  51634. High = 2
  51635. }
  51636. /**
  51637. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51638. */
  51639. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51640. private _circleOfConfusion;
  51641. /**
  51642. * @hidden Internal, blurs from high to low
  51643. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51644. private _depthOfFieldBlurY;
  51645. private _dofMerge;
  51646. /**
  51647. * @hidden Internal post processes in depth of field effect
  51648. */ effects: Array<PostProcess>;
  51649. /**
  51650. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51651. */
  51652. focalLength: number;
  51653. /**
  51654. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51655. */
  51656. fStop: number;
  51657. /**
  51658. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51659. */
  51660. focusDistance: number;
  51661. /**
  51662. * 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.
  51663. */
  51664. lensSize: number;
  51665. /**
  51666. * Creates a new instance DepthOfFieldEffect
  51667. * @param scene The scene the effect belongs to.
  51668. * @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.
  51669. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51670. * @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)
  51671. */
  51672. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  51673. /**
  51674. * 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.
  51675. */
  51676. depthTexture: RenderTargetTexture;
  51677. /**
  51678. * Disposes each of the internal effects for a given camera.
  51679. * @param camera The camera to dispose the effect on.
  51680. */
  51681. disposeEffects(camera: Camera): void;
  51682. /**
  51683. * @hidden Internal
  51684. */ updateEffects(): void;
  51685. /**
  51686. * Internal
  51687. * @returns if all the contained post processes are ready.
  51688. * @hidden
  51689. */ isReady(): boolean;
  51690. }
  51691. }
  51692. declare module BABYLON {
  51693. /** @hidden */
  51694. export var displayPassPixelShader: {
  51695. name: string;
  51696. shader: string;
  51697. };
  51698. }
  51699. declare module BABYLON {
  51700. /**
  51701. * DisplayPassPostProcess which produces an output the same as it's input
  51702. */
  51703. export class DisplayPassPostProcess extends PostProcess {
  51704. /**
  51705. * Creates the DisplayPassPostProcess
  51706. * @param name The name of the effect.
  51707. * @param options The required width/height ratio to downsize to before computing the render pass.
  51708. * @param camera The camera to apply the render pass to.
  51709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51710. * @param engine The engine which the post process will be applied. (default: current engine)
  51711. * @param reusable If the post process can be reused on the same frame. (default: false)
  51712. */
  51713. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51714. }
  51715. }
  51716. declare module BABYLON {
  51717. /** @hidden */
  51718. export var filterPixelShader: {
  51719. name: string;
  51720. shader: string;
  51721. };
  51722. }
  51723. declare module BABYLON {
  51724. /**
  51725. * Applies a kernel filter to the image
  51726. */
  51727. export class FilterPostProcess extends PostProcess {
  51728. /** The matrix to be applied to the image */
  51729. kernelMatrix: Matrix;
  51730. /**
  51731. *
  51732. * @param name The name of the effect.
  51733. * @param kernelMatrix The matrix to be applied to the image
  51734. * @param options The required width/height ratio to downsize to before computing the render pass.
  51735. * @param camera The camera to apply the render pass to.
  51736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51737. * @param engine The engine which the post process will be applied. (default: current engine)
  51738. * @param reusable If the post process can be reused on the same frame. (default: false)
  51739. */
  51740. constructor(name: string,
  51741. /** The matrix to be applied to the image */
  51742. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51743. }
  51744. }
  51745. declare module BABYLON {
  51746. /** @hidden */
  51747. export var fxaaPixelShader: {
  51748. name: string;
  51749. shader: string;
  51750. };
  51751. }
  51752. declare module BABYLON {
  51753. /** @hidden */
  51754. export var fxaaVertexShader: {
  51755. name: string;
  51756. shader: string;
  51757. };
  51758. }
  51759. declare module BABYLON {
  51760. /**
  51761. * Fxaa post process
  51762. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  51763. */
  51764. export class FxaaPostProcess extends PostProcess {
  51765. /** @hidden */
  51766. texelWidth: number;
  51767. /** @hidden */
  51768. texelHeight: number;
  51769. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51770. private _getDefines;
  51771. }
  51772. }
  51773. declare module BABYLON {
  51774. /** @hidden */
  51775. export var grainPixelShader: {
  51776. name: string;
  51777. shader: string;
  51778. };
  51779. }
  51780. declare module BABYLON {
  51781. /**
  51782. * The GrainPostProcess adds noise to the image at mid luminance levels
  51783. */
  51784. export class GrainPostProcess extends PostProcess {
  51785. /**
  51786. * The intensity of the grain added (default: 30)
  51787. */
  51788. intensity: number;
  51789. /**
  51790. * If the grain should be randomized on every frame
  51791. */
  51792. animated: boolean;
  51793. /**
  51794. * Creates a new instance of @see GrainPostProcess
  51795. * @param name The name of the effect.
  51796. * @param options The required width/height ratio to downsize to before computing the render pass.
  51797. * @param camera The camera to apply the render pass to.
  51798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51799. * @param engine The engine which the post process will be applied. (default: current engine)
  51800. * @param reusable If the post process can be reused on the same frame. (default: false)
  51801. * @param textureType Type of textures used when performing the post process. (default: 0)
  51802. * @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)
  51803. */
  51804. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51805. }
  51806. }
  51807. declare module BABYLON {
  51808. /** @hidden */
  51809. export var highlightsPixelShader: {
  51810. name: string;
  51811. shader: string;
  51812. };
  51813. }
  51814. declare module BABYLON {
  51815. /**
  51816. * Extracts highlights from the image
  51817. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51818. */
  51819. export class HighlightsPostProcess extends PostProcess {
  51820. /**
  51821. * Extracts highlights from the image
  51822. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51823. * @param name The name of the effect.
  51824. * @param options The required width/height ratio to downsize to before computing the render pass.
  51825. * @param camera The camera to apply the render pass to.
  51826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51827. * @param engine The engine which the post process will be applied. (default: current engine)
  51828. * @param reusable If the post process can be reused on the same frame. (default: false)
  51829. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  51830. */
  51831. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51832. }
  51833. }
  51834. declare module BABYLON {
  51835. /** @hidden */
  51836. export var mrtFragmentDeclaration: {
  51837. name: string;
  51838. shader: string;
  51839. };
  51840. }
  51841. declare module BABYLON {
  51842. /** @hidden */
  51843. export var geometryPixelShader: {
  51844. name: string;
  51845. shader: string;
  51846. };
  51847. }
  51848. declare module BABYLON {
  51849. /** @hidden */
  51850. export var geometryVertexShader: {
  51851. name: string;
  51852. shader: string;
  51853. };
  51854. }
  51855. declare module BABYLON {
  51856. /**
  51857. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  51858. */
  51859. export class GeometryBufferRenderer {
  51860. /**
  51861. * Constant used to retrieve the position texture index in the G-Buffer textures array
  51862. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  51863. */
  51864. static readonly POSITION_TEXTURE_TYPE: number;
  51865. /**
  51866. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  51867. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  51868. */
  51869. static readonly VELOCITY_TEXTURE_TYPE: number;
  51870. /**
  51871. * Dictionary used to store the previous transformation matrices of each rendered mesh
  51872. * in order to compute objects velocities when enableVelocity is set to "true"
  51873. * @hidden
  51874. */ previousTransformationMatrices: {
  51875. [index: number]: Matrix;
  51876. };
  51877. private _scene;
  51878. private _multiRenderTarget;
  51879. private _ratio;
  51880. private _enablePosition;
  51881. private _enableVelocity;
  51882. private _positionIndex;
  51883. private _velocityIndex;
  51884. protected _effect: Effect;
  51885. protected _cachedDefines: string;
  51886. /**
  51887. * Set the render list (meshes to be rendered) used in the G buffer.
  51888. */
  51889. renderList: Mesh[];
  51890. /**
  51891. * Gets wether or not G buffer are supported by the running hardware.
  51892. * This requires draw buffer supports
  51893. */
  51894. readonly isSupported: boolean;
  51895. /**
  51896. * Returns the index of the given texture type in the G-Buffer textures array
  51897. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  51898. * @returns the index of the given texture type in the G-Buffer textures array
  51899. */
  51900. getTextureIndex(textureType: number): number;
  51901. /**
  51902. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  51903. */
  51904. /**
  51905. * Sets whether or not objects positions are enabled for the G buffer.
  51906. */
  51907. enablePosition: boolean;
  51908. /**
  51909. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  51910. */
  51911. /**
  51912. * Sets wether or not objects velocities are enabled for the G buffer.
  51913. */
  51914. enableVelocity: boolean;
  51915. /**
  51916. * Gets the scene associated with the buffer.
  51917. */
  51918. readonly scene: Scene;
  51919. /**
  51920. * Gets the ratio used by the buffer during its creation.
  51921. * How big is the buffer related to the main canvas.
  51922. */
  51923. readonly ratio: number;
  51924. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  51925. /**
  51926. * Creates a new G Buffer for the scene
  51927. * @param scene The scene the buffer belongs to
  51928. * @param ratio How big is the buffer related to the main canvas.
  51929. */
  51930. constructor(scene: Scene, ratio?: number);
  51931. /**
  51932. * Checks wether everything is ready to render a submesh to the G buffer.
  51933. * @param subMesh the submesh to check readiness for
  51934. * @param useInstances is the mesh drawn using instance or not
  51935. * @returns true if ready otherwise false
  51936. */
  51937. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51938. /**
  51939. * Gets the current underlying G Buffer.
  51940. * @returns the buffer
  51941. */
  51942. getGBuffer(): MultiRenderTarget;
  51943. /**
  51944. * Gets the number of samples used to render the buffer (anti aliasing).
  51945. */
  51946. /**
  51947. * Sets the number of samples used to render the buffer (anti aliasing).
  51948. */
  51949. samples: number;
  51950. /**
  51951. * Disposes the renderer and frees up associated resources.
  51952. */
  51953. dispose(): void;
  51954. protected _createRenderTargets(): void;
  51955. }
  51956. }
  51957. declare module BABYLON {
  51958. interface Scene {
  51959. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51960. /**
  51961. * Gets or Sets the current geometry buffer associated to the scene.
  51962. */
  51963. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51964. /**
  51965. * Enables a GeometryBufferRender and associates it with the scene
  51966. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  51967. * @returns the GeometryBufferRenderer
  51968. */
  51969. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  51970. /**
  51971. * Disables the GeometryBufferRender associated with the scene
  51972. */
  51973. disableGeometryBufferRenderer(): void;
  51974. }
  51975. /**
  51976. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  51977. * in several rendering techniques.
  51978. */
  51979. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  51980. /**
  51981. * The component name helpful to identify the component in the list of scene components.
  51982. */
  51983. readonly name: string;
  51984. /**
  51985. * The scene the component belongs to.
  51986. */
  51987. scene: Scene;
  51988. /**
  51989. * Creates a new instance of the component for the given scene
  51990. * @param scene Defines the scene to register the component in
  51991. */
  51992. constructor(scene: Scene);
  51993. /**
  51994. * Registers the component in a given scene
  51995. */
  51996. register(): void;
  51997. /**
  51998. * Rebuilds the elements related to this component in case of
  51999. * context lost for instance.
  52000. */
  52001. rebuild(): void;
  52002. /**
  52003. * Disposes the component and the associated ressources
  52004. */
  52005. dispose(): void;
  52006. private _gatherRenderTargets;
  52007. }
  52008. }
  52009. declare module BABYLON {
  52010. /** @hidden */
  52011. export var motionBlurPixelShader: {
  52012. name: string;
  52013. shader: string;
  52014. };
  52015. }
  52016. declare module BABYLON {
  52017. /**
  52018. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52019. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52020. * As an example, all you have to do is to create the post-process:
  52021. * var mb = new BABYLON.MotionBlurPostProcess(
  52022. * 'mb', // The name of the effect.
  52023. * scene, // The scene containing the objects to blur according to their velocity.
  52024. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52025. * camera // The camera to apply the render pass to.
  52026. * );
  52027. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52028. */
  52029. export class MotionBlurPostProcess extends PostProcess {
  52030. /**
  52031. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52032. */
  52033. motionStrength: number;
  52034. /**
  52035. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52036. */
  52037. /**
  52038. * Sets the number of iterations to be used for motion blur quality
  52039. */
  52040. motionBlurSamples: number;
  52041. private _motionBlurSamples;
  52042. private _geometryBufferRenderer;
  52043. /**
  52044. * Creates a new instance MotionBlurPostProcess
  52045. * @param name The name of the effect.
  52046. * @param scene The scene containing the objects to blur according to their velocity.
  52047. * @param options The required width/height ratio to downsize to before computing the render pass.
  52048. * @param camera The camera to apply the render pass to.
  52049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52050. * @param engine The engine which the post process will be applied. (default: current engine)
  52051. * @param reusable If the post process can be reused on the same frame. (default: false)
  52052. * @param textureType Type of textures used when performing the post process. (default: 0)
  52053. * @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)
  52054. */
  52055. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52056. /**
  52057. * Disposes the post process.
  52058. * @param camera The camera to dispose the post process on.
  52059. */
  52060. dispose(camera?: Camera): void;
  52061. }
  52062. }
  52063. declare module BABYLON {
  52064. /** @hidden */
  52065. export var refractionPixelShader: {
  52066. name: string;
  52067. shader: string;
  52068. };
  52069. }
  52070. declare module BABYLON {
  52071. /**
  52072. * Post process which applies a refractin texture
  52073. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52074. */
  52075. export class RefractionPostProcess extends PostProcess {
  52076. /** the base color of the refraction (used to taint the rendering) */
  52077. color: Color3;
  52078. /** simulated refraction depth */
  52079. depth: number;
  52080. /** the coefficient of the base color (0 to remove base color tainting) */
  52081. colorLevel: number;
  52082. private _refTexture;
  52083. private _ownRefractionTexture;
  52084. /**
  52085. * Gets or sets the refraction texture
  52086. * Please note that you are responsible for disposing the texture if you set it manually
  52087. */
  52088. refractionTexture: Texture;
  52089. /**
  52090. * Initializes the RefractionPostProcess
  52091. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52092. * @param name The name of the effect.
  52093. * @param refractionTextureUrl Url of the refraction texture to use
  52094. * @param color the base color of the refraction (used to taint the rendering)
  52095. * @param depth simulated refraction depth
  52096. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52097. * @param camera The camera to apply the render pass to.
  52098. * @param options The required width/height ratio to downsize to before computing the render pass.
  52099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52100. * @param engine The engine which the post process will be applied. (default: current engine)
  52101. * @param reusable If the post process can be reused on the same frame. (default: false)
  52102. */
  52103. constructor(name: string, refractionTextureUrl: string,
  52104. /** the base color of the refraction (used to taint the rendering) */
  52105. color: Color3,
  52106. /** simulated refraction depth */
  52107. depth: number,
  52108. /** the coefficient of the base color (0 to remove base color tainting) */
  52109. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52110. /**
  52111. * Disposes of the post process
  52112. * @param camera Camera to dispose post process on
  52113. */
  52114. dispose(camera: Camera): void;
  52115. }
  52116. }
  52117. declare module BABYLON {
  52118. /** @hidden */
  52119. export var sharpenPixelShader: {
  52120. name: string;
  52121. shader: string;
  52122. };
  52123. }
  52124. declare module BABYLON {
  52125. /**
  52126. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52127. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52128. */
  52129. export class SharpenPostProcess extends PostProcess {
  52130. /**
  52131. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52132. */
  52133. colorAmount: number;
  52134. /**
  52135. * How much sharpness should be applied (default: 0.3)
  52136. */
  52137. edgeAmount: number;
  52138. /**
  52139. * Creates a new instance ConvolutionPostProcess
  52140. * @param name The name of the effect.
  52141. * @param options The required width/height ratio to downsize to before computing the render pass.
  52142. * @param camera The camera to apply the render pass to.
  52143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52144. * @param engine The engine which the post process will be applied. (default: current engine)
  52145. * @param reusable If the post process can be reused on the same frame. (default: false)
  52146. * @param textureType Type of textures used when performing the post process. (default: 0)
  52147. * @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)
  52148. */
  52149. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52150. }
  52151. }
  52152. declare module BABYLON {
  52153. /**
  52154. * PostProcessRenderPipeline
  52155. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52156. */
  52157. export class PostProcessRenderPipeline {
  52158. private engine;
  52159. private _renderEffects;
  52160. private _renderEffectsForIsolatedPass;
  52161. /**
  52162. * List of inspectable custom properties (used by the Inspector)
  52163. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52164. */
  52165. inspectableCustomProperties: IInspectable[];
  52166. /**
  52167. * @hidden
  52168. */
  52169. protected _cameras: Camera[];
  52170. /** @hidden */ name: string;
  52171. /**
  52172. * Gets pipeline name
  52173. */
  52174. readonly name: string;
  52175. /**
  52176. * Initializes a PostProcessRenderPipeline
  52177. * @param engine engine to add the pipeline to
  52178. * @param name name of the pipeline
  52179. */
  52180. constructor(engine: Engine, name: string);
  52181. /**
  52182. * Gets the class name
  52183. * @returns "PostProcessRenderPipeline"
  52184. */
  52185. getClassName(): string;
  52186. /**
  52187. * If all the render effects in the pipeline are supported
  52188. */
  52189. readonly isSupported: boolean;
  52190. /**
  52191. * Adds an effect to the pipeline
  52192. * @param renderEffect the effect to add
  52193. */
  52194. addEffect(renderEffect: PostProcessRenderEffect): void;
  52195. /** @hidden */ rebuild(): void;
  52196. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  52197. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52198. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52199. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52200. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  52201. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  52202. /** @hidden */ detachCameras(cameras: Camera): void;
  52203. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  52204. /** @hidden */ update(): void;
  52205. /** @hidden */ reset(): void;
  52206. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52207. /**
  52208. * Disposes of the pipeline
  52209. */
  52210. dispose(): void;
  52211. }
  52212. }
  52213. declare module BABYLON {
  52214. /**
  52215. * PostProcessRenderPipelineManager class
  52216. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52217. */
  52218. export class PostProcessRenderPipelineManager {
  52219. private _renderPipelines;
  52220. /**
  52221. * Initializes a PostProcessRenderPipelineManager
  52222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52223. */
  52224. constructor();
  52225. /**
  52226. * Gets the list of supported render pipelines
  52227. */
  52228. readonly supportedPipelines: PostProcessRenderPipeline[];
  52229. /**
  52230. * Adds a pipeline to the manager
  52231. * @param renderPipeline The pipeline to add
  52232. */
  52233. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52234. /**
  52235. * Attaches a camera to the pipeline
  52236. * @param renderPipelineName The name of the pipeline to attach to
  52237. * @param cameras the camera to attach
  52238. * @param unique if the camera can be attached multiple times to the pipeline
  52239. */
  52240. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52241. /**
  52242. * Detaches a camera from the pipeline
  52243. * @param renderPipelineName The name of the pipeline to detach from
  52244. * @param cameras the camera to detach
  52245. */
  52246. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52247. /**
  52248. * Enables an effect by name on a pipeline
  52249. * @param renderPipelineName the name of the pipeline to enable the effect in
  52250. * @param renderEffectName the name of the effect to enable
  52251. * @param cameras the cameras that the effect should be enabled on
  52252. */
  52253. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52254. /**
  52255. * Disables an effect by name on a pipeline
  52256. * @param renderPipelineName the name of the pipeline to disable the effect in
  52257. * @param renderEffectName the name of the effect to disable
  52258. * @param cameras the cameras that the effect should be disabled on
  52259. */
  52260. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52261. /**
  52262. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52263. */
  52264. update(): void;
  52265. /** @hidden */ rebuild(): void;
  52266. /**
  52267. * Disposes of the manager and pipelines
  52268. */
  52269. dispose(): void;
  52270. }
  52271. }
  52272. declare module BABYLON {
  52273. interface Scene {
  52274. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52275. /**
  52276. * Gets the postprocess render pipeline manager
  52277. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52278. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52279. */
  52280. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52281. }
  52282. /**
  52283. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52284. */
  52285. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52286. /**
  52287. * The component name helpfull to identify the component in the list of scene components.
  52288. */
  52289. readonly name: string;
  52290. /**
  52291. * The scene the component belongs to.
  52292. */
  52293. scene: Scene;
  52294. /**
  52295. * Creates a new instance of the component for the given scene
  52296. * @param scene Defines the scene to register the component in
  52297. */
  52298. constructor(scene: Scene);
  52299. /**
  52300. * Registers the component in a given scene
  52301. */
  52302. register(): void;
  52303. /**
  52304. * Rebuilds the elements related to this component in case of
  52305. * context lost for instance.
  52306. */
  52307. rebuild(): void;
  52308. /**
  52309. * Disposes the component and the associated ressources
  52310. */
  52311. dispose(): void;
  52312. private _gatherRenderTargets;
  52313. }
  52314. }
  52315. declare module BABYLON {
  52316. /**
  52317. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52318. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52319. */
  52320. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52321. private _scene;
  52322. private _camerasToBeAttached;
  52323. /**
  52324. * ID of the sharpen post process,
  52325. */
  52326. private readonly SharpenPostProcessId;
  52327. /**
  52328. * @ignore
  52329. * ID of the image processing post process;
  52330. */
  52331. readonly ImageProcessingPostProcessId: string;
  52332. /**
  52333. * @ignore
  52334. * ID of the Fast Approximate Anti-Aliasing post process;
  52335. */
  52336. readonly FxaaPostProcessId: string;
  52337. /**
  52338. * ID of the chromatic aberration post process,
  52339. */
  52340. private readonly ChromaticAberrationPostProcessId;
  52341. /**
  52342. * ID of the grain post process
  52343. */
  52344. private readonly GrainPostProcessId;
  52345. /**
  52346. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52347. */
  52348. sharpen: SharpenPostProcess;
  52349. private _sharpenEffect;
  52350. private bloom;
  52351. /**
  52352. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52353. */
  52354. depthOfField: DepthOfFieldEffect;
  52355. /**
  52356. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52357. */
  52358. fxaa: FxaaPostProcess;
  52359. /**
  52360. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52361. */
  52362. imageProcessing: ImageProcessingPostProcess;
  52363. /**
  52364. * Chromatic aberration post process which will shift rgb colors in the image
  52365. */
  52366. chromaticAberration: ChromaticAberrationPostProcess;
  52367. private _chromaticAberrationEffect;
  52368. /**
  52369. * Grain post process which add noise to the image
  52370. */
  52371. grain: GrainPostProcess;
  52372. private _grainEffect;
  52373. /**
  52374. * Glow post process which adds a glow to emissive areas of the image
  52375. */
  52376. private _glowLayer;
  52377. /**
  52378. * Animations which can be used to tweak settings over a period of time
  52379. */
  52380. animations: Animation[];
  52381. private _imageProcessingConfigurationObserver;
  52382. private _sharpenEnabled;
  52383. private _bloomEnabled;
  52384. private _depthOfFieldEnabled;
  52385. private _depthOfFieldBlurLevel;
  52386. private _fxaaEnabled;
  52387. private _imageProcessingEnabled;
  52388. private _defaultPipelineTextureType;
  52389. private _bloomScale;
  52390. private _chromaticAberrationEnabled;
  52391. private _grainEnabled;
  52392. private _buildAllowed;
  52393. /**
  52394. * Gets active scene
  52395. */
  52396. readonly scene: Scene;
  52397. /**
  52398. * Enable or disable the sharpen process from the pipeline
  52399. */
  52400. sharpenEnabled: boolean;
  52401. private _resizeObserver;
  52402. private _hardwareScaleLevel;
  52403. private _bloomKernel;
  52404. /**
  52405. * Specifies the size of the bloom blur kernel, relative to the final output size
  52406. */
  52407. bloomKernel: number;
  52408. /**
  52409. * Specifies the weight of the bloom in the final rendering
  52410. */
  52411. private _bloomWeight;
  52412. /**
  52413. * Specifies the luma threshold for the area that will be blurred by the bloom
  52414. */
  52415. private _bloomThreshold;
  52416. private _hdr;
  52417. /**
  52418. * The strength of the bloom.
  52419. */
  52420. bloomWeight: number;
  52421. /**
  52422. * The strength of the bloom.
  52423. */
  52424. bloomThreshold: number;
  52425. /**
  52426. * The scale of the bloom, lower value will provide better performance.
  52427. */
  52428. bloomScale: number;
  52429. /**
  52430. * Enable or disable the bloom from the pipeline
  52431. */
  52432. bloomEnabled: boolean;
  52433. private _rebuildBloom;
  52434. /**
  52435. * If the depth of field is enabled.
  52436. */
  52437. depthOfFieldEnabled: boolean;
  52438. /**
  52439. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52440. */
  52441. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52442. /**
  52443. * If the anti aliasing is enabled.
  52444. */
  52445. fxaaEnabled: boolean;
  52446. private _samples;
  52447. /**
  52448. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52449. */
  52450. samples: number;
  52451. /**
  52452. * If image processing is enabled.
  52453. */
  52454. imageProcessingEnabled: boolean;
  52455. /**
  52456. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52457. */
  52458. glowLayerEnabled: boolean;
  52459. /**
  52460. * Enable or disable the chromaticAberration process from the pipeline
  52461. */
  52462. chromaticAberrationEnabled: boolean;
  52463. /**
  52464. * Enable or disable the grain process from the pipeline
  52465. */
  52466. grainEnabled: boolean;
  52467. /**
  52468. * @constructor
  52469. * @param name - The rendering pipeline name (default: "")
  52470. * @param hdr - If high dynamic range textures should be used (default: true)
  52471. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52472. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52473. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52474. */
  52475. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52476. /**
  52477. * Get the class name
  52478. * @returns "DefaultRenderingPipeline"
  52479. */
  52480. getClassName(): string;
  52481. /**
  52482. * Force the compilation of the entire pipeline.
  52483. */
  52484. prepare(): void;
  52485. private _hasCleared;
  52486. private _prevPostProcess;
  52487. private _prevPrevPostProcess;
  52488. private _setAutoClearAndTextureSharing;
  52489. private _depthOfFieldSceneObserver;
  52490. private _buildPipeline;
  52491. private _disposePostProcesses;
  52492. /**
  52493. * Adds a camera to the pipeline
  52494. * @param camera the camera to be added
  52495. */
  52496. addCamera(camera: Camera): void;
  52497. /**
  52498. * Removes a camera from the pipeline
  52499. * @param camera the camera to remove
  52500. */
  52501. removeCamera(camera: Camera): void;
  52502. /**
  52503. * Dispose of the pipeline and stop all post processes
  52504. */
  52505. dispose(): void;
  52506. /**
  52507. * Serialize the rendering pipeline (Used when exporting)
  52508. * @returns the serialized object
  52509. */
  52510. serialize(): any;
  52511. /**
  52512. * Parse the serialized pipeline
  52513. * @param source Source pipeline.
  52514. * @param scene The scene to load the pipeline to.
  52515. * @param rootUrl The URL of the serialized pipeline.
  52516. * @returns An instantiated pipeline from the serialized object.
  52517. */
  52518. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52519. }
  52520. }
  52521. declare module BABYLON {
  52522. /** @hidden */
  52523. export var lensHighlightsPixelShader: {
  52524. name: string;
  52525. shader: string;
  52526. };
  52527. }
  52528. declare module BABYLON {
  52529. /** @hidden */
  52530. export var depthOfFieldPixelShader: {
  52531. name: string;
  52532. shader: string;
  52533. };
  52534. }
  52535. declare module BABYLON {
  52536. /**
  52537. * BABYLON.JS Chromatic Aberration GLSL Shader
  52538. * Author: Olivier Guyot
  52539. * Separates very slightly R, G and B colors on the edges of the screen
  52540. * Inspired by Francois Tarlier & Martins Upitis
  52541. */
  52542. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52543. /**
  52544. * @ignore
  52545. * The chromatic aberration PostProcess id in the pipeline
  52546. */
  52547. LensChromaticAberrationEffect: string;
  52548. /**
  52549. * @ignore
  52550. * The highlights enhancing PostProcess id in the pipeline
  52551. */
  52552. HighlightsEnhancingEffect: string;
  52553. /**
  52554. * @ignore
  52555. * The depth-of-field PostProcess id in the pipeline
  52556. */
  52557. LensDepthOfFieldEffect: string;
  52558. private _scene;
  52559. private _depthTexture;
  52560. private _grainTexture;
  52561. private _chromaticAberrationPostProcess;
  52562. private _highlightsPostProcess;
  52563. private _depthOfFieldPostProcess;
  52564. private _edgeBlur;
  52565. private _grainAmount;
  52566. private _chromaticAberration;
  52567. private _distortion;
  52568. private _highlightsGain;
  52569. private _highlightsThreshold;
  52570. private _dofDistance;
  52571. private _dofAperture;
  52572. private _dofDarken;
  52573. private _dofPentagon;
  52574. private _blurNoise;
  52575. /**
  52576. * @constructor
  52577. *
  52578. * Effect parameters are as follow:
  52579. * {
  52580. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52581. * edge_blur: number; // from 0 to x (1 for realism)
  52582. * distortion: number; // from 0 to x (1 for realism)
  52583. * grain_amount: number; // from 0 to 1
  52584. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52585. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52586. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52587. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52588. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52589. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52590. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52591. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52592. * }
  52593. * Note: if an effect parameter is unset, effect is disabled
  52594. *
  52595. * @param name The rendering pipeline name
  52596. * @param parameters - An object containing all parameters (see above)
  52597. * @param scene The scene linked to this pipeline
  52598. * @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)
  52599. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52600. */
  52601. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52602. /**
  52603. * Get the class name
  52604. * @returns "LensRenderingPipeline"
  52605. */
  52606. getClassName(): string;
  52607. /**
  52608. * Gets associated scene
  52609. */
  52610. readonly scene: Scene;
  52611. /**
  52612. * Gets or sets the edge blur
  52613. */
  52614. edgeBlur: number;
  52615. /**
  52616. * Gets or sets the grain amount
  52617. */
  52618. grainAmount: number;
  52619. /**
  52620. * Gets or sets the chromatic aberration amount
  52621. */
  52622. chromaticAberration: number;
  52623. /**
  52624. * Gets or sets the depth of field aperture
  52625. */
  52626. dofAperture: number;
  52627. /**
  52628. * Gets or sets the edge distortion
  52629. */
  52630. edgeDistortion: number;
  52631. /**
  52632. * Gets or sets the depth of field distortion
  52633. */
  52634. dofDistortion: number;
  52635. /**
  52636. * Gets or sets the darken out of focus amount
  52637. */
  52638. darkenOutOfFocus: number;
  52639. /**
  52640. * Gets or sets a boolean indicating if blur noise is enabled
  52641. */
  52642. blurNoise: boolean;
  52643. /**
  52644. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  52645. */
  52646. pentagonBokeh: boolean;
  52647. /**
  52648. * Gets or sets the highlight grain amount
  52649. */
  52650. highlightsGain: number;
  52651. /**
  52652. * Gets or sets the highlight threshold
  52653. */
  52654. highlightsThreshold: number;
  52655. /**
  52656. * Sets the amount of blur at the edges
  52657. * @param amount blur amount
  52658. */
  52659. setEdgeBlur(amount: number): void;
  52660. /**
  52661. * Sets edge blur to 0
  52662. */
  52663. disableEdgeBlur(): void;
  52664. /**
  52665. * Sets the amout of grain
  52666. * @param amount Amount of grain
  52667. */
  52668. setGrainAmount(amount: number): void;
  52669. /**
  52670. * Set grain amount to 0
  52671. */
  52672. disableGrain(): void;
  52673. /**
  52674. * Sets the chromatic aberration amount
  52675. * @param amount amount of chromatic aberration
  52676. */
  52677. setChromaticAberration(amount: number): void;
  52678. /**
  52679. * Sets chromatic aberration amount to 0
  52680. */
  52681. disableChromaticAberration(): void;
  52682. /**
  52683. * Sets the EdgeDistortion amount
  52684. * @param amount amount of EdgeDistortion
  52685. */
  52686. setEdgeDistortion(amount: number): void;
  52687. /**
  52688. * Sets edge distortion to 0
  52689. */
  52690. disableEdgeDistortion(): void;
  52691. /**
  52692. * Sets the FocusDistance amount
  52693. * @param amount amount of FocusDistance
  52694. */
  52695. setFocusDistance(amount: number): void;
  52696. /**
  52697. * Disables depth of field
  52698. */
  52699. disableDepthOfField(): void;
  52700. /**
  52701. * Sets the Aperture amount
  52702. * @param amount amount of Aperture
  52703. */
  52704. setAperture(amount: number): void;
  52705. /**
  52706. * Sets the DarkenOutOfFocus amount
  52707. * @param amount amount of DarkenOutOfFocus
  52708. */
  52709. setDarkenOutOfFocus(amount: number): void;
  52710. private _pentagonBokehIsEnabled;
  52711. /**
  52712. * Creates a pentagon bokeh effect
  52713. */
  52714. enablePentagonBokeh(): void;
  52715. /**
  52716. * Disables the pentagon bokeh effect
  52717. */
  52718. disablePentagonBokeh(): void;
  52719. /**
  52720. * Enables noise blur
  52721. */
  52722. enableNoiseBlur(): void;
  52723. /**
  52724. * Disables noise blur
  52725. */
  52726. disableNoiseBlur(): void;
  52727. /**
  52728. * Sets the HighlightsGain amount
  52729. * @param amount amount of HighlightsGain
  52730. */
  52731. setHighlightsGain(amount: number): void;
  52732. /**
  52733. * Sets the HighlightsThreshold amount
  52734. * @param amount amount of HighlightsThreshold
  52735. */
  52736. setHighlightsThreshold(amount: number): void;
  52737. /**
  52738. * Disables highlights
  52739. */
  52740. disableHighlights(): void;
  52741. /**
  52742. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52743. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52744. */
  52745. dispose(disableDepthRender?: boolean): void;
  52746. private _createChromaticAberrationPostProcess;
  52747. private _createHighlightsPostProcess;
  52748. private _createDepthOfFieldPostProcess;
  52749. private _createGrainTexture;
  52750. }
  52751. }
  52752. declare module BABYLON {
  52753. /** @hidden */
  52754. export var ssao2PixelShader: {
  52755. name: string;
  52756. shader: string;
  52757. };
  52758. }
  52759. declare module BABYLON {
  52760. /** @hidden */
  52761. export var ssaoCombinePixelShader: {
  52762. name: string;
  52763. shader: string;
  52764. };
  52765. }
  52766. declare module BABYLON {
  52767. /**
  52768. * Render pipeline to produce ssao effect
  52769. */
  52770. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  52771. /**
  52772. * @ignore
  52773. * The PassPostProcess id in the pipeline that contains the original scene color
  52774. */
  52775. SSAOOriginalSceneColorEffect: string;
  52776. /**
  52777. * @ignore
  52778. * The SSAO PostProcess id in the pipeline
  52779. */
  52780. SSAORenderEffect: string;
  52781. /**
  52782. * @ignore
  52783. * The horizontal blur PostProcess id in the pipeline
  52784. */
  52785. SSAOBlurHRenderEffect: string;
  52786. /**
  52787. * @ignore
  52788. * The vertical blur PostProcess id in the pipeline
  52789. */
  52790. SSAOBlurVRenderEffect: string;
  52791. /**
  52792. * @ignore
  52793. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52794. */
  52795. SSAOCombineRenderEffect: string;
  52796. /**
  52797. * The output strength of the SSAO post-process. Default value is 1.0.
  52798. */
  52799. totalStrength: number;
  52800. /**
  52801. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  52802. */
  52803. maxZ: number;
  52804. /**
  52805. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  52806. */
  52807. minZAspect: number;
  52808. private _samples;
  52809. /**
  52810. * Number of samples used for the SSAO calculations. Default value is 8
  52811. */
  52812. samples: number;
  52813. private _textureSamples;
  52814. /**
  52815. * Number of samples to use for antialiasing
  52816. */
  52817. textureSamples: number;
  52818. /**
  52819. * Ratio object used for SSAO ratio and blur ratio
  52820. */
  52821. private _ratio;
  52822. /**
  52823. * Dynamically generated sphere sampler.
  52824. */
  52825. private _sampleSphere;
  52826. /**
  52827. * Blur filter offsets
  52828. */
  52829. private _samplerOffsets;
  52830. private _expensiveBlur;
  52831. /**
  52832. * If bilateral blur should be used
  52833. */
  52834. expensiveBlur: boolean;
  52835. /**
  52836. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  52837. */
  52838. radius: number;
  52839. /**
  52840. * The base color of the SSAO post-process
  52841. * The final result is "base + ssao" between [0, 1]
  52842. */
  52843. base: number;
  52844. /**
  52845. * Support test.
  52846. */
  52847. static readonly IsSupported: boolean;
  52848. private _scene;
  52849. private _depthTexture;
  52850. private _normalTexture;
  52851. private _randomTexture;
  52852. private _originalColorPostProcess;
  52853. private _ssaoPostProcess;
  52854. private _blurHPostProcess;
  52855. private _blurVPostProcess;
  52856. private _ssaoCombinePostProcess;
  52857. private _firstUpdate;
  52858. /**
  52859. * Gets active scene
  52860. */
  52861. readonly scene: Scene;
  52862. /**
  52863. * @constructor
  52864. * @param name The rendering pipeline name
  52865. * @param scene The scene linked to this pipeline
  52866. * @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 }
  52867. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52868. */
  52869. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52870. /**
  52871. * Get the class name
  52872. * @returns "SSAO2RenderingPipeline"
  52873. */
  52874. getClassName(): string;
  52875. /**
  52876. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52877. */
  52878. dispose(disableGeometryBufferRenderer?: boolean): void;
  52879. private _createBlurPostProcess;
  52880. /** @hidden */ rebuild(): void;
  52881. private _bits;
  52882. private _radicalInverse_VdC;
  52883. private _hammersley;
  52884. private _hemisphereSample_uniform;
  52885. private _generateHemisphere;
  52886. private _createSSAOPostProcess;
  52887. private _createSSAOCombinePostProcess;
  52888. private _createRandomTexture;
  52889. /**
  52890. * Serialize the rendering pipeline (Used when exporting)
  52891. * @returns the serialized object
  52892. */
  52893. serialize(): any;
  52894. /**
  52895. * Parse the serialized pipeline
  52896. * @param source Source pipeline.
  52897. * @param scene The scene to load the pipeline to.
  52898. * @param rootUrl The URL of the serialized pipeline.
  52899. * @returns An instantiated pipeline from the serialized object.
  52900. */
  52901. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  52902. }
  52903. }
  52904. declare module BABYLON {
  52905. /** @hidden */
  52906. export var ssaoPixelShader: {
  52907. name: string;
  52908. shader: string;
  52909. };
  52910. }
  52911. declare module BABYLON {
  52912. /**
  52913. * Render pipeline to produce ssao effect
  52914. */
  52915. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  52916. /**
  52917. * @ignore
  52918. * The PassPostProcess id in the pipeline that contains the original scene color
  52919. */
  52920. SSAOOriginalSceneColorEffect: string;
  52921. /**
  52922. * @ignore
  52923. * The SSAO PostProcess id in the pipeline
  52924. */
  52925. SSAORenderEffect: string;
  52926. /**
  52927. * @ignore
  52928. * The horizontal blur PostProcess id in the pipeline
  52929. */
  52930. SSAOBlurHRenderEffect: string;
  52931. /**
  52932. * @ignore
  52933. * The vertical blur PostProcess id in the pipeline
  52934. */
  52935. SSAOBlurVRenderEffect: string;
  52936. /**
  52937. * @ignore
  52938. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52939. */
  52940. SSAOCombineRenderEffect: string;
  52941. /**
  52942. * The output strength of the SSAO post-process. Default value is 1.0.
  52943. */
  52944. totalStrength: number;
  52945. /**
  52946. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  52947. */
  52948. radius: number;
  52949. /**
  52950. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  52951. * Must not be equal to fallOff and superior to fallOff.
  52952. * Default value is 0.0075
  52953. */
  52954. area: number;
  52955. /**
  52956. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  52957. * Must not be equal to area and inferior to area.
  52958. * Default value is 0.000001
  52959. */
  52960. fallOff: number;
  52961. /**
  52962. * The base color of the SSAO post-process
  52963. * The final result is "base + ssao" between [0, 1]
  52964. */
  52965. base: number;
  52966. private _scene;
  52967. private _depthTexture;
  52968. private _randomTexture;
  52969. private _originalColorPostProcess;
  52970. private _ssaoPostProcess;
  52971. private _blurHPostProcess;
  52972. private _blurVPostProcess;
  52973. private _ssaoCombinePostProcess;
  52974. private _firstUpdate;
  52975. /**
  52976. * Gets active scene
  52977. */
  52978. readonly scene: Scene;
  52979. /**
  52980. * @constructor
  52981. * @param name - The rendering pipeline name
  52982. * @param scene - The scene linked to this pipeline
  52983. * @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 }
  52984. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  52985. */
  52986. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52987. /**
  52988. * Get the class name
  52989. * @returns "SSAORenderingPipeline"
  52990. */
  52991. getClassName(): string;
  52992. /**
  52993. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52994. */
  52995. dispose(disableDepthRender?: boolean): void;
  52996. private _createBlurPostProcess;
  52997. /** @hidden */ rebuild(): void;
  52998. private _createSSAOPostProcess;
  52999. private _createSSAOCombinePostProcess;
  53000. private _createRandomTexture;
  53001. }
  53002. }
  53003. declare module BABYLON {
  53004. /** @hidden */
  53005. export var standardPixelShader: {
  53006. name: string;
  53007. shader: string;
  53008. };
  53009. }
  53010. declare module BABYLON {
  53011. /**
  53012. * Standard rendering pipeline
  53013. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53014. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53015. */
  53016. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53017. /**
  53018. * Public members
  53019. */
  53020. /**
  53021. * Post-process which contains the original scene color before the pipeline applies all the effects
  53022. */
  53023. originalPostProcess: Nullable<PostProcess>;
  53024. /**
  53025. * Post-process used to down scale an image x4
  53026. */
  53027. downSampleX4PostProcess: Nullable<PostProcess>;
  53028. /**
  53029. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53030. */
  53031. brightPassPostProcess: Nullable<PostProcess>;
  53032. /**
  53033. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53034. */
  53035. blurHPostProcesses: PostProcess[];
  53036. /**
  53037. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53038. */
  53039. blurVPostProcesses: PostProcess[];
  53040. /**
  53041. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53042. */
  53043. textureAdderPostProcess: Nullable<PostProcess>;
  53044. /**
  53045. * Post-process used to create volumetric lighting effect
  53046. */
  53047. volumetricLightPostProcess: Nullable<PostProcess>;
  53048. /**
  53049. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53050. */
  53051. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53052. /**
  53053. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53054. */
  53055. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53056. /**
  53057. * Post-process used to merge the volumetric light effect and the real scene color
  53058. */
  53059. volumetricLightMergePostProces: Nullable<PostProcess>;
  53060. /**
  53061. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53062. */
  53063. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53064. /**
  53065. * Base post-process used to calculate the average luminance of the final image for HDR
  53066. */
  53067. luminancePostProcess: Nullable<PostProcess>;
  53068. /**
  53069. * Post-processes used to create down sample post-processes in order to get
  53070. * the average luminance of the final image for HDR
  53071. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53072. */
  53073. luminanceDownSamplePostProcesses: PostProcess[];
  53074. /**
  53075. * Post-process used to create a HDR effect (light adaptation)
  53076. */
  53077. hdrPostProcess: Nullable<PostProcess>;
  53078. /**
  53079. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53080. */
  53081. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53082. /**
  53083. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53084. */
  53085. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53086. /**
  53087. * Post-process used to merge the final HDR post-process and the real scene color
  53088. */
  53089. hdrFinalPostProcess: Nullable<PostProcess>;
  53090. /**
  53091. * Post-process used to create a lens flare effect
  53092. */
  53093. lensFlarePostProcess: Nullable<PostProcess>;
  53094. /**
  53095. * Post-process that merges the result of the lens flare post-process and the real scene color
  53096. */
  53097. lensFlareComposePostProcess: Nullable<PostProcess>;
  53098. /**
  53099. * Post-process used to create a motion blur effect
  53100. */
  53101. motionBlurPostProcess: Nullable<PostProcess>;
  53102. /**
  53103. * Post-process used to create a depth of field effect
  53104. */
  53105. depthOfFieldPostProcess: Nullable<PostProcess>;
  53106. /**
  53107. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53108. */
  53109. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53110. /**
  53111. * Represents the brightness threshold in order to configure the illuminated surfaces
  53112. */
  53113. brightThreshold: number;
  53114. /**
  53115. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53116. */
  53117. blurWidth: number;
  53118. /**
  53119. * Sets if the blur for highlighted surfaces must be only horizontal
  53120. */
  53121. horizontalBlur: boolean;
  53122. /**
  53123. * Gets the overall exposure used by the pipeline
  53124. */
  53125. /**
  53126. * Sets the overall exposure used by the pipeline
  53127. */
  53128. exposure: number;
  53129. /**
  53130. * Texture used typically to simulate "dirty" on camera lens
  53131. */
  53132. lensTexture: Nullable<Texture>;
  53133. /**
  53134. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53135. */
  53136. volumetricLightCoefficient: number;
  53137. /**
  53138. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53139. */
  53140. volumetricLightPower: number;
  53141. /**
  53142. * Used the set the blur intensity to smooth the volumetric lights
  53143. */
  53144. volumetricLightBlurScale: number;
  53145. /**
  53146. * Light (spot or directional) used to generate the volumetric lights rays
  53147. * The source light must have a shadow generate so the pipeline can get its
  53148. * depth map
  53149. */
  53150. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53151. /**
  53152. * For eye adaptation, represents the minimum luminance the eye can see
  53153. */
  53154. hdrMinimumLuminance: number;
  53155. /**
  53156. * For eye adaptation, represents the decrease luminance speed
  53157. */
  53158. hdrDecreaseRate: number;
  53159. /**
  53160. * For eye adaptation, represents the increase luminance speed
  53161. */
  53162. hdrIncreaseRate: number;
  53163. /**
  53164. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53165. */
  53166. /**
  53167. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53168. */
  53169. hdrAutoExposure: boolean;
  53170. /**
  53171. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53172. */
  53173. lensColorTexture: Nullable<Texture>;
  53174. /**
  53175. * The overall strengh for the lens flare effect
  53176. */
  53177. lensFlareStrength: number;
  53178. /**
  53179. * Dispersion coefficient for lens flare ghosts
  53180. */
  53181. lensFlareGhostDispersal: number;
  53182. /**
  53183. * Main lens flare halo width
  53184. */
  53185. lensFlareHaloWidth: number;
  53186. /**
  53187. * Based on the lens distortion effect, defines how much the lens flare result
  53188. * is distorted
  53189. */
  53190. lensFlareDistortionStrength: number;
  53191. /**
  53192. * Lens star texture must be used to simulate rays on the flares and is available
  53193. * in the documentation
  53194. */
  53195. lensStarTexture: Nullable<Texture>;
  53196. /**
  53197. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53198. * flare effect by taking account of the dirt texture
  53199. */
  53200. lensFlareDirtTexture: Nullable<Texture>;
  53201. /**
  53202. * Represents the focal length for the depth of field effect
  53203. */
  53204. depthOfFieldDistance: number;
  53205. /**
  53206. * Represents the blur intensity for the blurred part of the depth of field effect
  53207. */
  53208. depthOfFieldBlurWidth: number;
  53209. /**
  53210. * For motion blur, defines how much the image is blurred by the movement
  53211. */
  53212. motionStrength: number;
  53213. /**
  53214. * List of animations for the pipeline (IAnimatable implementation)
  53215. */
  53216. animations: Animation[];
  53217. /**
  53218. * Private members
  53219. */
  53220. private _scene;
  53221. private _currentDepthOfFieldSource;
  53222. private _basePostProcess;
  53223. private _fixedExposure;
  53224. private _currentExposure;
  53225. private _hdrAutoExposure;
  53226. private _hdrCurrentLuminance;
  53227. private _floatTextureType;
  53228. private _ratio;
  53229. private _bloomEnabled;
  53230. private _depthOfFieldEnabled;
  53231. private _vlsEnabled;
  53232. private _lensFlareEnabled;
  53233. private _hdrEnabled;
  53234. private _motionBlurEnabled;
  53235. private _fxaaEnabled;
  53236. private _motionBlurSamples;
  53237. private _volumetricLightStepsCount;
  53238. private _samples;
  53239. /**
  53240. * @ignore
  53241. * Specifies if the bloom pipeline is enabled
  53242. */
  53243. BloomEnabled: boolean;
  53244. /**
  53245. * @ignore
  53246. * Specifies if the depth of field pipeline is enabed
  53247. */
  53248. DepthOfFieldEnabled: boolean;
  53249. /**
  53250. * @ignore
  53251. * Specifies if the lens flare pipeline is enabed
  53252. */
  53253. LensFlareEnabled: boolean;
  53254. /**
  53255. * @ignore
  53256. * Specifies if the HDR pipeline is enabled
  53257. */
  53258. HDREnabled: boolean;
  53259. /**
  53260. * @ignore
  53261. * Specifies if the volumetric lights scattering effect is enabled
  53262. */
  53263. VLSEnabled: boolean;
  53264. /**
  53265. * @ignore
  53266. * Specifies if the motion blur effect is enabled
  53267. */
  53268. MotionBlurEnabled: boolean;
  53269. /**
  53270. * Specifies if anti-aliasing is enabled
  53271. */
  53272. fxaaEnabled: boolean;
  53273. /**
  53274. * Specifies the number of steps used to calculate the volumetric lights
  53275. * Typically in interval [50, 200]
  53276. */
  53277. volumetricLightStepsCount: number;
  53278. /**
  53279. * Specifies the number of samples used for the motion blur effect
  53280. * Typically in interval [16, 64]
  53281. */
  53282. motionBlurSamples: number;
  53283. /**
  53284. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53285. */
  53286. samples: number;
  53287. /**
  53288. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53289. * @constructor
  53290. * @param name The rendering pipeline name
  53291. * @param scene The scene linked to this pipeline
  53292. * @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)
  53293. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53294. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53295. */
  53296. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53297. private _buildPipeline;
  53298. private _createDownSampleX4PostProcess;
  53299. private _createBrightPassPostProcess;
  53300. private _createBlurPostProcesses;
  53301. private _createTextureAdderPostProcess;
  53302. private _createVolumetricLightPostProcess;
  53303. private _createLuminancePostProcesses;
  53304. private _createHdrPostProcess;
  53305. private _createLensFlarePostProcess;
  53306. private _createDepthOfFieldPostProcess;
  53307. private _createMotionBlurPostProcess;
  53308. private _getDepthTexture;
  53309. private _disposePostProcesses;
  53310. /**
  53311. * Dispose of the pipeline and stop all post processes
  53312. */
  53313. dispose(): void;
  53314. /**
  53315. * Serialize the rendering pipeline (Used when exporting)
  53316. * @returns the serialized object
  53317. */
  53318. serialize(): any;
  53319. /**
  53320. * Parse the serialized pipeline
  53321. * @param source Source pipeline.
  53322. * @param scene The scene to load the pipeline to.
  53323. * @param rootUrl The URL of the serialized pipeline.
  53324. * @returns An instantiated pipeline from the serialized object.
  53325. */
  53326. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53327. /**
  53328. * Luminance steps
  53329. */
  53330. static LuminanceSteps: number;
  53331. }
  53332. }
  53333. declare module BABYLON {
  53334. /** @hidden */
  53335. export var tonemapPixelShader: {
  53336. name: string;
  53337. shader: string;
  53338. };
  53339. }
  53340. declare module BABYLON {
  53341. /** Defines operator used for tonemapping */
  53342. export enum TonemappingOperator {
  53343. /** Hable */
  53344. Hable = 0,
  53345. /** Reinhard */
  53346. Reinhard = 1,
  53347. /** HejiDawson */
  53348. HejiDawson = 2,
  53349. /** Photographic */
  53350. Photographic = 3
  53351. }
  53352. /**
  53353. * Defines a post process to apply tone mapping
  53354. */
  53355. export class TonemapPostProcess extends PostProcess {
  53356. private _operator;
  53357. /** Defines the required exposure adjustement */
  53358. exposureAdjustment: number;
  53359. /**
  53360. * Creates a new TonemapPostProcess
  53361. * @param name defines the name of the postprocess
  53362. * @param _operator defines the operator to use
  53363. * @param exposureAdjustment defines the required exposure adjustement
  53364. * @param camera defines the camera to use (can be null)
  53365. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53366. * @param engine defines the hosting engine (can be ignore if camera is set)
  53367. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53368. */
  53369. constructor(name: string, _operator: TonemappingOperator,
  53370. /** Defines the required exposure adjustement */
  53371. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53372. }
  53373. }
  53374. declare module BABYLON {
  53375. /** @hidden */
  53376. export var depthVertexShader: {
  53377. name: string;
  53378. shader: string;
  53379. };
  53380. }
  53381. declare module BABYLON {
  53382. /** @hidden */
  53383. export var volumetricLightScatteringPixelShader: {
  53384. name: string;
  53385. shader: string;
  53386. };
  53387. }
  53388. declare module BABYLON {
  53389. /** @hidden */
  53390. export var volumetricLightScatteringPassPixelShader: {
  53391. name: string;
  53392. shader: string;
  53393. };
  53394. }
  53395. declare module BABYLON {
  53396. /**
  53397. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53398. */
  53399. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53400. private _volumetricLightScatteringPass;
  53401. private _volumetricLightScatteringRTT;
  53402. private _viewPort;
  53403. private _screenCoordinates;
  53404. private _cachedDefines;
  53405. /**
  53406. * If not undefined, the mesh position is computed from the attached node position
  53407. */
  53408. attachedNode: {
  53409. position: Vector3;
  53410. };
  53411. /**
  53412. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53413. */
  53414. customMeshPosition: Vector3;
  53415. /**
  53416. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53417. */
  53418. useCustomMeshPosition: boolean;
  53419. /**
  53420. * If the post-process should inverse the light scattering direction
  53421. */
  53422. invert: boolean;
  53423. /**
  53424. * The internal mesh used by the post-process
  53425. */
  53426. mesh: Mesh;
  53427. /**
  53428. * @hidden
  53429. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53430. */
  53431. useDiffuseColor: boolean;
  53432. /**
  53433. * Array containing the excluded meshes not rendered in the internal pass
  53434. */
  53435. excludedMeshes: AbstractMesh[];
  53436. /**
  53437. * Controls the overall intensity of the post-process
  53438. */
  53439. exposure: number;
  53440. /**
  53441. * Dissipates each sample's contribution in range [0, 1]
  53442. */
  53443. decay: number;
  53444. /**
  53445. * Controls the overall intensity of each sample
  53446. */
  53447. weight: number;
  53448. /**
  53449. * Controls the density of each sample
  53450. */
  53451. density: number;
  53452. /**
  53453. * @constructor
  53454. * @param name The post-process name
  53455. * @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)
  53456. * @param camera The camera that the post-process will be attached to
  53457. * @param mesh The mesh used to create the light scattering
  53458. * @param samples The post-process quality, default 100
  53459. * @param samplingModeThe post-process filtering mode
  53460. * @param engine The babylon engine
  53461. * @param reusable If the post-process is reusable
  53462. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53463. */
  53464. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53465. /**
  53466. * Returns the string "VolumetricLightScatteringPostProcess"
  53467. * @returns "VolumetricLightScatteringPostProcess"
  53468. */
  53469. getClassName(): string;
  53470. private _isReady;
  53471. /**
  53472. * Sets the new light position for light scattering effect
  53473. * @param position The new custom light position
  53474. */
  53475. setCustomMeshPosition(position: Vector3): void;
  53476. /**
  53477. * Returns the light position for light scattering effect
  53478. * @return Vector3 The custom light position
  53479. */
  53480. getCustomMeshPosition(): Vector3;
  53481. /**
  53482. * Disposes the internal assets and detaches the post-process from the camera
  53483. */
  53484. dispose(camera: Camera): void;
  53485. /**
  53486. * Returns the render target texture used by the post-process
  53487. * @return the render target texture used by the post-process
  53488. */
  53489. getPass(): RenderTargetTexture;
  53490. private _meshExcluded;
  53491. private _createPass;
  53492. private _updateMeshScreenCoordinates;
  53493. /**
  53494. * Creates a default mesh for the Volumeric Light Scattering post-process
  53495. * @param name The mesh name
  53496. * @param scene The scene where to create the mesh
  53497. * @return the default mesh
  53498. */
  53499. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53500. }
  53501. }
  53502. declare module BABYLON {
  53503. interface Scene {
  53504. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  53505. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  53506. /**
  53507. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53508. */
  53509. forceShowBoundingBoxes: boolean;
  53510. /**
  53511. * Gets the bounding box renderer associated with the scene
  53512. * @returns a BoundingBoxRenderer
  53513. */
  53514. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53515. }
  53516. interface AbstractMesh {
  53517. /** @hidden (Backing field) */ showBoundingBox: boolean;
  53518. /**
  53519. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53520. */
  53521. showBoundingBox: boolean;
  53522. }
  53523. /**
  53524. * Component responsible of rendering the bounding box of the meshes in a scene.
  53525. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53526. */
  53527. export class BoundingBoxRenderer implements ISceneComponent {
  53528. /**
  53529. * The component name helpfull to identify the component in the list of scene components.
  53530. */
  53531. readonly name: string;
  53532. /**
  53533. * The scene the component belongs to.
  53534. */
  53535. scene: Scene;
  53536. /**
  53537. * Color of the bounding box lines placed in front of an object
  53538. */
  53539. frontColor: Color3;
  53540. /**
  53541. * Color of the bounding box lines placed behind an object
  53542. */
  53543. backColor: Color3;
  53544. /**
  53545. * Defines if the renderer should show the back lines or not
  53546. */
  53547. showBackLines: boolean;
  53548. /**
  53549. * @hidden
  53550. */
  53551. renderList: SmartArray<BoundingBox>;
  53552. private _colorShader;
  53553. private _vertexBuffers;
  53554. private _indexBuffer;
  53555. /**
  53556. * Instantiates a new bounding box renderer in a scene.
  53557. * @param scene the scene the renderer renders in
  53558. */
  53559. constructor(scene: Scene);
  53560. /**
  53561. * Registers the component in a given scene
  53562. */
  53563. register(): void;
  53564. private _evaluateSubMesh;
  53565. private _activeMesh;
  53566. private _prepareRessources;
  53567. private _createIndexBuffer;
  53568. /**
  53569. * Rebuilds the elements related to this component in case of
  53570. * context lost for instance.
  53571. */
  53572. rebuild(): void;
  53573. /**
  53574. * @hidden
  53575. */
  53576. reset(): void;
  53577. /**
  53578. * Render the bounding boxes of a specific rendering group
  53579. * @param renderingGroupId defines the rendering group to render
  53580. */
  53581. render(renderingGroupId: number): void;
  53582. /**
  53583. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53584. * @param mesh Define the mesh to render the occlusion bounding box for
  53585. */
  53586. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53587. /**
  53588. * Dispose and release the resources attached to this renderer.
  53589. */
  53590. dispose(): void;
  53591. }
  53592. }
  53593. declare module BABYLON {
  53594. /** @hidden */
  53595. export var depthPixelShader: {
  53596. name: string;
  53597. shader: string;
  53598. };
  53599. }
  53600. declare module BABYLON {
  53601. /**
  53602. * This represents a depth renderer in Babylon.
  53603. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53604. */
  53605. export class DepthRenderer {
  53606. private _scene;
  53607. private _depthMap;
  53608. private _effect;
  53609. private _cachedDefines;
  53610. private _camera;
  53611. /**
  53612. * Specifiess that the depth renderer will only be used within
  53613. * the camera it is created for.
  53614. * This can help forcing its rendering during the camera processing.
  53615. */
  53616. useOnlyInActiveCamera: boolean;
  53617. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  53618. /**
  53619. * Instantiates a depth renderer
  53620. * @param scene The scene the renderer belongs to
  53621. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53622. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53623. */
  53624. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53625. /**
  53626. * Creates the depth rendering effect and checks if the effect is ready.
  53627. * @param subMesh The submesh to be used to render the depth map of
  53628. * @param useInstances If multiple world instances should be used
  53629. * @returns if the depth renderer is ready to render the depth map
  53630. */
  53631. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53632. /**
  53633. * Gets the texture which the depth map will be written to.
  53634. * @returns The depth map texture
  53635. */
  53636. getDepthMap(): RenderTargetTexture;
  53637. /**
  53638. * Disposes of the depth renderer.
  53639. */
  53640. dispose(): void;
  53641. }
  53642. }
  53643. declare module BABYLON {
  53644. interface Scene {
  53645. /** @hidden (Backing field) */ depthRenderer: {
  53646. [id: string]: DepthRenderer;
  53647. };
  53648. /**
  53649. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53650. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53651. * @returns the created depth renderer
  53652. */
  53653. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53654. /**
  53655. * Disables a depth renderer for a given camera
  53656. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53657. */
  53658. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53659. }
  53660. /**
  53661. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  53662. * in several rendering techniques.
  53663. */
  53664. export class DepthRendererSceneComponent implements ISceneComponent {
  53665. /**
  53666. * The component name helpfull to identify the component in the list of scene components.
  53667. */
  53668. readonly name: string;
  53669. /**
  53670. * The scene the component belongs to.
  53671. */
  53672. scene: Scene;
  53673. /**
  53674. * Creates a new instance of the component for the given scene
  53675. * @param scene Defines the scene to register the component in
  53676. */
  53677. constructor(scene: Scene);
  53678. /**
  53679. * Registers the component in a given scene
  53680. */
  53681. register(): void;
  53682. /**
  53683. * Rebuilds the elements related to this component in case of
  53684. * context lost for instance.
  53685. */
  53686. rebuild(): void;
  53687. /**
  53688. * Disposes the component and the associated ressources
  53689. */
  53690. dispose(): void;
  53691. private _gatherRenderTargets;
  53692. private _gatherActiveCameraRenderTargets;
  53693. }
  53694. }
  53695. declare module BABYLON {
  53696. /** @hidden */
  53697. export var outlinePixelShader: {
  53698. name: string;
  53699. shader: string;
  53700. };
  53701. }
  53702. declare module BABYLON {
  53703. /** @hidden */
  53704. export var outlineVertexShader: {
  53705. name: string;
  53706. shader: string;
  53707. };
  53708. }
  53709. declare module BABYLON {
  53710. interface Scene {
  53711. /** @hidden */ outlineRenderer: OutlineRenderer;
  53712. /**
  53713. * Gets the outline renderer associated with the scene
  53714. * @returns a OutlineRenderer
  53715. */
  53716. getOutlineRenderer(): OutlineRenderer;
  53717. }
  53718. interface AbstractMesh {
  53719. /** @hidden (Backing field) */ renderOutline: boolean;
  53720. /**
  53721. * Gets or sets a boolean indicating if the outline must be rendered as well
  53722. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  53723. */
  53724. renderOutline: boolean;
  53725. /** @hidden (Backing field) */ renderOverlay: boolean;
  53726. /**
  53727. * Gets or sets a boolean indicating if the overlay must be rendered as well
  53728. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  53729. */
  53730. renderOverlay: boolean;
  53731. }
  53732. /**
  53733. * This class is responsible to draw bothe outline/overlay of meshes.
  53734. * It should not be used directly but through the available method on mesh.
  53735. */
  53736. export class OutlineRenderer implements ISceneComponent {
  53737. /**
  53738. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  53739. */
  53740. private static _StencilReference;
  53741. /**
  53742. * The name of the component. Each component must have a unique name.
  53743. */
  53744. name: string;
  53745. /**
  53746. * The scene the component belongs to.
  53747. */
  53748. scene: Scene;
  53749. /**
  53750. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  53751. */
  53752. zOffset: number;
  53753. private _engine;
  53754. private _effect;
  53755. private _cachedDefines;
  53756. private _savedDepthWrite;
  53757. /**
  53758. * Instantiates a new outline renderer. (There could be only one per scene).
  53759. * @param scene Defines the scene it belongs to
  53760. */
  53761. constructor(scene: Scene);
  53762. /**
  53763. * Register the component to one instance of a scene.
  53764. */
  53765. register(): void;
  53766. /**
  53767. * Rebuilds the elements related to this component in case of
  53768. * context lost for instance.
  53769. */
  53770. rebuild(): void;
  53771. /**
  53772. * Disposes the component and the associated ressources.
  53773. */
  53774. dispose(): void;
  53775. /**
  53776. * Renders the outline in the canvas.
  53777. * @param subMesh Defines the sumesh to render
  53778. * @param batch Defines the batch of meshes in case of instances
  53779. * @param useOverlay Defines if the rendering is for the overlay or the outline
  53780. */
  53781. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  53782. /**
  53783. * Returns whether or not the outline renderer is ready for a given submesh.
  53784. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  53785. * @param subMesh Defines the submesh to check readyness for
  53786. * @param useInstances Defines wheter wee are trying to render instances or not
  53787. * @returns true if ready otherwise false
  53788. */
  53789. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53790. private _beforeRenderingMesh;
  53791. private _afterRenderingMesh;
  53792. }
  53793. }
  53794. declare module BABYLON {
  53795. /**
  53796. * Defines the list of states available for a task inside a AssetsManager
  53797. */
  53798. export enum AssetTaskState {
  53799. /**
  53800. * Initialization
  53801. */
  53802. INIT = 0,
  53803. /**
  53804. * Running
  53805. */
  53806. RUNNING = 1,
  53807. /**
  53808. * Done
  53809. */
  53810. DONE = 2,
  53811. /**
  53812. * Error
  53813. */
  53814. ERROR = 3
  53815. }
  53816. /**
  53817. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  53818. */
  53819. export abstract class AbstractAssetTask {
  53820. /**
  53821. * Task name
  53822. */ name: string;
  53823. /**
  53824. * Callback called when the task is successful
  53825. */
  53826. onSuccess: (task: any) => void;
  53827. /**
  53828. * Callback called when the task is not successful
  53829. */
  53830. onError: (task: any, message?: string, exception?: any) => void;
  53831. /**
  53832. * Creates a new AssetsManager
  53833. * @param name defines the name of the task
  53834. */
  53835. constructor(
  53836. /**
  53837. * Task name
  53838. */ name: string);
  53839. private _isCompleted;
  53840. private _taskState;
  53841. private _errorObject;
  53842. /**
  53843. * Get if the task is completed
  53844. */
  53845. readonly isCompleted: boolean;
  53846. /**
  53847. * Gets the current state of the task
  53848. */
  53849. readonly taskState: AssetTaskState;
  53850. /**
  53851. * Gets the current error object (if task is in error)
  53852. */
  53853. readonly errorObject: {
  53854. message?: string;
  53855. exception?: any;
  53856. };
  53857. /**
  53858. * Internal only
  53859. * @hidden
  53860. */ setErrorObject(message?: string, exception?: any): void;
  53861. /**
  53862. * Execute the current task
  53863. * @param scene defines the scene where you want your assets to be loaded
  53864. * @param onSuccess is a callback called when the task is successfully executed
  53865. * @param onError is a callback called if an error occurs
  53866. */
  53867. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53868. /**
  53869. * Execute the current task
  53870. * @param scene defines the scene where you want your assets to be loaded
  53871. * @param onSuccess is a callback called when the task is successfully executed
  53872. * @param onError is a callback called if an error occurs
  53873. */
  53874. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53875. /**
  53876. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  53877. * This can be used with failed tasks that have the reason for failure fixed.
  53878. */
  53879. reset(): void;
  53880. private onErrorCallback;
  53881. private onDoneCallback;
  53882. }
  53883. /**
  53884. * Define the interface used by progress events raised during assets loading
  53885. */
  53886. export interface IAssetsProgressEvent {
  53887. /**
  53888. * Defines the number of remaining tasks to process
  53889. */
  53890. remainingCount: number;
  53891. /**
  53892. * Defines the total number of tasks
  53893. */
  53894. totalCount: number;
  53895. /**
  53896. * Defines the task that was just processed
  53897. */
  53898. task: AbstractAssetTask;
  53899. }
  53900. /**
  53901. * Class used to share progress information about assets loading
  53902. */
  53903. export class AssetsProgressEvent implements IAssetsProgressEvent {
  53904. /**
  53905. * Defines the number of remaining tasks to process
  53906. */
  53907. remainingCount: number;
  53908. /**
  53909. * Defines the total number of tasks
  53910. */
  53911. totalCount: number;
  53912. /**
  53913. * Defines the task that was just processed
  53914. */
  53915. task: AbstractAssetTask;
  53916. /**
  53917. * Creates a AssetsProgressEvent
  53918. * @param remainingCount defines the number of remaining tasks to process
  53919. * @param totalCount defines the total number of tasks
  53920. * @param task defines the task that was just processed
  53921. */
  53922. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  53923. }
  53924. /**
  53925. * Define a task used by AssetsManager to load meshes
  53926. */
  53927. export class MeshAssetTask extends AbstractAssetTask {
  53928. /**
  53929. * Defines the name of the task
  53930. */
  53931. name: string;
  53932. /**
  53933. * Defines the list of mesh's names you want to load
  53934. */
  53935. meshesNames: any;
  53936. /**
  53937. * Defines the root url to use as a base to load your meshes and associated resources
  53938. */
  53939. rootUrl: string;
  53940. /**
  53941. * Defines the filename of the scene to load from
  53942. */
  53943. sceneFilename: string;
  53944. /**
  53945. * Gets the list of loaded meshes
  53946. */
  53947. loadedMeshes: Array<AbstractMesh>;
  53948. /**
  53949. * Gets the list of loaded particle systems
  53950. */
  53951. loadedParticleSystems: Array<IParticleSystem>;
  53952. /**
  53953. * Gets the list of loaded skeletons
  53954. */
  53955. loadedSkeletons: Array<Skeleton>;
  53956. /**
  53957. * Gets the list of loaded animation groups
  53958. */
  53959. loadedAnimationGroups: Array<AnimationGroup>;
  53960. /**
  53961. * Callback called when the task is successful
  53962. */
  53963. onSuccess: (task: MeshAssetTask) => void;
  53964. /**
  53965. * Callback called when the task is successful
  53966. */
  53967. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  53968. /**
  53969. * Creates a new MeshAssetTask
  53970. * @param name defines the name of the task
  53971. * @param meshesNames defines the list of mesh's names you want to load
  53972. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  53973. * @param sceneFilename defines the filename of the scene to load from
  53974. */
  53975. constructor(
  53976. /**
  53977. * Defines the name of the task
  53978. */
  53979. name: string,
  53980. /**
  53981. * Defines the list of mesh's names you want to load
  53982. */
  53983. meshesNames: any,
  53984. /**
  53985. * Defines the root url to use as a base to load your meshes and associated resources
  53986. */
  53987. rootUrl: string,
  53988. /**
  53989. * Defines the filename of the scene to load from
  53990. */
  53991. sceneFilename: string);
  53992. /**
  53993. * Execute the current task
  53994. * @param scene defines the scene where you want your assets to be loaded
  53995. * @param onSuccess is a callback called when the task is successfully executed
  53996. * @param onError is a callback called if an error occurs
  53997. */
  53998. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53999. }
  54000. /**
  54001. * Define a task used by AssetsManager to load text content
  54002. */
  54003. export class TextFileAssetTask extends AbstractAssetTask {
  54004. /**
  54005. * Defines the name of the task
  54006. */
  54007. name: string;
  54008. /**
  54009. * Defines the location of the file to load
  54010. */
  54011. url: string;
  54012. /**
  54013. * Gets the loaded text string
  54014. */
  54015. text: string;
  54016. /**
  54017. * Callback called when the task is successful
  54018. */
  54019. onSuccess: (task: TextFileAssetTask) => void;
  54020. /**
  54021. * Callback called when the task is successful
  54022. */
  54023. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54024. /**
  54025. * Creates a new TextFileAssetTask object
  54026. * @param name defines the name of the task
  54027. * @param url defines the location of the file to load
  54028. */
  54029. constructor(
  54030. /**
  54031. * Defines the name of the task
  54032. */
  54033. name: string,
  54034. /**
  54035. * Defines the location of the file to load
  54036. */
  54037. url: string);
  54038. /**
  54039. * Execute the current task
  54040. * @param scene defines the scene where you want your assets to be loaded
  54041. * @param onSuccess is a callback called when the task is successfully executed
  54042. * @param onError is a callback called if an error occurs
  54043. */
  54044. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54045. }
  54046. /**
  54047. * Define a task used by AssetsManager to load binary data
  54048. */
  54049. export class BinaryFileAssetTask extends AbstractAssetTask {
  54050. /**
  54051. * Defines the name of the task
  54052. */
  54053. name: string;
  54054. /**
  54055. * Defines the location of the file to load
  54056. */
  54057. url: string;
  54058. /**
  54059. * Gets the lodaded data (as an array buffer)
  54060. */
  54061. data: ArrayBuffer;
  54062. /**
  54063. * Callback called when the task is successful
  54064. */
  54065. onSuccess: (task: BinaryFileAssetTask) => void;
  54066. /**
  54067. * Callback called when the task is successful
  54068. */
  54069. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54070. /**
  54071. * Creates a new BinaryFileAssetTask object
  54072. * @param name defines the name of the new task
  54073. * @param url defines the location of the file to load
  54074. */
  54075. constructor(
  54076. /**
  54077. * Defines the name of the task
  54078. */
  54079. name: string,
  54080. /**
  54081. * Defines the location of the file to load
  54082. */
  54083. url: string);
  54084. /**
  54085. * Execute the current task
  54086. * @param scene defines the scene where you want your assets to be loaded
  54087. * @param onSuccess is a callback called when the task is successfully executed
  54088. * @param onError is a callback called if an error occurs
  54089. */
  54090. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54091. }
  54092. /**
  54093. * Define a task used by AssetsManager to load images
  54094. */
  54095. export class ImageAssetTask extends AbstractAssetTask {
  54096. /**
  54097. * Defines the name of the task
  54098. */
  54099. name: string;
  54100. /**
  54101. * Defines the location of the image to load
  54102. */
  54103. url: string;
  54104. /**
  54105. * Gets the loaded images
  54106. */
  54107. image: HTMLImageElement;
  54108. /**
  54109. * Callback called when the task is successful
  54110. */
  54111. onSuccess: (task: ImageAssetTask) => void;
  54112. /**
  54113. * Callback called when the task is successful
  54114. */
  54115. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54116. /**
  54117. * Creates a new ImageAssetTask
  54118. * @param name defines the name of the task
  54119. * @param url defines the location of the image to load
  54120. */
  54121. constructor(
  54122. /**
  54123. * Defines the name of the task
  54124. */
  54125. name: string,
  54126. /**
  54127. * Defines the location of the image to load
  54128. */
  54129. url: string);
  54130. /**
  54131. * Execute the current task
  54132. * @param scene defines the scene where you want your assets to be loaded
  54133. * @param onSuccess is a callback called when the task is successfully executed
  54134. * @param onError is a callback called if an error occurs
  54135. */
  54136. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54137. }
  54138. /**
  54139. * Defines the interface used by texture loading tasks
  54140. */
  54141. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54142. /**
  54143. * Gets the loaded texture
  54144. */
  54145. texture: TEX;
  54146. }
  54147. /**
  54148. * Define a task used by AssetsManager to load 2D textures
  54149. */
  54150. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54151. /**
  54152. * Defines the name of the task
  54153. */
  54154. name: string;
  54155. /**
  54156. * Defines the location of the file to load
  54157. */
  54158. url: string;
  54159. /**
  54160. * Defines if mipmap should not be generated (default is false)
  54161. */
  54162. noMipmap?: boolean | undefined;
  54163. /**
  54164. * Defines if texture must be inverted on Y axis (default is false)
  54165. */
  54166. invertY?: boolean | undefined;
  54167. /**
  54168. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54169. */
  54170. samplingMode: number;
  54171. /**
  54172. * Gets the loaded texture
  54173. */
  54174. texture: Texture;
  54175. /**
  54176. * Callback called when the task is successful
  54177. */
  54178. onSuccess: (task: TextureAssetTask) => void;
  54179. /**
  54180. * Callback called when the task is successful
  54181. */
  54182. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54183. /**
  54184. * Creates a new TextureAssetTask object
  54185. * @param name defines the name of the task
  54186. * @param url defines the location of the file to load
  54187. * @param noMipmap defines if mipmap should not be generated (default is false)
  54188. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54189. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54190. */
  54191. constructor(
  54192. /**
  54193. * Defines the name of the task
  54194. */
  54195. name: string,
  54196. /**
  54197. * Defines the location of the file to load
  54198. */
  54199. url: string,
  54200. /**
  54201. * Defines if mipmap should not be generated (default is false)
  54202. */
  54203. noMipmap?: boolean | undefined,
  54204. /**
  54205. * Defines if texture must be inverted on Y axis (default is false)
  54206. */
  54207. invertY?: boolean | undefined,
  54208. /**
  54209. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54210. */
  54211. samplingMode?: number);
  54212. /**
  54213. * Execute the current task
  54214. * @param scene defines the scene where you want your assets to be loaded
  54215. * @param onSuccess is a callback called when the task is successfully executed
  54216. * @param onError is a callback called if an error occurs
  54217. */
  54218. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54219. }
  54220. /**
  54221. * Define a task used by AssetsManager to load cube textures
  54222. */
  54223. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54224. /**
  54225. * Defines the name of the task
  54226. */
  54227. name: string;
  54228. /**
  54229. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54230. */
  54231. url: string;
  54232. /**
  54233. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54234. */
  54235. extensions?: string[] | undefined;
  54236. /**
  54237. * Defines if mipmaps should not be generated (default is false)
  54238. */
  54239. noMipmap?: boolean | undefined;
  54240. /**
  54241. * Defines the explicit list of files (undefined by default)
  54242. */
  54243. files?: string[] | undefined;
  54244. /**
  54245. * Gets the loaded texture
  54246. */
  54247. texture: CubeTexture;
  54248. /**
  54249. * Callback called when the task is successful
  54250. */
  54251. onSuccess: (task: CubeTextureAssetTask) => void;
  54252. /**
  54253. * Callback called when the task is successful
  54254. */
  54255. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54256. /**
  54257. * Creates a new CubeTextureAssetTask
  54258. * @param name defines the name of the task
  54259. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54260. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54261. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54262. * @param files defines the explicit list of files (undefined by default)
  54263. */
  54264. constructor(
  54265. /**
  54266. * Defines the name of the task
  54267. */
  54268. name: string,
  54269. /**
  54270. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54271. */
  54272. url: string,
  54273. /**
  54274. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54275. */
  54276. extensions?: string[] | undefined,
  54277. /**
  54278. * Defines if mipmaps should not be generated (default is false)
  54279. */
  54280. noMipmap?: boolean | undefined,
  54281. /**
  54282. * Defines the explicit list of files (undefined by default)
  54283. */
  54284. files?: string[] | undefined);
  54285. /**
  54286. * Execute the current task
  54287. * @param scene defines the scene where you want your assets to be loaded
  54288. * @param onSuccess is a callback called when the task is successfully executed
  54289. * @param onError is a callback called if an error occurs
  54290. */
  54291. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54292. }
  54293. /**
  54294. * Define a task used by AssetsManager to load HDR cube textures
  54295. */
  54296. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54297. /**
  54298. * Defines the name of the task
  54299. */
  54300. name: string;
  54301. /**
  54302. * Defines the location of the file to load
  54303. */
  54304. url: string;
  54305. /**
  54306. * Defines the desired size (the more it increases the longer the generation will be)
  54307. */
  54308. size: number;
  54309. /**
  54310. * Defines if mipmaps should not be generated (default is false)
  54311. */
  54312. noMipmap: boolean;
  54313. /**
  54314. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54315. */
  54316. generateHarmonics: boolean;
  54317. /**
  54318. * 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)
  54319. */
  54320. gammaSpace: boolean;
  54321. /**
  54322. * Internal Use Only
  54323. */
  54324. reserved: boolean;
  54325. /**
  54326. * Gets the loaded texture
  54327. */
  54328. texture: HDRCubeTexture;
  54329. /**
  54330. * Callback called when the task is successful
  54331. */
  54332. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54333. /**
  54334. * Callback called when the task is successful
  54335. */
  54336. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54337. /**
  54338. * Creates a new HDRCubeTextureAssetTask object
  54339. * @param name defines the name of the task
  54340. * @param url defines the location of the file to load
  54341. * @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.
  54342. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54343. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54344. * @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)
  54345. * @param reserved Internal use only
  54346. */
  54347. constructor(
  54348. /**
  54349. * Defines the name of the task
  54350. */
  54351. name: string,
  54352. /**
  54353. * Defines the location of the file to load
  54354. */
  54355. url: string,
  54356. /**
  54357. * Defines the desired size (the more it increases the longer the generation will be)
  54358. */
  54359. size: number,
  54360. /**
  54361. * Defines if mipmaps should not be generated (default is false)
  54362. */
  54363. noMipmap?: boolean,
  54364. /**
  54365. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54366. */
  54367. generateHarmonics?: boolean,
  54368. /**
  54369. * 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)
  54370. */
  54371. gammaSpace?: boolean,
  54372. /**
  54373. * Internal Use Only
  54374. */
  54375. reserved?: boolean);
  54376. /**
  54377. * Execute the current task
  54378. * @param scene defines the scene where you want your assets to be loaded
  54379. * @param onSuccess is a callback called when the task is successfully executed
  54380. * @param onError is a callback called if an error occurs
  54381. */
  54382. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54383. }
  54384. /**
  54385. * Define a task used by AssetsManager to load Equirectangular cube textures
  54386. */
  54387. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  54388. /**
  54389. * Defines the name of the task
  54390. */
  54391. name: string;
  54392. /**
  54393. * Defines the location of the file to load
  54394. */
  54395. url: string;
  54396. /**
  54397. * Defines the desired size (the more it increases the longer the generation will be)
  54398. */
  54399. size: number;
  54400. /**
  54401. * Defines if mipmaps should not be generated (default is false)
  54402. */
  54403. noMipmap: boolean;
  54404. /**
  54405. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54406. * but the standard material would require them in Gamma space) (default is true)
  54407. */
  54408. gammaSpace: boolean;
  54409. /**
  54410. * Gets the loaded texture
  54411. */
  54412. texture: EquiRectangularCubeTexture;
  54413. /**
  54414. * Callback called when the task is successful
  54415. */
  54416. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  54417. /**
  54418. * Callback called when the task is successful
  54419. */
  54420. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  54421. /**
  54422. * Creates a new EquiRectangularCubeTextureAssetTask object
  54423. * @param name defines the name of the task
  54424. * @param url defines the location of the file to load
  54425. * @param size defines the desired size (the more it increases the longer the generation will be)
  54426. * If the size is omitted this implies you are using a preprocessed cubemap.
  54427. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54428. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  54429. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54430. * (default is true)
  54431. */
  54432. constructor(
  54433. /**
  54434. * Defines the name of the task
  54435. */
  54436. name: string,
  54437. /**
  54438. * Defines the location of the file to load
  54439. */
  54440. url: string,
  54441. /**
  54442. * Defines the desired size (the more it increases the longer the generation will be)
  54443. */
  54444. size: number,
  54445. /**
  54446. * Defines if mipmaps should not be generated (default is false)
  54447. */
  54448. noMipmap?: boolean,
  54449. /**
  54450. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54451. * but the standard material would require them in Gamma space) (default is true)
  54452. */
  54453. gammaSpace?: boolean);
  54454. /**
  54455. * Execute the current task
  54456. * @param scene defines the scene where you want your assets to be loaded
  54457. * @param onSuccess is a callback called when the task is successfully executed
  54458. * @param onError is a callback called if an error occurs
  54459. */
  54460. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54461. }
  54462. /**
  54463. * This class can be used to easily import assets into a scene
  54464. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54465. */
  54466. export class AssetsManager {
  54467. private _scene;
  54468. private _isLoading;
  54469. protected _tasks: AbstractAssetTask[];
  54470. protected _waitingTasksCount: number;
  54471. protected _totalTasksCount: number;
  54472. /**
  54473. * Callback called when all tasks are processed
  54474. */
  54475. onFinish: (tasks: AbstractAssetTask[]) => void;
  54476. /**
  54477. * Callback called when a task is successful
  54478. */
  54479. onTaskSuccess: (task: AbstractAssetTask) => void;
  54480. /**
  54481. * Callback called when a task had an error
  54482. */
  54483. onTaskError: (task: AbstractAssetTask) => void;
  54484. /**
  54485. * Callback called when a task is done (whatever the result is)
  54486. */
  54487. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54488. /**
  54489. * Observable called when all tasks are processed
  54490. */
  54491. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54492. /**
  54493. * Observable called when a task had an error
  54494. */
  54495. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54496. /**
  54497. * Observable called when all tasks were executed
  54498. */
  54499. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54500. /**
  54501. * Observable called when a task is done (whatever the result is)
  54502. */
  54503. onProgressObservable: Observable<IAssetsProgressEvent>;
  54504. /**
  54505. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54506. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54507. */
  54508. useDefaultLoadingScreen: boolean;
  54509. /**
  54510. * Creates a new AssetsManager
  54511. * @param scene defines the scene to work on
  54512. */
  54513. constructor(scene: Scene);
  54514. /**
  54515. * Add a MeshAssetTask to the list of active tasks
  54516. * @param taskName defines the name of the new task
  54517. * @param meshesNames defines the name of meshes to load
  54518. * @param rootUrl defines the root url to use to locate files
  54519. * @param sceneFilename defines the filename of the scene file
  54520. * @returns a new MeshAssetTask object
  54521. */
  54522. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54523. /**
  54524. * Add a TextFileAssetTask to the list of active tasks
  54525. * @param taskName defines the name of the new task
  54526. * @param url defines the url of the file to load
  54527. * @returns a new TextFileAssetTask object
  54528. */
  54529. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54530. /**
  54531. * Add a BinaryFileAssetTask to the list of active tasks
  54532. * @param taskName defines the name of the new task
  54533. * @param url defines the url of the file to load
  54534. * @returns a new BinaryFileAssetTask object
  54535. */
  54536. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54537. /**
  54538. * Add a ImageAssetTask to the list of active tasks
  54539. * @param taskName defines the name of the new task
  54540. * @param url defines the url of the file to load
  54541. * @returns a new ImageAssetTask object
  54542. */
  54543. addImageTask(taskName: string, url: string): ImageAssetTask;
  54544. /**
  54545. * Add a TextureAssetTask to the list of active tasks
  54546. * @param taskName defines the name of the new task
  54547. * @param url defines the url of the file to load
  54548. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54549. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54550. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54551. * @returns a new TextureAssetTask object
  54552. */
  54553. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54554. /**
  54555. * Add a CubeTextureAssetTask to the list of active tasks
  54556. * @param taskName defines the name of the new task
  54557. * @param url defines the url of the file to load
  54558. * @param extensions defines the extension to use to load the cube map (can be null)
  54559. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54560. * @param files defines the list of files to load (can be null)
  54561. * @returns a new CubeTextureAssetTask object
  54562. */
  54563. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54564. /**
  54565. *
  54566. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54567. * @param taskName defines the name of the new task
  54568. * @param url defines the url of the file to load
  54569. * @param size defines the size you want for the cubemap (can be null)
  54570. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54571. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54572. * @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)
  54573. * @param reserved Internal use only
  54574. * @returns a new HDRCubeTextureAssetTask object
  54575. */
  54576. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54577. /**
  54578. *
  54579. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  54580. * @param taskName defines the name of the new task
  54581. * @param url defines the url of the file to load
  54582. * @param size defines the size you want for the cubemap (can be null)
  54583. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54584. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54585. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54586. * @returns a new EquiRectangularCubeTextureAssetTask object
  54587. */
  54588. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  54589. /**
  54590. * Remove a task from the assets manager.
  54591. * @param task the task to remove
  54592. */
  54593. removeTask(task: AbstractAssetTask): void;
  54594. private _decreaseWaitingTasksCount;
  54595. private _runTask;
  54596. /**
  54597. * Reset the AssetsManager and remove all tasks
  54598. * @return the current instance of the AssetsManager
  54599. */
  54600. reset(): AssetsManager;
  54601. /**
  54602. * Start the loading process
  54603. * @return the current instance of the AssetsManager
  54604. */
  54605. load(): AssetsManager;
  54606. /**
  54607. * Start the loading process as an async operation
  54608. * @return a promise returning the list of failed tasks
  54609. */
  54610. loadAsync(): Promise<void>;
  54611. }
  54612. }
  54613. declare module BABYLON {
  54614. /**
  54615. * Wrapper class for promise with external resolve and reject.
  54616. */
  54617. export class Deferred<T> {
  54618. /**
  54619. * The promise associated with this deferred object.
  54620. */
  54621. readonly promise: Promise<T>;
  54622. private _resolve;
  54623. private _reject;
  54624. /**
  54625. * The resolve method of the promise associated with this deferred object.
  54626. */
  54627. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54628. /**
  54629. * The reject method of the promise associated with this deferred object.
  54630. */
  54631. readonly reject: (reason?: any) => void;
  54632. /**
  54633. * Constructor for this deferred object.
  54634. */
  54635. constructor();
  54636. }
  54637. }
  54638. declare module BABYLON {
  54639. /**
  54640. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  54641. */
  54642. export class MeshExploder {
  54643. private _centerMesh;
  54644. private _meshes;
  54645. private _meshesOrigins;
  54646. private _toCenterVectors;
  54647. private _scaledDirection;
  54648. private _newPosition;
  54649. private _centerPosition;
  54650. /**
  54651. * Explodes meshes from a center mesh.
  54652. * @param meshes The meshes to explode.
  54653. * @param centerMesh The mesh to be center of explosion.
  54654. */
  54655. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  54656. private _setCenterMesh;
  54657. /**
  54658. * Get class name
  54659. * @returns "MeshExploder"
  54660. */
  54661. getClassName(): string;
  54662. /**
  54663. * "Exploded meshes"
  54664. * @returns Array of meshes with the centerMesh at index 0.
  54665. */
  54666. getMeshes(): Array<Mesh>;
  54667. /**
  54668. * Explodes meshes giving a specific direction
  54669. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  54670. */
  54671. explode(direction?: number): void;
  54672. }
  54673. }
  54674. declare module BABYLON {
  54675. /**
  54676. * Class used to help managing file picking and drag'n'drop
  54677. */
  54678. export class FilesInput {
  54679. /**
  54680. * List of files ready to be loaded
  54681. */
  54682. static readonly FilesToLoad: {
  54683. [key: string]: File;
  54684. };
  54685. /**
  54686. * Callback called when a file is processed
  54687. */
  54688. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  54689. private _engine;
  54690. private _currentScene;
  54691. private _sceneLoadedCallback;
  54692. private _progressCallback;
  54693. private _additionalRenderLoopLogicCallback;
  54694. private _textureLoadingCallback;
  54695. private _startingProcessingFilesCallback;
  54696. private _onReloadCallback;
  54697. private _errorCallback;
  54698. private _elementToMonitor;
  54699. private _sceneFileToLoad;
  54700. private _filesToLoad;
  54701. /**
  54702. * Creates a new FilesInput
  54703. * @param engine defines the rendering engine
  54704. * @param scene defines the hosting scene
  54705. * @param sceneLoadedCallback callback called when scene is loaded
  54706. * @param progressCallback callback called to track progress
  54707. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  54708. * @param textureLoadingCallback callback called when a texture is loading
  54709. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  54710. * @param onReloadCallback callback called when a reload is requested
  54711. * @param errorCallback callback call if an error occurs
  54712. */
  54713. 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);
  54714. private _dragEnterHandler;
  54715. private _dragOverHandler;
  54716. private _dropHandler;
  54717. /**
  54718. * Calls this function to listen to drag'n'drop events on a specific DOM element
  54719. * @param elementToMonitor defines the DOM element to track
  54720. */
  54721. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  54722. /**
  54723. * Release all associated resources
  54724. */
  54725. dispose(): void;
  54726. private renderFunction;
  54727. private drag;
  54728. private drop;
  54729. private _traverseFolder;
  54730. private _processFiles;
  54731. /**
  54732. * Load files from a drop event
  54733. * @param event defines the drop event to use as source
  54734. */
  54735. loadFiles(event: any): void;
  54736. private _processReload;
  54737. /**
  54738. * Reload the current scene from the loaded files
  54739. */
  54740. reload(): void;
  54741. }
  54742. }
  54743. declare module BABYLON {
  54744. /**
  54745. * Defines the root class used to create scene optimization to use with SceneOptimizer
  54746. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54747. */
  54748. export class SceneOptimization {
  54749. /**
  54750. * Defines the priority of this optimization (0 by default which means first in the list)
  54751. */
  54752. priority: number;
  54753. /**
  54754. * Gets a string describing the action executed by the current optimization
  54755. * @returns description string
  54756. */
  54757. getDescription(): string;
  54758. /**
  54759. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54760. * @param scene defines the current scene where to apply this optimization
  54761. * @param optimizer defines the current optimizer
  54762. * @returns true if everything that can be done was applied
  54763. */
  54764. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54765. /**
  54766. * Creates the SceneOptimization object
  54767. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54768. * @param desc defines the description associated with the optimization
  54769. */
  54770. constructor(
  54771. /**
  54772. * Defines the priority of this optimization (0 by default which means first in the list)
  54773. */
  54774. priority?: number);
  54775. }
  54776. /**
  54777. * Defines an optimization used to reduce the size of render target textures
  54778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54779. */
  54780. export class TextureOptimization extends SceneOptimization {
  54781. /**
  54782. * Defines the priority of this optimization (0 by default which means first in the list)
  54783. */
  54784. priority: number;
  54785. /**
  54786. * 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
  54787. */
  54788. maximumSize: number;
  54789. /**
  54790. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54791. */
  54792. step: number;
  54793. /**
  54794. * Gets a string describing the action executed by the current optimization
  54795. * @returns description string
  54796. */
  54797. getDescription(): string;
  54798. /**
  54799. * Creates the TextureOptimization object
  54800. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54801. * @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
  54802. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54803. */
  54804. constructor(
  54805. /**
  54806. * Defines the priority of this optimization (0 by default which means first in the list)
  54807. */
  54808. priority?: number,
  54809. /**
  54810. * 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
  54811. */
  54812. maximumSize?: number,
  54813. /**
  54814. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54815. */
  54816. step?: number);
  54817. /**
  54818. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54819. * @param scene defines the current scene where to apply this optimization
  54820. * @param optimizer defines the current optimizer
  54821. * @returns true if everything that can be done was applied
  54822. */
  54823. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54824. }
  54825. /**
  54826. * Defines an optimization used to increase or decrease the rendering resolution
  54827. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54828. */
  54829. export class HardwareScalingOptimization extends SceneOptimization {
  54830. /**
  54831. * Defines the priority of this optimization (0 by default which means first in the list)
  54832. */
  54833. priority: number;
  54834. /**
  54835. * Defines the maximum scale to use (2 by default)
  54836. */
  54837. maximumScale: number;
  54838. /**
  54839. * Defines the step to use between two passes (0.5 by default)
  54840. */
  54841. step: number;
  54842. private _currentScale;
  54843. private _directionOffset;
  54844. /**
  54845. * Gets a string describing the action executed by the current optimization
  54846. * @return description string
  54847. */
  54848. getDescription(): string;
  54849. /**
  54850. * Creates the HardwareScalingOptimization object
  54851. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54852. * @param maximumScale defines the maximum scale to use (2 by default)
  54853. * @param step defines the step to use between two passes (0.5 by default)
  54854. */
  54855. constructor(
  54856. /**
  54857. * Defines the priority of this optimization (0 by default which means first in the list)
  54858. */
  54859. priority?: number,
  54860. /**
  54861. * Defines the maximum scale to use (2 by default)
  54862. */
  54863. maximumScale?: number,
  54864. /**
  54865. * Defines the step to use between two passes (0.5 by default)
  54866. */
  54867. step?: number);
  54868. /**
  54869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54870. * @param scene defines the current scene where to apply this optimization
  54871. * @param optimizer defines the current optimizer
  54872. * @returns true if everything that can be done was applied
  54873. */
  54874. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54875. }
  54876. /**
  54877. * Defines an optimization used to remove shadows
  54878. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54879. */
  54880. export class ShadowsOptimization extends SceneOptimization {
  54881. /**
  54882. * Gets a string describing the action executed by the current optimization
  54883. * @return description string
  54884. */
  54885. getDescription(): string;
  54886. /**
  54887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54888. * @param scene defines the current scene where to apply this optimization
  54889. * @param optimizer defines the current optimizer
  54890. * @returns true if everything that can be done was applied
  54891. */
  54892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54893. }
  54894. /**
  54895. * Defines an optimization used to turn post-processes off
  54896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54897. */
  54898. export class PostProcessesOptimization extends SceneOptimization {
  54899. /**
  54900. * Gets a string describing the action executed by the current optimization
  54901. * @return description string
  54902. */
  54903. getDescription(): string;
  54904. /**
  54905. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54906. * @param scene defines the current scene where to apply this optimization
  54907. * @param optimizer defines the current optimizer
  54908. * @returns true if everything that can be done was applied
  54909. */
  54910. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54911. }
  54912. /**
  54913. * Defines an optimization used to turn lens flares off
  54914. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54915. */
  54916. export class LensFlaresOptimization extends SceneOptimization {
  54917. /**
  54918. * Gets a string describing the action executed by the current optimization
  54919. * @return description string
  54920. */
  54921. getDescription(): string;
  54922. /**
  54923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54924. * @param scene defines the current scene where to apply this optimization
  54925. * @param optimizer defines the current optimizer
  54926. * @returns true if everything that can be done was applied
  54927. */
  54928. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54929. }
  54930. /**
  54931. * Defines an optimization based on user defined callback.
  54932. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54933. */
  54934. export class CustomOptimization extends SceneOptimization {
  54935. /**
  54936. * Callback called to apply the custom optimization.
  54937. */
  54938. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  54939. /**
  54940. * Callback called to get custom description
  54941. */
  54942. onGetDescription: () => string;
  54943. /**
  54944. * Gets a string describing the action executed by the current optimization
  54945. * @returns description string
  54946. */
  54947. getDescription(): string;
  54948. /**
  54949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54950. * @param scene defines the current scene where to apply this optimization
  54951. * @param optimizer defines the current optimizer
  54952. * @returns true if everything that can be done was applied
  54953. */
  54954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54955. }
  54956. /**
  54957. * Defines an optimization used to turn particles off
  54958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54959. */
  54960. export class ParticlesOptimization extends SceneOptimization {
  54961. /**
  54962. * Gets a string describing the action executed by the current optimization
  54963. * @return description string
  54964. */
  54965. getDescription(): string;
  54966. /**
  54967. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54968. * @param scene defines the current scene where to apply this optimization
  54969. * @param optimizer defines the current optimizer
  54970. * @returns true if everything that can be done was applied
  54971. */
  54972. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54973. }
  54974. /**
  54975. * Defines an optimization used to turn render targets off
  54976. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54977. */
  54978. export class RenderTargetsOptimization extends SceneOptimization {
  54979. /**
  54980. * Gets a string describing the action executed by the current optimization
  54981. * @return description string
  54982. */
  54983. getDescription(): string;
  54984. /**
  54985. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54986. * @param scene defines the current scene where to apply this optimization
  54987. * @param optimizer defines the current optimizer
  54988. * @returns true if everything that can be done was applied
  54989. */
  54990. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54991. }
  54992. /**
  54993. * Defines an optimization used to merge meshes with compatible materials
  54994. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54995. */
  54996. export class MergeMeshesOptimization extends SceneOptimization {
  54997. private static _UpdateSelectionTree;
  54998. /**
  54999. * Gets or sets a boolean which defines if optimization octree has to be updated
  55000. */
  55001. /**
  55002. * Gets or sets a boolean which defines if optimization octree has to be updated
  55003. */
  55004. static UpdateSelectionTree: boolean;
  55005. /**
  55006. * Gets a string describing the action executed by the current optimization
  55007. * @return description string
  55008. */
  55009. getDescription(): string;
  55010. private _canBeMerged;
  55011. /**
  55012. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55013. * @param scene defines the current scene where to apply this optimization
  55014. * @param optimizer defines the current optimizer
  55015. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55016. * @returns true if everything that can be done was applied
  55017. */
  55018. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55019. }
  55020. /**
  55021. * Defines a list of options used by SceneOptimizer
  55022. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55023. */
  55024. export class SceneOptimizerOptions {
  55025. /**
  55026. * Defines the target frame rate to reach (60 by default)
  55027. */
  55028. targetFrameRate: number;
  55029. /**
  55030. * Defines the interval between two checkes (2000ms by default)
  55031. */
  55032. trackerDuration: number;
  55033. /**
  55034. * Gets the list of optimizations to apply
  55035. */
  55036. optimizations: SceneOptimization[];
  55037. /**
  55038. * Creates a new list of options used by SceneOptimizer
  55039. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55040. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55041. */
  55042. constructor(
  55043. /**
  55044. * Defines the target frame rate to reach (60 by default)
  55045. */
  55046. targetFrameRate?: number,
  55047. /**
  55048. * Defines the interval between two checkes (2000ms by default)
  55049. */
  55050. trackerDuration?: number);
  55051. /**
  55052. * Add a new optimization
  55053. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55054. * @returns the current SceneOptimizerOptions
  55055. */
  55056. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55057. /**
  55058. * Add a new custom optimization
  55059. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55060. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55061. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55062. * @returns the current SceneOptimizerOptions
  55063. */
  55064. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55065. /**
  55066. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55067. * @param targetFrameRate defines the target frame rate (60 by default)
  55068. * @returns a SceneOptimizerOptions object
  55069. */
  55070. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55071. /**
  55072. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55073. * @param targetFrameRate defines the target frame rate (60 by default)
  55074. * @returns a SceneOptimizerOptions object
  55075. */
  55076. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55077. /**
  55078. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55079. * @param targetFrameRate defines the target frame rate (60 by default)
  55080. * @returns a SceneOptimizerOptions object
  55081. */
  55082. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55083. }
  55084. /**
  55085. * Class used to run optimizations in order to reach a target frame rate
  55086. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55087. */
  55088. export class SceneOptimizer implements IDisposable {
  55089. private _isRunning;
  55090. private _options;
  55091. private _scene;
  55092. private _currentPriorityLevel;
  55093. private _targetFrameRate;
  55094. private _trackerDuration;
  55095. private _currentFrameRate;
  55096. private _sceneDisposeObserver;
  55097. private _improvementMode;
  55098. /**
  55099. * Defines an observable called when the optimizer reaches the target frame rate
  55100. */
  55101. onSuccessObservable: Observable<SceneOptimizer>;
  55102. /**
  55103. * Defines an observable called when the optimizer enables an optimization
  55104. */
  55105. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55106. /**
  55107. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55108. */
  55109. onFailureObservable: Observable<SceneOptimizer>;
  55110. /**
  55111. * Gets a boolean indicating if the optimizer is in improvement mode
  55112. */
  55113. readonly isInImprovementMode: boolean;
  55114. /**
  55115. * Gets the current priority level (0 at start)
  55116. */
  55117. readonly currentPriorityLevel: number;
  55118. /**
  55119. * Gets the current frame rate checked by the SceneOptimizer
  55120. */
  55121. readonly currentFrameRate: number;
  55122. /**
  55123. * Gets or sets the current target frame rate (60 by default)
  55124. */
  55125. /**
  55126. * Gets or sets the current target frame rate (60 by default)
  55127. */
  55128. targetFrameRate: number;
  55129. /**
  55130. * Gets or sets the current interval between two checks (every 2000ms by default)
  55131. */
  55132. /**
  55133. * Gets or sets the current interval between two checks (every 2000ms by default)
  55134. */
  55135. trackerDuration: number;
  55136. /**
  55137. * Gets the list of active optimizations
  55138. */
  55139. readonly optimizations: SceneOptimization[];
  55140. /**
  55141. * Creates a new SceneOptimizer
  55142. * @param scene defines the scene to work on
  55143. * @param options defines the options to use with the SceneOptimizer
  55144. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55145. * @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)
  55146. */
  55147. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55148. /**
  55149. * Stops the current optimizer
  55150. */
  55151. stop(): void;
  55152. /**
  55153. * Reset the optimizer to initial step (current priority level = 0)
  55154. */
  55155. reset(): void;
  55156. /**
  55157. * Start the optimizer. By default it will try to reach a specific framerate
  55158. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55159. */
  55160. start(): void;
  55161. private _checkCurrentState;
  55162. /**
  55163. * Release all resources
  55164. */
  55165. dispose(): void;
  55166. /**
  55167. * Helper function to create a SceneOptimizer with one single line of code
  55168. * @param scene defines the scene to work on
  55169. * @param options defines the options to use with the SceneOptimizer
  55170. * @param onSuccess defines a callback to call on success
  55171. * @param onFailure defines a callback to call on failure
  55172. * @returns the new SceneOptimizer object
  55173. */
  55174. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55175. }
  55176. }
  55177. declare module BABYLON {
  55178. /**
  55179. * Class used to serialize a scene into a string
  55180. */
  55181. export class SceneSerializer {
  55182. /**
  55183. * Clear cache used by a previous serialization
  55184. */
  55185. static ClearCache(): void;
  55186. /**
  55187. * Serialize a scene into a JSON compatible object
  55188. * @param scene defines the scene to serialize
  55189. * @returns a JSON compatible object
  55190. */
  55191. static Serialize(scene: Scene): any;
  55192. /**
  55193. * Serialize a mesh into a JSON compatible object
  55194. * @param toSerialize defines the mesh to serialize
  55195. * @param withParents defines if parents must be serialized as well
  55196. * @param withChildren defines if children must be serialized as well
  55197. * @returns a JSON compatible object
  55198. */
  55199. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55200. }
  55201. }
  55202. declare module BABYLON {
  55203. /**
  55204. * Class used to host texture specific utilities
  55205. */
  55206. export class TextureTools {
  55207. /**
  55208. * Uses the GPU to create a copy texture rescaled at a given size
  55209. * @param texture Texture to copy from
  55210. * @param width defines the desired width
  55211. * @param height defines the desired height
  55212. * @param useBilinearMode defines if bilinear mode has to be used
  55213. * @return the generated texture
  55214. */
  55215. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55216. }
  55217. }
  55218. declare module BABYLON {
  55219. /**
  55220. * This represents the different options avilable for the video capture.
  55221. */
  55222. export interface VideoRecorderOptions {
  55223. /** Defines the mime type of the video */
  55224. mimeType: string;
  55225. /** Defines the video the video should be recorded at */
  55226. fps: number;
  55227. /** Defines the chunk size for the recording data */
  55228. recordChunckSize: number;
  55229. /** The audio tracks to attach to the record */
  55230. audioTracks?: MediaStreamTrack[];
  55231. }
  55232. /**
  55233. * This can helps recording videos from BabylonJS.
  55234. * This is based on the available WebRTC functionalities of the browser.
  55235. *
  55236. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55237. */
  55238. export class VideoRecorder {
  55239. private static readonly _defaultOptions;
  55240. /**
  55241. * Returns wehther or not the VideoRecorder is available in your browser.
  55242. * @param engine Defines the Babylon Engine to check the support for
  55243. * @returns true if supported otherwise false
  55244. */
  55245. static IsSupported(engine: Engine): boolean;
  55246. private readonly _options;
  55247. private _canvas;
  55248. private _mediaRecorder;
  55249. private _recordedChunks;
  55250. private _fileName;
  55251. private _resolve;
  55252. private _reject;
  55253. /**
  55254. * True wether a recording is already in progress.
  55255. */
  55256. readonly isRecording: boolean;
  55257. /**
  55258. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55259. * a video file.
  55260. * @param engine Defines the BabylonJS Engine you wish to record
  55261. * @param options Defines options that can be used to customized the capture
  55262. */
  55263. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55264. /**
  55265. * Stops the current recording before the default capture timeout passed in the startRecording
  55266. * functions.
  55267. */
  55268. stopRecording(): void;
  55269. /**
  55270. * Starts recording the canvas for a max duration specified in parameters.
  55271. * @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.
  55272. * @param maxDuration Defines the maximum recording time in seconds.
  55273. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55274. * @return a promise callback at the end of the recording with the video data in Blob.
  55275. */
  55276. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55277. /**
  55278. * Releases internal resources used during the recording.
  55279. */
  55280. dispose(): void;
  55281. private _handleDataAvailable;
  55282. private _handleError;
  55283. private _handleStop;
  55284. }
  55285. }
  55286. declare module BABYLON {
  55287. /**
  55288. * Class containing a set of static utilities functions for screenshots
  55289. */
  55290. export class ScreenshotTools {
  55291. /**
  55292. * Captures a screenshot of the current rendering
  55293. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55294. * @param engine defines the rendering engine
  55295. * @param camera defines the source camera
  55296. * @param size This parameter can be set to a single number or to an object with the
  55297. * following (optional) properties: precision, width, height. If a single number is passed,
  55298. * it will be used for both width and height. If an object is passed, the screenshot size
  55299. * will be derived from the parameters. The precision property is a multiplier allowing
  55300. * rendering at a higher or lower resolution
  55301. * @param successCallback defines the callback receives a single parameter which contains the
  55302. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55303. * src parameter of an <img> to display it
  55304. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55305. * Check your browser for supported MIME types
  55306. */
  55307. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55308. /**
  55309. * Generates an image screenshot from the specified camera.
  55310. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55311. * @param engine The engine to use for rendering
  55312. * @param camera The camera to use for rendering
  55313. * @param size This parameter can be set to a single number or to an object with the
  55314. * following (optional) properties: precision, width, height. If a single number is passed,
  55315. * it will be used for both width and height. If an object is passed, the screenshot size
  55316. * will be derived from the parameters. The precision property is a multiplier allowing
  55317. * rendering at a higher or lower resolution
  55318. * @param successCallback The callback receives a single parameter which contains the
  55319. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55320. * src parameter of an <img> to display it
  55321. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55322. * Check your browser for supported MIME types
  55323. * @param samples Texture samples (default: 1)
  55324. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55325. * @param fileName A name for for the downloaded file.
  55326. */
  55327. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55328. }
  55329. }
  55330. declare module BABYLON {
  55331. /**
  55332. * A cursor which tracks a point on a path
  55333. */
  55334. export class PathCursor {
  55335. private path;
  55336. /**
  55337. * Stores path cursor callbacks for when an onchange event is triggered
  55338. */
  55339. private _onchange;
  55340. /**
  55341. * The value of the path cursor
  55342. */
  55343. value: number;
  55344. /**
  55345. * The animation array of the path cursor
  55346. */
  55347. animations: Animation[];
  55348. /**
  55349. * Initializes the path cursor
  55350. * @param path The path to track
  55351. */
  55352. constructor(path: Path2);
  55353. /**
  55354. * Gets the cursor point on the path
  55355. * @returns A point on the path cursor at the cursor location
  55356. */
  55357. getPoint(): Vector3;
  55358. /**
  55359. * Moves the cursor ahead by the step amount
  55360. * @param step The amount to move the cursor forward
  55361. * @returns This path cursor
  55362. */
  55363. moveAhead(step?: number): PathCursor;
  55364. /**
  55365. * Moves the cursor behind by the step amount
  55366. * @param step The amount to move the cursor back
  55367. * @returns This path cursor
  55368. */
  55369. moveBack(step?: number): PathCursor;
  55370. /**
  55371. * Moves the cursor by the step amount
  55372. * If the step amount is greater than one, an exception is thrown
  55373. * @param step The amount to move the cursor
  55374. * @returns This path cursor
  55375. */
  55376. move(step: number): PathCursor;
  55377. /**
  55378. * Ensures that the value is limited between zero and one
  55379. * @returns This path cursor
  55380. */
  55381. private ensureLimits;
  55382. /**
  55383. * Runs onchange callbacks on change (used by the animation engine)
  55384. * @returns This path cursor
  55385. */
  55386. private raiseOnChange;
  55387. /**
  55388. * Executes a function on change
  55389. * @param f A path cursor onchange callback
  55390. * @returns This path cursor
  55391. */
  55392. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55393. }
  55394. }
  55395. declare module BABYLON {
  55396. /** @hidden */
  55397. export var blurPixelShader: {
  55398. name: string;
  55399. shader: string;
  55400. };
  55401. }
  55402. declare module BABYLON {
  55403. /** @hidden */
  55404. export var bones300Declaration: {
  55405. name: string;
  55406. shader: string;
  55407. };
  55408. }
  55409. declare module BABYLON {
  55410. /** @hidden */
  55411. export var instances300Declaration: {
  55412. name: string;
  55413. shader: string;
  55414. };
  55415. }
  55416. declare module BABYLON {
  55417. /** @hidden */
  55418. export var pointCloudVertexDeclaration: {
  55419. name: string;
  55420. shader: string;
  55421. };
  55422. }
  55423. // Mixins
  55424. interface Window {
  55425. mozIndexedDB: IDBFactory;
  55426. webkitIndexedDB: IDBFactory;
  55427. msIndexedDB: IDBFactory;
  55428. webkitURL: typeof URL;
  55429. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55430. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55431. WebGLRenderingContext: WebGLRenderingContext;
  55432. MSGesture: MSGesture;
  55433. CANNON: any;
  55434. AudioContext: AudioContext;
  55435. webkitAudioContext: AudioContext;
  55436. PointerEvent: any;
  55437. Math: Math;
  55438. Uint8Array: Uint8ArrayConstructor;
  55439. Float32Array: Float32ArrayConstructor;
  55440. mozURL: typeof URL;
  55441. msURL: typeof URL;
  55442. VRFrameData: any; // WebVR, from specs 1.1
  55443. DracoDecoderModule: any;
  55444. setImmediate(handler: (...args: any[]) => void): number;
  55445. }
  55446. interface HTMLCanvasElement {
  55447. requestPointerLock(): void;
  55448. msRequestPointerLock?(): void;
  55449. mozRequestPointerLock?(): void;
  55450. webkitRequestPointerLock?(): void;
  55451. /** Track wether a record is in progress */
  55452. isRecording: boolean;
  55453. /** Capture Stream method defined by some browsers */
  55454. captureStream(fps?: number): MediaStream;
  55455. }
  55456. interface CanvasRenderingContext2D {
  55457. msImageSmoothingEnabled: boolean;
  55458. }
  55459. interface MouseEvent {
  55460. mozMovementX: number;
  55461. mozMovementY: number;
  55462. webkitMovementX: number;
  55463. webkitMovementY: number;
  55464. msMovementX: number;
  55465. msMovementY: number;
  55466. }
  55467. interface Navigator {
  55468. mozGetVRDevices: (any: any) => any;
  55469. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55470. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55471. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55472. webkitGetGamepads(): Gamepad[];
  55473. msGetGamepads(): Gamepad[];
  55474. webkitGamepads(): Gamepad[];
  55475. }
  55476. interface HTMLVideoElement {
  55477. mozSrcObject: any;
  55478. }
  55479. interface Math {
  55480. fround(x: number): number;
  55481. imul(a: number, b: number): number;
  55482. }
  55483. interface WebGLProgram {
  55484. context?: WebGLRenderingContext;
  55485. vertexShader?: WebGLShader;
  55486. fragmentShader?: WebGLShader;
  55487. isParallelCompiled: boolean;
  55488. onCompiled?: () => void;
  55489. }
  55490. interface WebGLRenderingContext {
  55491. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55492. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55493. vertexAttribDivisor(index: number, divisor: number): void;
  55494. createVertexArray(): any;
  55495. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55496. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55497. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55498. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55499. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55500. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55501. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55502. // Queries
  55503. createQuery(): WebGLQuery;
  55504. deleteQuery(query: WebGLQuery): void;
  55505. beginQuery(target: number, query: WebGLQuery): void;
  55506. endQuery(target: number): void;
  55507. getQueryParameter(query: WebGLQuery, pname: number): any;
  55508. getQuery(target: number, pname: number): any;
  55509. MAX_SAMPLES: number;
  55510. RGBA8: number;
  55511. READ_FRAMEBUFFER: number;
  55512. DRAW_FRAMEBUFFER: number;
  55513. UNIFORM_BUFFER: number;
  55514. HALF_FLOAT_OES: number;
  55515. RGBA16F: number;
  55516. RGBA32F: number;
  55517. R32F: number;
  55518. RG32F: number;
  55519. RGB32F: number;
  55520. R16F: number;
  55521. RG16F: number;
  55522. RGB16F: number;
  55523. RED: number;
  55524. RG: number;
  55525. R8: number;
  55526. RG8: number;
  55527. UNSIGNED_INT_24_8: number;
  55528. DEPTH24_STENCIL8: number;
  55529. /* Multiple Render Targets */
  55530. drawBuffers(buffers: number[]): void;
  55531. readBuffer(src: number): void;
  55532. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55533. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55534. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55535. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55536. // Occlusion Query
  55537. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55538. ANY_SAMPLES_PASSED: number;
  55539. QUERY_RESULT_AVAILABLE: number;
  55540. QUERY_RESULT: number;
  55541. }
  55542. interface WebGLBuffer {
  55543. references: number;
  55544. capacity: number;
  55545. is32Bits: boolean;
  55546. }
  55547. interface WebGLProgram {
  55548. transformFeedback?: WebGLTransformFeedback | null; private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55549. }
  55550. interface EXT_disjoint_timer_query {
  55551. QUERY_COUNTER_BITS_EXT: number;
  55552. TIME_ELAPSED_EXT: number;
  55553. TIMESTAMP_EXT: number;
  55554. GPU_DISJOINT_EXT: number;
  55555. QUERY_RESULT_EXT: number;
  55556. QUERY_RESULT_AVAILABLE_EXT: number;
  55557. queryCounterEXT(query: WebGLQuery, target: number): void;
  55558. createQueryEXT(): WebGLQuery;
  55559. beginQueryEXT(target: number, query: WebGLQuery): void;
  55560. endQueryEXT(target: number): void;
  55561. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55562. deleteQueryEXT(query: WebGLQuery): void;
  55563. }
  55564. interface WebGLUniformLocation { currentState: any;
  55565. }
  55566. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55567. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55568. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55569. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55570. interface WebGLRenderingContext {
  55571. readonly RASTERIZER_DISCARD: number;
  55572. readonly DEPTH_COMPONENT24: number;
  55573. readonly TEXTURE_3D: number;
  55574. readonly TEXTURE_2D_ARRAY: number;
  55575. readonly TEXTURE_COMPARE_FUNC: number;
  55576. readonly TEXTURE_COMPARE_MODE: number;
  55577. readonly COMPARE_REF_TO_TEXTURE: number;
  55578. readonly TEXTURE_WRAP_R: number;
  55579. readonly HALF_FLOAT: number;
  55580. readonly RGB8: number;
  55581. readonly RED_INTEGER: number;
  55582. readonly RG_INTEGER: number;
  55583. readonly RGB_INTEGER: number;
  55584. readonly RGBA_INTEGER: number;
  55585. readonly R8_SNORM: number;
  55586. readonly RG8_SNORM: number;
  55587. readonly RGB8_SNORM: number;
  55588. readonly RGBA8_SNORM: number;
  55589. readonly R8I: number;
  55590. readonly RG8I: number;
  55591. readonly RGB8I: number;
  55592. readonly RGBA8I: number;
  55593. readonly R8UI: number;
  55594. readonly RG8UI: number;
  55595. readonly RGB8UI: number;
  55596. readonly RGBA8UI: number;
  55597. readonly R16I: number;
  55598. readonly RG16I: number;
  55599. readonly RGB16I: number;
  55600. readonly RGBA16I: number;
  55601. readonly R16UI: number;
  55602. readonly RG16UI: number;
  55603. readonly RGB16UI: number;
  55604. readonly RGBA16UI: number;
  55605. readonly R32I: number;
  55606. readonly RG32I: number;
  55607. readonly RGB32I: number;
  55608. readonly RGBA32I: number;
  55609. readonly R32UI: number;
  55610. readonly RG32UI: number;
  55611. readonly RGB32UI: number;
  55612. readonly RGBA32UI: number;
  55613. readonly RGB10_A2UI: number;
  55614. readonly R11F_G11F_B10F: number;
  55615. readonly RGB9_E5: number;
  55616. readonly RGB10_A2: number;
  55617. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55618. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55619. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55620. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55621. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55622. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55623. 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;
  55624. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55625. readonly TRANSFORM_FEEDBACK: number;
  55626. readonly INTERLEAVED_ATTRIBS: number;
  55627. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55628. createTransformFeedback(): WebGLTransformFeedback;
  55629. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55630. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55631. beginTransformFeedback(primitiveMode: number): void;
  55632. endTransformFeedback(): void;
  55633. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55634. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55635. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55636. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55637. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55638. }
  55639. interface ImageBitmap {
  55640. readonly width: number;
  55641. readonly height: number;
  55642. close(): void;
  55643. }
  55644. interface WebGLQuery extends WebGLObject {
  55645. }
  55646. declare var WebGLQuery: {
  55647. prototype: WebGLQuery;
  55648. new(): WebGLQuery;
  55649. };
  55650. interface WebGLSampler extends WebGLObject {
  55651. }
  55652. declare var WebGLSampler: {
  55653. prototype: WebGLSampler;
  55654. new(): WebGLSampler;
  55655. };
  55656. interface WebGLSync extends WebGLObject {
  55657. }
  55658. declare var WebGLSync: {
  55659. prototype: WebGLSync;
  55660. new(): WebGLSync;
  55661. };
  55662. interface WebGLTransformFeedback extends WebGLObject {
  55663. }
  55664. declare var WebGLTransformFeedback: {
  55665. prototype: WebGLTransformFeedback;
  55666. new(): WebGLTransformFeedback;
  55667. };
  55668. interface WebGLVertexArrayObject extends WebGLObject {
  55669. }
  55670. declare var WebGLVertexArrayObject: {
  55671. prototype: WebGLVertexArrayObject;
  55672. new(): WebGLVertexArrayObject;
  55673. };
  55674. // Type definitions for WebVR API
  55675. // Project: https://w3c.github.io/webvr/
  55676. // Definitions by: six a <https://github.com/lostfictions>
  55677. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55678. interface VRDisplay extends EventTarget {
  55679. /**
  55680. * Dictionary of capabilities describing the VRDisplay.
  55681. */
  55682. readonly capabilities: VRDisplayCapabilities;
  55683. /**
  55684. * z-depth defining the far plane of the eye view frustum
  55685. * enables mapping of values in the render target depth
  55686. * attachment to scene coordinates. Initially set to 10000.0.
  55687. */
  55688. depthFar: number;
  55689. /**
  55690. * z-depth defining the near plane of the eye view frustum
  55691. * enables mapping of values in the render target depth
  55692. * attachment to scene coordinates. Initially set to 0.01.
  55693. */
  55694. depthNear: number;
  55695. /**
  55696. * An identifier for this distinct VRDisplay. Used as an
  55697. * association point in the Gamepad API.
  55698. */
  55699. readonly displayId: number;
  55700. /**
  55701. * A display name, a user-readable name identifying it.
  55702. */
  55703. readonly displayName: string;
  55704. readonly isConnected: boolean;
  55705. readonly isPresenting: boolean;
  55706. /**
  55707. * If this VRDisplay supports room-scale experiences, the optional
  55708. * stage attribute contains details on the room-scale parameters.
  55709. */
  55710. readonly stageParameters: VRStageParameters | null;
  55711. /**
  55712. * Passing the value returned by `requestAnimationFrame` to
  55713. * `cancelAnimationFrame` will unregister the callback.
  55714. * @param handle Define the hanle of the request to cancel
  55715. */
  55716. cancelAnimationFrame(handle: number): void;
  55717. /**
  55718. * Stops presenting to the VRDisplay.
  55719. * @returns a promise to know when it stopped
  55720. */
  55721. exitPresent(): Promise<void>;
  55722. /**
  55723. * Return the current VREyeParameters for the given eye.
  55724. * @param whichEye Define the eye we want the parameter for
  55725. * @returns the eye parameters
  55726. */
  55727. getEyeParameters(whichEye: string): VREyeParameters;
  55728. /**
  55729. * Populates the passed VRFrameData with the information required to render
  55730. * the current frame.
  55731. * @param frameData Define the data structure to populate
  55732. * @returns true if ok otherwise false
  55733. */
  55734. getFrameData(frameData: VRFrameData): boolean;
  55735. /**
  55736. * Get the layers currently being presented.
  55737. * @returns the list of VR layers
  55738. */
  55739. getLayers(): VRLayer[];
  55740. /**
  55741. * Return a VRPose containing the future predicted pose of the VRDisplay
  55742. * when the current frame will be presented. The value returned will not
  55743. * change until JavaScript has returned control to the browser.
  55744. *
  55745. * The VRPose will contain the position, orientation, velocity,
  55746. * and acceleration of each of these properties.
  55747. * @returns the pose object
  55748. */
  55749. getPose(): VRPose;
  55750. /**
  55751. * Return the current instantaneous pose of the VRDisplay, with no
  55752. * prediction applied.
  55753. * @returns the current instantaneous pose
  55754. */
  55755. getImmediatePose(): VRPose;
  55756. /**
  55757. * The callback passed to `requestAnimationFrame` will be called
  55758. * any time a new frame should be rendered. When the VRDisplay is
  55759. * presenting the callback will be called at the native refresh
  55760. * rate of the HMD. When not presenting this function acts
  55761. * identically to how window.requestAnimationFrame acts. Content should
  55762. * make no assumptions of frame rate or vsync behavior as the HMD runs
  55763. * asynchronously from other displays and at differing refresh rates.
  55764. * @param callback Define the eaction to run next frame
  55765. * @returns the request handle it
  55766. */
  55767. requestAnimationFrame(callback: FrameRequestCallback): number;
  55768. /**
  55769. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  55770. * Repeat calls while already presenting will update the VRLayers being displayed.
  55771. * @param layers Define the list of layer to present
  55772. * @returns a promise to know when the request has been fulfilled
  55773. */
  55774. requestPresent(layers: VRLayer[]): Promise<void>;
  55775. /**
  55776. * Reset the pose for this display, treating its current position and
  55777. * orientation as the "origin/zero" values. VRPose.position,
  55778. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  55779. * updated when calling resetPose(). This should be called in only
  55780. * sitting-space experiences.
  55781. */
  55782. resetPose(): void;
  55783. /**
  55784. * The VRLayer provided to the VRDisplay will be captured and presented
  55785. * in the HMD. Calling this function has the same effect on the source
  55786. * canvas as any other operation that uses its source image, and canvases
  55787. * created without preserveDrawingBuffer set to true will be cleared.
  55788. * @param pose Define the pose to submit
  55789. */
  55790. submitFrame(pose?: VRPose): void;
  55791. }
  55792. declare var VRDisplay: {
  55793. prototype: VRDisplay;
  55794. new(): VRDisplay;
  55795. };
  55796. interface VRLayer {
  55797. leftBounds?: number[] | Float32Array | null;
  55798. rightBounds?: number[] | Float32Array | null;
  55799. source?: HTMLCanvasElement | null;
  55800. }
  55801. interface VRDisplayCapabilities {
  55802. readonly canPresent: boolean;
  55803. readonly hasExternalDisplay: boolean;
  55804. readonly hasOrientation: boolean;
  55805. readonly hasPosition: boolean;
  55806. readonly maxLayers: number;
  55807. }
  55808. interface VREyeParameters {
  55809. /** @deprecated */
  55810. readonly fieldOfView: VRFieldOfView;
  55811. readonly offset: Float32Array;
  55812. readonly renderHeight: number;
  55813. readonly renderWidth: number;
  55814. }
  55815. interface VRFieldOfView {
  55816. readonly downDegrees: number;
  55817. readonly leftDegrees: number;
  55818. readonly rightDegrees: number;
  55819. readonly upDegrees: number;
  55820. }
  55821. interface VRFrameData {
  55822. readonly leftProjectionMatrix: Float32Array;
  55823. readonly leftViewMatrix: Float32Array;
  55824. readonly pose: VRPose;
  55825. readonly rightProjectionMatrix: Float32Array;
  55826. readonly rightViewMatrix: Float32Array;
  55827. readonly timestamp: number;
  55828. }
  55829. interface VRPose {
  55830. readonly angularAcceleration: Float32Array | null;
  55831. readonly angularVelocity: Float32Array | null;
  55832. readonly linearAcceleration: Float32Array | null;
  55833. readonly linearVelocity: Float32Array | null;
  55834. readonly orientation: Float32Array | null;
  55835. readonly position: Float32Array | null;
  55836. readonly timestamp: number;
  55837. }
  55838. interface VRStageParameters {
  55839. sittingToStandingTransform?: Float32Array;
  55840. sizeX?: number;
  55841. sizeY?: number;
  55842. }
  55843. interface Navigator {
  55844. getVRDisplays(): Promise<VRDisplay[]>;
  55845. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  55846. }
  55847. interface Window {
  55848. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  55849. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  55850. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  55851. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55852. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55853. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  55854. }
  55855. interface Gamepad {
  55856. readonly displayId: number;
  55857. }
  55858. interface XRDevice {
  55859. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  55860. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  55861. }
  55862. interface XRSession {
  55863. getInputSources(): Array<any>;
  55864. baseLayer: XRWebGLLayer;
  55865. requestFrameOfReference(type: string): Promise<void>;
  55866. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  55867. end(): Promise<void>;
  55868. requestAnimationFrame: Function;
  55869. addEventListener: Function;
  55870. }
  55871. interface XRSessionCreationOptions {
  55872. outputContext?: WebGLRenderingContext | null;
  55873. immersive?: boolean;
  55874. environmentIntegration?: boolean;
  55875. }
  55876. interface XRLayer {
  55877. getViewport: Function;
  55878. framebufferWidth: number;
  55879. framebufferHeight: number;
  55880. }
  55881. interface XRView {
  55882. projectionMatrix: Float32Array;
  55883. }
  55884. interface XRFrame {
  55885. getDevicePose: Function;
  55886. getInputPose: Function;
  55887. views: Array<XRView>;
  55888. baseLayer: XRLayer;
  55889. }
  55890. interface XRFrameOfReference {
  55891. }
  55892. interface XRWebGLLayer extends XRLayer {
  55893. framebuffer: WebGLFramebuffer;
  55894. }
  55895. declare var XRWebGLLayer: {
  55896. prototype: XRWebGLLayer;
  55897. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  55898. };
  55899. declare module BABYLON.GUI {
  55900. /**
  55901. * Class used to specific a value and its associated unit
  55902. */
  55903. export class ValueAndUnit {
  55904. /** defines the unit to store */
  55905. unit: number;
  55906. /** defines a boolean indicating if the value can be negative */
  55907. negativeValueAllowed: boolean;
  55908. private _value;
  55909. private _originalUnit;
  55910. /**
  55911. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  55912. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  55913. */
  55914. ignoreAdaptiveScaling: boolean;
  55915. /**
  55916. * Creates a new ValueAndUnit
  55917. * @param value defines the value to store
  55918. * @param unit defines the unit to store
  55919. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  55920. */
  55921. constructor(value: number,
  55922. /** defines the unit to store */
  55923. unit?: number,
  55924. /** defines a boolean indicating if the value can be negative */
  55925. negativeValueAllowed?: boolean);
  55926. /** Gets a boolean indicating if the value is a percentage */
  55927. readonly isPercentage: boolean;
  55928. /** Gets a boolean indicating if the value is store as pixel */
  55929. readonly isPixel: boolean;
  55930. /** Gets direct internal value */
  55931. readonly internalValue: number;
  55932. /**
  55933. * Gets value as pixel
  55934. * @param host defines the root host
  55935. * @param refValue defines the reference value for percentages
  55936. * @returns the value as pixel
  55937. */
  55938. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  55939. /**
  55940. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  55941. * @param value defines the value to store
  55942. * @param unit defines the unit to store
  55943. * @returns the current ValueAndUnit
  55944. */
  55945. updateInPlace(value: number, unit?: number): ValueAndUnit;
  55946. /**
  55947. * Gets the value accordingly to its unit
  55948. * @param host defines the root host
  55949. * @returns the value
  55950. */
  55951. getValue(host: AdvancedDynamicTexture): number;
  55952. /**
  55953. * Gets a string representation of the value
  55954. * @param host defines the root host
  55955. * @param decimals defines an optional number of decimals to display
  55956. * @returns a string
  55957. */
  55958. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  55959. /**
  55960. * Store a value parsed from a string
  55961. * @param source defines the source string
  55962. * @returns true if the value was successfully parsed
  55963. */
  55964. fromString(source: string | number): boolean;
  55965. private static _Regex;
  55966. private static _UNITMODE_PERCENTAGE;
  55967. private static _UNITMODE_PIXEL;
  55968. /** UNITMODE_PERCENTAGE */
  55969. static readonly UNITMODE_PERCENTAGE: number;
  55970. /** UNITMODE_PIXEL */
  55971. static readonly UNITMODE_PIXEL: number;
  55972. }
  55973. }
  55974. declare module BABYLON.GUI {
  55975. /**
  55976. * Define a style used by control to automatically setup properties based on a template.
  55977. * Only support font related properties so far
  55978. */
  55979. export class Style implements BABYLON.IDisposable {
  55980. private _fontFamily;
  55981. private _fontStyle;
  55982. private _fontWeight;
  55983. /** @hidden */ host: AdvancedDynamicTexture;
  55984. /** @hidden */ fontSize: ValueAndUnit;
  55985. /**
  55986. * BABYLON.Observable raised when the style values are changed
  55987. */
  55988. onChangedObservable: BABYLON.Observable<Style>;
  55989. /**
  55990. * Creates a new style object
  55991. * @param host defines the AdvancedDynamicTexture which hosts this style
  55992. */
  55993. constructor(host: AdvancedDynamicTexture);
  55994. /**
  55995. * Gets or sets the font size
  55996. */
  55997. fontSize: string | number;
  55998. /**
  55999. * Gets or sets the font family
  56000. */
  56001. fontFamily: string;
  56002. /**
  56003. * Gets or sets the font style
  56004. */
  56005. fontStyle: string;
  56006. /** Gets or sets font weight */
  56007. fontWeight: string;
  56008. /** Dispose all associated resources */
  56009. dispose(): void;
  56010. }
  56011. }
  56012. declare module BABYLON.GUI {
  56013. /**
  56014. * Class used to transport BABYLON.Vector2 information for pointer events
  56015. */
  56016. export class Vector2WithInfo extends BABYLON.Vector2 {
  56017. /** defines the current mouse button index */
  56018. buttonIndex: number;
  56019. /**
  56020. * Creates a new Vector2WithInfo
  56021. * @param source defines the vector2 data to transport
  56022. * @param buttonIndex defines the current mouse button index
  56023. */
  56024. constructor(source: BABYLON.Vector2,
  56025. /** defines the current mouse button index */
  56026. buttonIndex?: number);
  56027. }
  56028. /** Class used to provide 2D matrix features */
  56029. export class Matrix2D {
  56030. /** Gets the internal array of 6 floats used to store matrix data */
  56031. m: Float32Array;
  56032. /**
  56033. * Creates a new matrix
  56034. * @param m00 defines value for (0, 0)
  56035. * @param m01 defines value for (0, 1)
  56036. * @param m10 defines value for (1, 0)
  56037. * @param m11 defines value for (1, 1)
  56038. * @param m20 defines value for (2, 0)
  56039. * @param m21 defines value for (2, 1)
  56040. */
  56041. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  56042. /**
  56043. * Fills the matrix from direct values
  56044. * @param m00 defines value for (0, 0)
  56045. * @param m01 defines value for (0, 1)
  56046. * @param m10 defines value for (1, 0)
  56047. * @param m11 defines value for (1, 1)
  56048. * @param m20 defines value for (2, 0)
  56049. * @param m21 defines value for (2, 1)
  56050. * @returns the current modified matrix
  56051. */
  56052. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  56053. /**
  56054. * Gets matrix determinant
  56055. * @returns the determinant
  56056. */
  56057. determinant(): number;
  56058. /**
  56059. * Inverses the matrix and stores it in a target matrix
  56060. * @param result defines the target matrix
  56061. * @returns the current matrix
  56062. */
  56063. invertToRef(result: Matrix2D): Matrix2D;
  56064. /**
  56065. * Multiplies the current matrix with another one
  56066. * @param other defines the second operand
  56067. * @param result defines the target matrix
  56068. * @returns the current matrix
  56069. */
  56070. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  56071. /**
  56072. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  56073. * @param x defines the x coordinate to transform
  56074. * @param y defines the x coordinate to transform
  56075. * @param result defines the target vector2
  56076. * @returns the current matrix
  56077. */
  56078. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  56079. /**
  56080. * Creates an identity matrix
  56081. * @returns a new matrix
  56082. */
  56083. static Identity(): Matrix2D;
  56084. /**
  56085. * Creates a translation matrix and stores it in a target matrix
  56086. * @param x defines the x coordinate of the translation
  56087. * @param y defines the y coordinate of the translation
  56088. * @param result defines the target matrix
  56089. */
  56090. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  56091. /**
  56092. * Creates a scaling matrix and stores it in a target matrix
  56093. * @param x defines the x coordinate of the scaling
  56094. * @param y defines the y coordinate of the scaling
  56095. * @param result defines the target matrix
  56096. */
  56097. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  56098. /**
  56099. * Creates a rotation matrix and stores it in a target matrix
  56100. * @param angle defines the rotation angle
  56101. * @param result defines the target matrix
  56102. */
  56103. static RotationToRef(angle: number, result: Matrix2D): void;
  56104. private static _TempPreTranslationMatrix;
  56105. private static _TempPostTranslationMatrix;
  56106. private static _TempRotationMatrix;
  56107. private static _TempScalingMatrix;
  56108. private static _TempCompose0;
  56109. private static _TempCompose1;
  56110. private static _TempCompose2;
  56111. /**
  56112. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  56113. * @param tx defines the x coordinate of the translation
  56114. * @param ty defines the y coordinate of the translation
  56115. * @param angle defines the rotation angle
  56116. * @param scaleX defines the x coordinate of the scaling
  56117. * @param scaleY defines the y coordinate of the scaling
  56118. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  56119. * @param result defines the target matrix
  56120. */
  56121. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  56122. }
  56123. }
  56124. declare module BABYLON.GUI {
  56125. /**
  56126. * Class used to store 2D control sizes
  56127. */
  56128. export class Measure {
  56129. /** defines left coordinate */
  56130. left: number;
  56131. /** defines top coordinate */
  56132. top: number;
  56133. /** defines width dimension */
  56134. width: number;
  56135. /** defines height dimension */
  56136. height: number;
  56137. /**
  56138. * Creates a new measure
  56139. * @param left defines left coordinate
  56140. * @param top defines top coordinate
  56141. * @param width defines width dimension
  56142. * @param height defines height dimension
  56143. */
  56144. constructor(
  56145. /** defines left coordinate */
  56146. left: number,
  56147. /** defines top coordinate */
  56148. top: number,
  56149. /** defines width dimension */
  56150. width: number,
  56151. /** defines height dimension */
  56152. height: number);
  56153. /**
  56154. * Copy from another measure
  56155. * @param other defines the other measure to copy from
  56156. */
  56157. copyFrom(other: Measure): void;
  56158. /**
  56159. * Copy from a group of 4 floats
  56160. * @param left defines left coordinate
  56161. * @param top defines top coordinate
  56162. * @param width defines width dimension
  56163. * @param height defines height dimension
  56164. */
  56165. copyFromFloats(left: number, top: number, width: number, height: number): void;
  56166. /**
  56167. * Computes the axis aligned bounding box measure for two given measures
  56168. * @param a Input measure
  56169. * @param b Input measure
  56170. * @param result the resulting bounding measure
  56171. */
  56172. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  56173. /**
  56174. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  56175. * @param transform the matrix to transform the measure before computing the AABB
  56176. * @param result the resulting AABB
  56177. */
  56178. transformToRef(transform: Matrix2D, result: Measure): void;
  56179. /**
  56180. * Check equality between this measure and another one
  56181. * @param other defines the other measures
  56182. * @returns true if both measures are equals
  56183. */
  56184. isEqualsTo(other: Measure): boolean;
  56185. /**
  56186. * Creates an empty measure
  56187. * @returns a new measure
  56188. */
  56189. static Empty(): Measure;
  56190. }
  56191. }
  56192. declare module BABYLON.GUI {
  56193. /**
  56194. * Interface used to define a control that can receive focus
  56195. */
  56196. export interface IFocusableControl {
  56197. /**
  56198. * Function called when the control receives the focus
  56199. */
  56200. onFocus(): void;
  56201. /**
  56202. * Function called when the control loses the focus
  56203. */
  56204. onBlur(): void;
  56205. /**
  56206. * Function called to let the control handle keyboard events
  56207. * @param evt defines the current keyboard event
  56208. */
  56209. processKeyboard(evt: KeyboardEvent): void;
  56210. /**
  56211. * Function called to get the list of controls that should not steal the focus from this control
  56212. * @returns an array of controls
  56213. */
  56214. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  56215. }
  56216. /**
  56217. * Class used to create texture to support 2D GUI elements
  56218. * @see http://doc.babylonjs.com/how_to/gui
  56219. */
  56220. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  56221. private _isDirty;
  56222. private _renderObserver;
  56223. private _resizeObserver;
  56224. private _preKeyboardObserver;
  56225. private _pointerMoveObserver;
  56226. private _pointerObserver;
  56227. private _canvasPointerOutObserver;
  56228. private _background;
  56229. /** @hidden */ rootContainer: Container;
  56230. /** @hidden */ lastPickedControl: Control;
  56231. /** @hidden */ lastControlOver: {
  56232. [pointerId: number]: Control;
  56233. };
  56234. /** @hidden */ lastControlDown: {
  56235. [pointerId: number]: Control;
  56236. };
  56237. /** @hidden */ capturingControl: {
  56238. [pointerId: number]: Control;
  56239. };
  56240. /** @hidden */ shouldBlockPointer: boolean;
  56241. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  56242. /** @hidden */ linkedControls: Control[];
  56243. private _isFullscreen;
  56244. private _fullscreenViewport;
  56245. private _idealWidth;
  56246. private _idealHeight;
  56247. private _useSmallestIdeal;
  56248. private _renderAtIdealSize;
  56249. private _focusedControl;
  56250. private _blockNextFocusCheck;
  56251. private _renderScale;
  56252. private _rootCanvas;
  56253. private _cursorChanged;
  56254. /**
  56255. * Define type to string to ensure compatibility across browsers
  56256. * Safari doesn't support DataTransfer constructor
  56257. */
  56258. private _clipboardData;
  56259. /**
  56260. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  56261. */
  56262. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  56263. /**
  56264. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  56265. */
  56266. onControlPickedObservable: BABYLON.Observable<Control>;
  56267. /**
  56268. * BABYLON.Observable event triggered before layout is evaluated
  56269. */
  56270. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56271. /**
  56272. * BABYLON.Observable event triggered after the layout was evaluated
  56273. */
  56274. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56275. /**
  56276. * BABYLON.Observable event triggered before the texture is rendered
  56277. */
  56278. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56279. /**
  56280. * BABYLON.Observable event triggered after the texture was rendered
  56281. */
  56282. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56283. /**
  56284. * Gets or sets a boolean defining if alpha is stored as premultiplied
  56285. */
  56286. premulAlpha: boolean;
  56287. /**
  56288. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  56289. * Useful when you want more antialiasing
  56290. */
  56291. renderScale: number;
  56292. /** Gets or sets the background color */
  56293. background: string;
  56294. /**
  56295. * Gets or sets the ideal width used to design controls.
  56296. * The GUI will then rescale everything accordingly
  56297. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56298. */
  56299. idealWidth: number;
  56300. /**
  56301. * Gets or sets the ideal height used to design controls.
  56302. * The GUI will then rescale everything accordingly
  56303. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56304. */
  56305. idealHeight: number;
  56306. /**
  56307. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  56308. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56309. */
  56310. useSmallestIdeal: boolean;
  56311. /**
  56312. * Gets or sets a boolean indicating if adaptive scaling must be used
  56313. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56314. */
  56315. renderAtIdealSize: boolean;
  56316. /**
  56317. * Gets the underlying layer used to render the texture when in fullscreen mode
  56318. */
  56319. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  56320. /**
  56321. * Gets the root container control
  56322. */
  56323. readonly rootContainer: Container;
  56324. /**
  56325. * Returns an array containing the root container.
  56326. * This is mostly used to let the Inspector introspects the ADT
  56327. * @returns an array containing the rootContainer
  56328. */
  56329. getChildren(): Array<Container>;
  56330. /**
  56331. * Will return all controls that are inside this texture
  56332. * @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
  56333. * @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
  56334. * @return all child controls
  56335. */
  56336. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56337. /**
  56338. * Gets or sets the current focused control
  56339. */
  56340. focusedControl: BABYLON.Nullable<IFocusableControl>;
  56341. /**
  56342. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  56343. */
  56344. isForeground: boolean;
  56345. /**
  56346. * Gets or set information about clipboardData
  56347. */
  56348. clipboardData: string;
  56349. /**
  56350. * Creates a new AdvancedDynamicTexture
  56351. * @param name defines the name of the texture
  56352. * @param width defines the width of the texture
  56353. * @param height defines the height of the texture
  56354. * @param scene defines the hosting scene
  56355. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  56356. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  56357. */
  56358. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  56359. /**
  56360. * Get the current class name of the texture useful for serialization or dynamic coding.
  56361. * @returns "AdvancedDynamicTexture"
  56362. */
  56363. getClassName(): string;
  56364. /**
  56365. * Function used to execute a function on all controls
  56366. * @param func defines the function to execute
  56367. * @param container defines the container where controls belong. If null the root container will be used
  56368. */
  56369. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  56370. private _useInvalidateRectOptimization;
  56371. /**
  56372. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  56373. */
  56374. useInvalidateRectOptimization: boolean;
  56375. private _invalidatedRectangle;
  56376. /**
  56377. * Invalidates a rectangle area on the gui texture
  56378. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  56379. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  56380. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  56381. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  56382. */
  56383. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  56384. /**
  56385. * Marks the texture as dirty forcing a complete update
  56386. */
  56387. markAsDirty(): void;
  56388. /**
  56389. * Helper function used to create a new style
  56390. * @returns a new style
  56391. * @see http://doc.babylonjs.com/how_to/gui#styles
  56392. */
  56393. createStyle(): Style;
  56394. /**
  56395. * Adds a new control to the root container
  56396. * @param control defines the control to add
  56397. * @returns the current texture
  56398. */
  56399. addControl(control: Control): AdvancedDynamicTexture;
  56400. /**
  56401. * Removes a control from the root container
  56402. * @param control defines the control to remove
  56403. * @returns the current texture
  56404. */
  56405. removeControl(control: Control): AdvancedDynamicTexture;
  56406. /**
  56407. * Release all resources
  56408. */
  56409. dispose(): void;
  56410. private _onResize;
  56411. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  56412. /**
  56413. * Get screen coordinates for a vector3
  56414. * @param position defines the position to project
  56415. * @param worldMatrix defines the world matrix to use
  56416. * @returns the projected position
  56417. */
  56418. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  56419. private _checkUpdate;
  56420. private _clearMeasure;
  56421. private _render;
  56422. /** @hidden */ changeCursor(cursor: string): void;
  56423. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  56424. private _doPicking;
  56425. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  56426. [pointerId: number]: Control;
  56427. }, control: Control): void;
  56428. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  56429. /** Attach to all scene events required to support pointer events */
  56430. attach(): void;
  56431. /** @hidden */
  56432. private onClipboardCopy;
  56433. /** @hidden */
  56434. private onClipboardCut;
  56435. /** @hidden */
  56436. private onClipboardPaste;
  56437. /**
  56438. * Register the clipboard Events onto the canvas
  56439. */
  56440. registerClipboardEvents(): void;
  56441. /**
  56442. * Unregister the clipboard Events from the canvas
  56443. */
  56444. unRegisterClipboardEvents(): void;
  56445. /**
  56446. * Connect the texture to a hosting mesh to enable interactions
  56447. * @param mesh defines the mesh to attach to
  56448. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  56449. */
  56450. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  56451. /**
  56452. * Move the focus to a specific control
  56453. * @param control defines the control which will receive the focus
  56454. */
  56455. moveFocusToControl(control: IFocusableControl): void;
  56456. private _manageFocus;
  56457. private _attachToOnPointerOut;
  56458. /**
  56459. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  56460. * @param mesh defines the mesh which will receive the texture
  56461. * @param width defines the texture width (1024 by default)
  56462. * @param height defines the texture height (1024 by default)
  56463. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  56464. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  56465. * @returns a new AdvancedDynamicTexture
  56466. */
  56467. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  56468. /**
  56469. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  56470. * In this mode the texture will rely on a layer for its rendering.
  56471. * This allows it to be treated like any other layer.
  56472. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  56473. * LayerMask is set through advancedTexture.layer.layerMask
  56474. * @param name defines name for the texture
  56475. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  56476. * @param scene defines the hsoting scene
  56477. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  56478. * @returns a new AdvancedDynamicTexture
  56479. */
  56480. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  56481. }
  56482. }
  56483. declare module BABYLON.GUI {
  56484. /**
  56485. * Root class used for all 2D controls
  56486. * @see http://doc.babylonjs.com/how_to/gui#controls
  56487. */
  56488. export class Control {
  56489. /** defines the name of the control */
  56490. name?: string | undefined;
  56491. /**
  56492. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  56493. */
  56494. static AllowAlphaInheritance: boolean;
  56495. private _alpha;
  56496. private _alphaSet;
  56497. private _zIndex;
  56498. /** @hidden */ host: AdvancedDynamicTexture;
  56499. /** Gets or sets the control parent */
  56500. parent: BABYLON.Nullable<Container>;
  56501. /** @hidden */ currentMeasure: Measure;
  56502. private _fontFamily;
  56503. private _fontStyle;
  56504. private _fontWeight;
  56505. private _fontSize;
  56506. private _font;
  56507. /** @hidden */ width: ValueAndUnit;
  56508. /** @hidden */ height: ValueAndUnit;
  56509. /** @hidden */
  56510. protected _fontOffset: {
  56511. ascent: number;
  56512. height: number;
  56513. descent: number;
  56514. };
  56515. private _color;
  56516. private _style;
  56517. private _styleObserver;
  56518. /** @hidden */
  56519. protected _horizontalAlignment: number;
  56520. /** @hidden */
  56521. protected _verticalAlignment: number;
  56522. /** @hidden */
  56523. protected _isDirty: boolean;
  56524. /** @hidden */
  56525. protected _wasDirty: boolean;
  56526. /** @hidden */ tempParentMeasure: Measure;
  56527. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  56528. /** @hidden */
  56529. protected _cachedParentMeasure: Measure;
  56530. private _paddingLeft;
  56531. private _paddingRight;
  56532. private _paddingTop;
  56533. private _paddingBottom;
  56534. /** @hidden */ left: ValueAndUnit;
  56535. /** @hidden */ top: ValueAndUnit;
  56536. private _scaleX;
  56537. private _scaleY;
  56538. private _rotation;
  56539. private _transformCenterX;
  56540. private _transformCenterY;
  56541. /** @hidden */ transformMatrix: Matrix2D;
  56542. /** @hidden */
  56543. protected _invertTransformMatrix: Matrix2D;
  56544. /** @hidden */
  56545. protected _transformedPosition: BABYLON.Vector2;
  56546. private _isMatrixDirty;
  56547. private _cachedOffsetX;
  56548. private _cachedOffsetY;
  56549. private _isVisible;
  56550. private _isHighlighted;
  56551. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56552. private _fontSet;
  56553. private _dummyVector2;
  56554. private _downCount;
  56555. private _enterCount;
  56556. private _doNotRender;
  56557. private _downPointerIds;
  56558. protected _isEnabled: boolean;
  56559. protected _disabledColor: string;
  56560. /** @hidden */
  56561. protected _rebuildLayout: boolean;
  56562. /** @hidden */ isClipped: boolean;
  56563. /** @hidden */ tag: any;
  56564. /**
  56565. * 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
  56566. */
  56567. uniqueId: number;
  56568. /**
  56569. * Gets or sets an object used to store user defined information for the node
  56570. */
  56571. metadata: any;
  56572. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  56573. isHitTestVisible: boolean;
  56574. /** Gets or sets a boolean indicating if the control can block pointer events */
  56575. isPointerBlocker: boolean;
  56576. /** Gets or sets a boolean indicating if the control can be focusable */
  56577. isFocusInvisible: boolean;
  56578. /**
  56579. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  56580. * 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
  56581. */
  56582. clipChildren: boolean;
  56583. /**
  56584. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  56585. */
  56586. useBitmapCache: boolean;
  56587. private _cacheData;
  56588. private _shadowOffsetX;
  56589. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  56590. shadowOffsetX: number;
  56591. private _shadowOffsetY;
  56592. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  56593. shadowOffsetY: number;
  56594. private _shadowBlur;
  56595. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  56596. shadowBlur: number;
  56597. private _shadowColor;
  56598. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  56599. shadowColor: string;
  56600. /** Gets or sets the cursor to use when the control is hovered */
  56601. hoverCursor: string;
  56602. /** @hidden */
  56603. protected _linkOffsetX: ValueAndUnit;
  56604. /** @hidden */
  56605. protected _linkOffsetY: ValueAndUnit;
  56606. /** Gets the control type name */
  56607. readonly typeName: string;
  56608. /**
  56609. * Get the current class name of the control.
  56610. * @returns current class name
  56611. */
  56612. getClassName(): string;
  56613. /**
  56614. * An event triggered when the pointer move over the control.
  56615. */
  56616. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  56617. /**
  56618. * An event triggered when the pointer move out of the control.
  56619. */
  56620. onPointerOutObservable: BABYLON.Observable<Control>;
  56621. /**
  56622. * An event triggered when the pointer taps the control
  56623. */
  56624. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  56625. /**
  56626. * An event triggered when pointer up
  56627. */
  56628. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  56629. /**
  56630. * An event triggered when a control is clicked on
  56631. */
  56632. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  56633. /**
  56634. * An event triggered when pointer enters the control
  56635. */
  56636. onPointerEnterObservable: BABYLON.Observable<Control>;
  56637. /**
  56638. * An event triggered when the control is marked as dirty
  56639. */
  56640. onDirtyObservable: BABYLON.Observable<Control>;
  56641. /**
  56642. * An event triggered before drawing the control
  56643. */
  56644. onBeforeDrawObservable: BABYLON.Observable<Control>;
  56645. /**
  56646. * An event triggered after the control was drawn
  56647. */
  56648. onAfterDrawObservable: BABYLON.Observable<Control>;
  56649. /**
  56650. * Get the hosting AdvancedDynamicTexture
  56651. */
  56652. readonly host: AdvancedDynamicTexture;
  56653. /** Gets or set information about font offsets (used to render and align text) */
  56654. fontOffset: {
  56655. ascent: number;
  56656. height: number;
  56657. descent: number;
  56658. };
  56659. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  56660. alpha: number;
  56661. /**
  56662. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  56663. */
  56664. isHighlighted: boolean;
  56665. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  56666. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56667. */
  56668. scaleX: number;
  56669. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  56670. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56671. */
  56672. scaleY: number;
  56673. /** Gets or sets the rotation angle (0 by default)
  56674. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56675. */
  56676. rotation: number;
  56677. /** Gets or sets the transformation center on Y axis (0 by default)
  56678. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56679. */
  56680. transformCenterY: number;
  56681. /** Gets or sets the transformation center on X axis (0 by default)
  56682. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56683. */
  56684. transformCenterX: number;
  56685. /**
  56686. * Gets or sets the horizontal alignment
  56687. * @see http://doc.babylonjs.com/how_to/gui#alignments
  56688. */
  56689. horizontalAlignment: number;
  56690. /**
  56691. * Gets or sets the vertical alignment
  56692. * @see http://doc.babylonjs.com/how_to/gui#alignments
  56693. */
  56694. verticalAlignment: number;
  56695. /**
  56696. * Gets or sets control width
  56697. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56698. */
  56699. width: string | number;
  56700. /**
  56701. * Gets control width in pixel
  56702. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56703. */
  56704. readonly widthInPixels: number;
  56705. /**
  56706. * Gets or sets control height
  56707. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56708. */
  56709. height: string | number;
  56710. /**
  56711. * Gets control height in pixel
  56712. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56713. */
  56714. readonly heightInPixels: number;
  56715. /** Gets or set font family */
  56716. fontFamily: string;
  56717. /** Gets or sets font style */
  56718. fontStyle: string;
  56719. /** Gets or sets font weight */
  56720. fontWeight: string;
  56721. /**
  56722. * Gets or sets style
  56723. * @see http://doc.babylonjs.com/how_to/gui#styles
  56724. */
  56725. style: BABYLON.Nullable<Style>;
  56726. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  56727. /** Gets font size in pixels */
  56728. readonly fontSizeInPixels: number;
  56729. /** Gets or sets font size */
  56730. fontSize: string | number;
  56731. /** Gets or sets foreground color */
  56732. color: string;
  56733. /** Gets or sets z index which is used to reorder controls on the z axis */
  56734. zIndex: number;
  56735. /** Gets or sets a boolean indicating if the control can be rendered */
  56736. notRenderable: boolean;
  56737. /** Gets or sets a boolean indicating if the control is visible */
  56738. isVisible: boolean;
  56739. /** Gets a boolean indicating that the control needs to update its rendering */
  56740. readonly isDirty: boolean;
  56741. /**
  56742. * Gets the current linked mesh (or null if none)
  56743. */
  56744. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56745. /**
  56746. * Gets or sets a value indicating the padding to use on the left of the control
  56747. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56748. */
  56749. paddingLeft: string | number;
  56750. /**
  56751. * Gets a value indicating the padding in pixels to use on the left of the control
  56752. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56753. */
  56754. readonly paddingLeftInPixels: number;
  56755. /**
  56756. * Gets or sets a value indicating the padding to use on the right of the control
  56757. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56758. */
  56759. paddingRight: string | number;
  56760. /**
  56761. * Gets a value indicating the padding in pixels to use on the right of the control
  56762. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56763. */
  56764. readonly paddingRightInPixels: number;
  56765. /**
  56766. * Gets or sets a value indicating the padding to use on the top of the control
  56767. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56768. */
  56769. paddingTop: string | number;
  56770. /**
  56771. * Gets a value indicating the padding in pixels to use on the top of the control
  56772. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56773. */
  56774. readonly paddingTopInPixels: number;
  56775. /**
  56776. * Gets or sets a value indicating the padding to use on the bottom of the control
  56777. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56778. */
  56779. paddingBottom: string | number;
  56780. /**
  56781. * Gets a value indicating the padding in pixels to use on the bottom of the control
  56782. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56783. */
  56784. readonly paddingBottomInPixels: number;
  56785. /**
  56786. * Gets or sets a value indicating the left coordinate of the control
  56787. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56788. */
  56789. left: string | number;
  56790. /**
  56791. * Gets a value indicating the left coordinate in pixels of the control
  56792. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56793. */
  56794. readonly leftInPixels: number;
  56795. /**
  56796. * Gets or sets a value indicating the top coordinate of the control
  56797. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56798. */
  56799. top: string | number;
  56800. /**
  56801. * Gets a value indicating the top coordinate in pixels of the control
  56802. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56803. */
  56804. readonly topInPixels: number;
  56805. /**
  56806. * Gets or sets a value indicating the offset on X axis to the linked mesh
  56807. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56808. */
  56809. linkOffsetX: string | number;
  56810. /**
  56811. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  56812. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56813. */
  56814. readonly linkOffsetXInPixels: number;
  56815. /**
  56816. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  56817. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56818. */
  56819. linkOffsetY: string | number;
  56820. /**
  56821. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  56822. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56823. */
  56824. readonly linkOffsetYInPixels: number;
  56825. /** Gets the center coordinate on X axis */
  56826. readonly centerX: number;
  56827. /** Gets the center coordinate on Y axis */
  56828. readonly centerY: number;
  56829. /** Gets or sets if control is Enabled*/
  56830. isEnabled: boolean;
  56831. /** Gets or sets background color of control if it's disabled*/
  56832. disabledColor: string;
  56833. /**
  56834. * Creates a new control
  56835. * @param name defines the name of the control
  56836. */
  56837. constructor(
  56838. /** defines the name of the control */
  56839. name?: string | undefined);
  56840. /** @hidden */
  56841. protected _getTypeName(): string;
  56842. /**
  56843. * Gets the first ascendant in the hierarchy of the given type
  56844. * @param className defines the required type
  56845. * @returns the ascendant or null if not found
  56846. */
  56847. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  56848. /** @hidden */ resetFontCache(): void;
  56849. /**
  56850. * Determines if a container is an ascendant of the current control
  56851. * @param container defines the container to look for
  56852. * @returns true if the container is one of the ascendant of the control
  56853. */
  56854. isAscendant(container: Control): boolean;
  56855. /**
  56856. * Gets coordinates in local control space
  56857. * @param globalCoordinates defines the coordinates to transform
  56858. * @returns the new coordinates in local space
  56859. */
  56860. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  56861. /**
  56862. * Gets coordinates in local control space
  56863. * @param globalCoordinates defines the coordinates to transform
  56864. * @param result defines the target vector2 where to store the result
  56865. * @returns the current control
  56866. */
  56867. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  56868. /**
  56869. * Gets coordinates in parent local control space
  56870. * @param globalCoordinates defines the coordinates to transform
  56871. * @returns the new coordinates in parent local space
  56872. */
  56873. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  56874. /**
  56875. * Move the current control to a vector3 position projected onto the screen.
  56876. * @param position defines the target position
  56877. * @param scene defines the hosting scene
  56878. */
  56879. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  56880. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  56881. /**
  56882. * Will return all controls that have this control as ascendant
  56883. * @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
  56884. * @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
  56885. * @return all child controls
  56886. */
  56887. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56888. /**
  56889. * Link current control with a target mesh
  56890. * @param mesh defines the mesh to link with
  56891. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56892. */
  56893. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  56894. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  56895. /** @hidden */ offsetLeft(offset: number): void;
  56896. /** @hidden */ offsetTop(offset: number): void;
  56897. /** @hidden */ markMatrixAsDirty(): void;
  56898. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  56899. /** @hidden */ intersectsRect(rect: Measure): boolean;
  56900. /** @hidden */
  56901. protected invalidateRect(): void;
  56902. /** @hidden */ markAsDirty(force?: boolean): void;
  56903. /** @hidden */ markAllAsDirty(): void;
  56904. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  56905. /** @hidden */
  56906. protected _transform(context?: CanvasRenderingContext2D): void;
  56907. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  56908. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  56909. /** @hidden */
  56910. protected _applyStates(context: CanvasRenderingContext2D): void;
  56911. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  56912. /** @hidden */
  56913. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56914. protected _evaluateClippingState(parentMeasure: Measure): void;
  56915. /** @hidden */ measure(): void;
  56916. /** @hidden */
  56917. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56918. /** @hidden */
  56919. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56920. /** @hidden */
  56921. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56922. /** @hidden */
  56923. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  56924. private static _ClipMeasure;
  56925. private _tmpMeasureA;
  56926. private _clip;
  56927. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  56928. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  56929. /**
  56930. * Tests if a given coordinates belong to the current control
  56931. * @param x defines x coordinate to test
  56932. * @param y defines y coordinate to test
  56933. * @returns true if the coordinates are inside the control
  56934. */
  56935. contains(x: number, y: number): boolean;
  56936. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  56937. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  56938. /** @hidden */ onPointerEnter(target: Control): boolean;
  56939. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  56940. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  56941. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  56942. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  56943. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  56944. private _prepareFont;
  56945. /** Releases associated resources */
  56946. dispose(): void;
  56947. private static _HORIZONTAL_ALIGNMENT_LEFT;
  56948. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  56949. private static _HORIZONTAL_ALIGNMENT_CENTER;
  56950. private static _VERTICAL_ALIGNMENT_TOP;
  56951. private static _VERTICAL_ALIGNMENT_BOTTOM;
  56952. private static _VERTICAL_ALIGNMENT_CENTER;
  56953. /** HORIZONTAL_ALIGNMENT_LEFT */
  56954. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  56955. /** HORIZONTAL_ALIGNMENT_RIGHT */
  56956. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  56957. /** HORIZONTAL_ALIGNMENT_CENTER */
  56958. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  56959. /** VERTICAL_ALIGNMENT_TOP */
  56960. static readonly VERTICAL_ALIGNMENT_TOP: number;
  56961. /** VERTICAL_ALIGNMENT_BOTTOM */
  56962. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  56963. /** VERTICAL_ALIGNMENT_CENTER */
  56964. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  56965. private static _FontHeightSizes;
  56966. /** @hidden */ private static _GetFontOffset(font: string): {
  56967. ascent: number;
  56968. height: number;
  56969. descent: number;
  56970. };
  56971. /**
  56972. * Creates a stack panel that can be used to render headers
  56973. * @param control defines the control to associate with the header
  56974. * @param text defines the text of the header
  56975. * @param size defines the size of the header
  56976. * @param options defines options used to configure the header
  56977. * @returns a new StackPanel
  56978. * @ignore
  56979. * @hidden
  56980. */
  56981. static AddHeader: (control: Control, text: string, size: string | number, options: {
  56982. isHorizontal: boolean;
  56983. controlFirst: boolean;
  56984. }) => any;
  56985. /** @hidden */
  56986. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  56987. }
  56988. }
  56989. declare module BABYLON.GUI {
  56990. /**
  56991. * Root class for 2D containers
  56992. * @see http://doc.babylonjs.com/how_to/gui#containers
  56993. */
  56994. export class Container extends Control {
  56995. name?: string | undefined;
  56996. /** @hidden */
  56997. protected _children: Control[];
  56998. /** @hidden */
  56999. protected _measureForChildren: Measure;
  57000. /** @hidden */
  57001. protected _background: string;
  57002. /** @hidden */
  57003. protected _adaptWidthToChildren: boolean;
  57004. /** @hidden */
  57005. protected _adaptHeightToChildren: boolean;
  57006. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  57007. adaptHeightToChildren: boolean;
  57008. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  57009. adaptWidthToChildren: boolean;
  57010. /** Gets or sets background color */
  57011. background: string;
  57012. /** Gets the list of children */
  57013. readonly children: Control[];
  57014. /**
  57015. * Creates a new Container
  57016. * @param name defines the name of the container
  57017. */
  57018. constructor(name?: string | undefined);
  57019. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  57020. /**
  57021. * Gets a child using its name
  57022. * @param name defines the child name to look for
  57023. * @returns the child control if found
  57024. */
  57025. getChildByName(name: string): BABYLON.Nullable<Control>;
  57026. /**
  57027. * Gets a child using its type and its name
  57028. * @param name defines the child name to look for
  57029. * @param type defines the child type to look for
  57030. * @returns the child control if found
  57031. */
  57032. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  57033. /**
  57034. * Search for a specific control in children
  57035. * @param control defines the control to look for
  57036. * @returns true if the control is in child list
  57037. */
  57038. containsControl(control: Control): boolean;
  57039. /**
  57040. * Adds a new control to the current container
  57041. * @param control defines the control to add
  57042. * @returns the current container
  57043. */
  57044. addControl(control: BABYLON.Nullable<Control>): Container;
  57045. /**
  57046. * Removes all controls from the current container
  57047. * @returns the current container
  57048. */
  57049. clearControls(): Container;
  57050. /**
  57051. * Removes a control from the current container
  57052. * @param control defines the control to remove
  57053. * @returns the current container
  57054. */
  57055. removeControl(control: Control): Container;
  57056. /** @hidden */ reOrderControl(control: Control): void;
  57057. /** @hidden */ offsetLeft(offset: number): void;
  57058. /** @hidden */ offsetTop(offset: number): void;
  57059. /** @hidden */ markAllAsDirty(): void;
  57060. /** @hidden */
  57061. protected _localDraw(context: CanvasRenderingContext2D): void;
  57062. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57063. /** @hidden */
  57064. protected _beforeLayout(): void;
  57065. /** @hidden */
  57066. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57067. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57068. protected _postMeasure(): void;
  57069. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  57070. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57071. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57072. /** @hidden */
  57073. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57074. /** Releases associated resources */
  57075. dispose(): void;
  57076. }
  57077. }
  57078. declare module BABYLON.GUI {
  57079. /** Class used to create rectangle container */
  57080. export class Rectangle extends Container {
  57081. name?: string | undefined;
  57082. private _thickness;
  57083. private _cornerRadius;
  57084. /** Gets or sets border thickness */
  57085. thickness: number;
  57086. /** Gets or sets the corner radius angle */
  57087. cornerRadius: number;
  57088. /**
  57089. * Creates a new Rectangle
  57090. * @param name defines the control name
  57091. */
  57092. constructor(name?: string | undefined);
  57093. protected _getTypeName(): string;
  57094. protected _localDraw(context: CanvasRenderingContext2D): void;
  57095. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57096. private _drawRoundedRect;
  57097. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57098. }
  57099. }
  57100. declare module BABYLON.GUI {
  57101. /**
  57102. * Enum that determines the text-wrapping mode to use.
  57103. */
  57104. export enum TextWrapping {
  57105. /**
  57106. * Clip the text when it's larger than Control.width; this is the default mode.
  57107. */
  57108. Clip = 0,
  57109. /**
  57110. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  57111. */
  57112. WordWrap = 1,
  57113. /**
  57114. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  57115. */
  57116. Ellipsis = 2
  57117. }
  57118. /**
  57119. * Class used to create text block control
  57120. */
  57121. export class TextBlock extends Control {
  57122. /**
  57123. * Defines the name of the control
  57124. */
  57125. name?: string | undefined;
  57126. private _text;
  57127. private _textWrapping;
  57128. private _textHorizontalAlignment;
  57129. private _textVerticalAlignment;
  57130. private _lines;
  57131. private _resizeToFit;
  57132. private _lineSpacing;
  57133. private _outlineWidth;
  57134. private _outlineColor;
  57135. /**
  57136. * An event triggered after the text is changed
  57137. */
  57138. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  57139. /**
  57140. * An event triggered after the text was broken up into lines
  57141. */
  57142. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  57143. /**
  57144. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  57145. */
  57146. readonly lines: any[];
  57147. /**
  57148. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57149. */
  57150. /**
  57151. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57152. */
  57153. resizeToFit: boolean;
  57154. /**
  57155. * Gets or sets a boolean indicating if text must be wrapped
  57156. */
  57157. /**
  57158. * Gets or sets a boolean indicating if text must be wrapped
  57159. */
  57160. textWrapping: TextWrapping | boolean;
  57161. /**
  57162. * Gets or sets text to display
  57163. */
  57164. /**
  57165. * Gets or sets text to display
  57166. */
  57167. text: string;
  57168. /**
  57169. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57170. */
  57171. /**
  57172. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57173. */
  57174. textHorizontalAlignment: number;
  57175. /**
  57176. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57177. */
  57178. /**
  57179. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57180. */
  57181. textVerticalAlignment: number;
  57182. /**
  57183. * Gets or sets line spacing value
  57184. */
  57185. /**
  57186. * Gets or sets line spacing value
  57187. */
  57188. lineSpacing: string | number;
  57189. /**
  57190. * Gets or sets outlineWidth of the text to display
  57191. */
  57192. /**
  57193. * Gets or sets outlineWidth of the text to display
  57194. */
  57195. outlineWidth: number;
  57196. /**
  57197. * Gets or sets outlineColor of the text to display
  57198. */
  57199. /**
  57200. * Gets or sets outlineColor of the text to display
  57201. */
  57202. outlineColor: string;
  57203. /**
  57204. * Creates a new TextBlock object
  57205. * @param name defines the name of the control
  57206. * @param text defines the text to display (emptry string by default)
  57207. */
  57208. constructor(
  57209. /**
  57210. * Defines the name of the control
  57211. */
  57212. name?: string | undefined, text?: string);
  57213. protected _getTypeName(): string;
  57214. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57215. private _drawText;
  57216. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57217. protected _applyStates(context: CanvasRenderingContext2D): void;
  57218. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  57219. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  57220. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  57221. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  57222. protected _renderLines(context: CanvasRenderingContext2D): void;
  57223. /**
  57224. * Given a width constraint applied on the text block, find the expected height
  57225. * @returns expected height
  57226. */
  57227. computeExpectedHeight(): number;
  57228. dispose(): void;
  57229. }
  57230. }
  57231. declare module BABYLON.GUI {
  57232. /**
  57233. * Class used to create 2D images
  57234. */
  57235. export class Image extends Control {
  57236. name?: string | undefined;
  57237. private static _WorkingCanvas;
  57238. private _domImage;
  57239. private _imageWidth;
  57240. private _imageHeight;
  57241. private _loaded;
  57242. private _stretch;
  57243. private _source;
  57244. private _autoScale;
  57245. private _sourceLeft;
  57246. private _sourceTop;
  57247. private _sourceWidth;
  57248. private _sourceHeight;
  57249. private _cellWidth;
  57250. private _cellHeight;
  57251. private _cellId;
  57252. private _populateNinePatchSlicesFromImage;
  57253. private _sliceLeft;
  57254. private _sliceRight;
  57255. private _sliceTop;
  57256. private _sliceBottom;
  57257. private _detectPointerOnOpaqueOnly;
  57258. /**
  57259. * BABYLON.Observable notified when the content is loaded
  57260. */
  57261. onImageLoadedObservable: BABYLON.Observable<Image>;
  57262. /**
  57263. * Gets a boolean indicating that the content is loaded
  57264. */
  57265. readonly isLoaded: boolean;
  57266. /**
  57267. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  57268. */
  57269. populateNinePatchSlicesFromImage: boolean;
  57270. /**
  57271. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  57272. * Beware using this as this will comsume more memory as the image has to be stored twice
  57273. */
  57274. detectPointerOnOpaqueOnly: boolean;
  57275. /**
  57276. * Gets or sets the left value for slicing (9-patch)
  57277. */
  57278. sliceLeft: number;
  57279. /**
  57280. * Gets or sets the right value for slicing (9-patch)
  57281. */
  57282. sliceRight: number;
  57283. /**
  57284. * Gets or sets the top value for slicing (9-patch)
  57285. */
  57286. sliceTop: number;
  57287. /**
  57288. * Gets or sets the bottom value for slicing (9-patch)
  57289. */
  57290. sliceBottom: number;
  57291. /**
  57292. * Gets or sets the left coordinate in the source image
  57293. */
  57294. sourceLeft: number;
  57295. /**
  57296. * Gets or sets the top coordinate in the source image
  57297. */
  57298. sourceTop: number;
  57299. /**
  57300. * Gets or sets the width to capture in the source image
  57301. */
  57302. sourceWidth: number;
  57303. /**
  57304. * Gets or sets the height to capture in the source image
  57305. */
  57306. sourceHeight: number;
  57307. /**
  57308. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  57309. * @see http://doc.babylonjs.com/how_to/gui#image
  57310. */
  57311. autoScale: boolean;
  57312. /** Gets or sets the streching mode used by the image */
  57313. stretch: number;
  57314. /**
  57315. * Gets or sets the internal DOM image used to render the control
  57316. */
  57317. domImage: HTMLImageElement;
  57318. private _onImageLoaded;
  57319. private _extractNinePatchSliceDataFromImage;
  57320. /**
  57321. * Gets or sets image source url
  57322. */
  57323. source: BABYLON.Nullable<string>;
  57324. /**
  57325. * Gets or sets the cell width to use when animation sheet is enabled
  57326. * @see http://doc.babylonjs.com/how_to/gui#image
  57327. */
  57328. cellWidth: number;
  57329. /**
  57330. * Gets or sets the cell height to use when animation sheet is enabled
  57331. * @see http://doc.babylonjs.com/how_to/gui#image
  57332. */
  57333. cellHeight: number;
  57334. /**
  57335. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  57336. * @see http://doc.babylonjs.com/how_to/gui#image
  57337. */
  57338. cellId: number;
  57339. /**
  57340. * Creates a new Image
  57341. * @param name defines the control name
  57342. * @param url defines the image url
  57343. */
  57344. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  57345. /**
  57346. * Tests if a given coordinates belong to the current control
  57347. * @param x defines x coordinate to test
  57348. * @param y defines y coordinate to test
  57349. * @returns true if the coordinates are inside the control
  57350. */
  57351. contains(x: number, y: number): boolean;
  57352. protected _getTypeName(): string;
  57353. /** Force the control to synchronize with its content */
  57354. synchronizeSizeWithContent(): void;
  57355. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57356. private _prepareWorkingCanvasForOpaqueDetection;
  57357. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  57358. private _renderCornerPatch;
  57359. private _renderNinePatch;
  57360. dispose(): void;
  57361. /** STRETCH_NONE */
  57362. static readonly STRETCH_NONE: number;
  57363. /** STRETCH_FILL */
  57364. static readonly STRETCH_FILL: number;
  57365. /** STRETCH_UNIFORM */
  57366. static readonly STRETCH_UNIFORM: number;
  57367. /** STRETCH_EXTEND */
  57368. static readonly STRETCH_EXTEND: number;
  57369. /** NINE_PATCH */
  57370. static readonly STRETCH_NINE_PATCH: number;
  57371. }
  57372. }
  57373. declare module BABYLON.GUI {
  57374. /**
  57375. * Class used to create 2D buttons
  57376. */
  57377. export class Button extends Rectangle {
  57378. name?: string | undefined;
  57379. /**
  57380. * Function called to generate a pointer enter animation
  57381. */
  57382. pointerEnterAnimation: () => void;
  57383. /**
  57384. * Function called to generate a pointer out animation
  57385. */
  57386. pointerOutAnimation: () => void;
  57387. /**
  57388. * Function called to generate a pointer down animation
  57389. */
  57390. pointerDownAnimation: () => void;
  57391. /**
  57392. * Function called to generate a pointer up animation
  57393. */
  57394. pointerUpAnimation: () => void;
  57395. private _image;
  57396. /**
  57397. * Returns the image part of the button (if any)
  57398. */
  57399. readonly image: BABYLON.Nullable<Image>;
  57400. private _textBlock;
  57401. /**
  57402. * Returns the image part of the button (if any)
  57403. */
  57404. readonly textBlock: BABYLON.Nullable<TextBlock>;
  57405. /**
  57406. * Creates a new Button
  57407. * @param name defines the name of the button
  57408. */
  57409. constructor(name?: string | undefined);
  57410. protected _getTypeName(): string;
  57411. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57412. /** @hidden */ onPointerEnter(target: Control): boolean;
  57413. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57414. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57415. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57416. /**
  57417. * Creates a new button made with an image and a text
  57418. * @param name defines the name of the button
  57419. * @param text defines the text of the button
  57420. * @param imageUrl defines the url of the image
  57421. * @returns a new Button
  57422. */
  57423. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  57424. /**
  57425. * Creates a new button made with an image
  57426. * @param name defines the name of the button
  57427. * @param imageUrl defines the url of the image
  57428. * @returns a new Button
  57429. */
  57430. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  57431. /**
  57432. * Creates a new button made with a text
  57433. * @param name defines the name of the button
  57434. * @param text defines the text of the button
  57435. * @returns a new Button
  57436. */
  57437. static CreateSimpleButton(name: string, text: string): Button;
  57438. /**
  57439. * Creates a new button made with an image and a centered text
  57440. * @param name defines the name of the button
  57441. * @param text defines the text of the button
  57442. * @param imageUrl defines the url of the image
  57443. * @returns a new Button
  57444. */
  57445. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  57446. }
  57447. }
  57448. declare module BABYLON.GUI {
  57449. /**
  57450. * Class used to create a 2D stack panel container
  57451. */
  57452. export class StackPanel extends Container {
  57453. name?: string | undefined;
  57454. private _isVertical;
  57455. private _manualWidth;
  57456. private _manualHeight;
  57457. private _doNotTrackManualChanges;
  57458. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  57459. isVertical: boolean;
  57460. /**
  57461. * Gets or sets panel width.
  57462. * This value should not be set when in horizontal mode as it will be computed automatically
  57463. */
  57464. width: string | number;
  57465. /**
  57466. * Gets or sets panel height.
  57467. * This value should not be set when in vertical mode as it will be computed automatically
  57468. */
  57469. height: string | number;
  57470. /**
  57471. * Creates a new StackPanel
  57472. * @param name defines control name
  57473. */
  57474. constructor(name?: string | undefined);
  57475. protected _getTypeName(): string;
  57476. /** @hidden */
  57477. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57478. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57479. protected _postMeasure(): void;
  57480. }
  57481. }
  57482. declare module BABYLON.GUI {
  57483. /**
  57484. * Class used to represent a 2D checkbox
  57485. */
  57486. export class Checkbox extends Control {
  57487. name?: string | undefined;
  57488. private _isChecked;
  57489. private _background;
  57490. private _checkSizeRatio;
  57491. private _thickness;
  57492. /** Gets or sets border thickness */
  57493. thickness: number;
  57494. /**
  57495. * BABYLON.Observable raised when isChecked property changes
  57496. */
  57497. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  57498. /** Gets or sets a value indicating the ratio between overall size and check size */
  57499. checkSizeRatio: number;
  57500. /** Gets or sets background color */
  57501. background: string;
  57502. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  57503. isChecked: boolean;
  57504. /**
  57505. * Creates a new CheckBox
  57506. * @param name defines the control name
  57507. */
  57508. constructor(name?: string | undefined);
  57509. protected _getTypeName(): string;
  57510. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57511. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57512. /**
  57513. * Utility function to easily create a checkbox with a header
  57514. * @param title defines the label to use for the header
  57515. * @param onValueChanged defines the callback to call when value changes
  57516. * @returns a StackPanel containing the checkbox and a textBlock
  57517. */
  57518. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  57519. }
  57520. }
  57521. declare module BABYLON.GUI {
  57522. /**
  57523. * Class used to store key control properties
  57524. */
  57525. export class KeyPropertySet {
  57526. /** Width */
  57527. width?: string;
  57528. /** Height */
  57529. height?: string;
  57530. /** Left padding */
  57531. paddingLeft?: string;
  57532. /** Right padding */
  57533. paddingRight?: string;
  57534. /** Top padding */
  57535. paddingTop?: string;
  57536. /** Bottom padding */
  57537. paddingBottom?: string;
  57538. /** Foreground color */
  57539. color?: string;
  57540. /** Background color */
  57541. background?: string;
  57542. }
  57543. /**
  57544. * Class used to create virtual keyboard
  57545. */
  57546. export class VirtualKeyboard extends StackPanel {
  57547. /** BABYLON.Observable raised when a key is pressed */
  57548. onKeyPressObservable: BABYLON.Observable<string>;
  57549. /** Gets or sets default key button width */
  57550. defaultButtonWidth: string;
  57551. /** Gets or sets default key button height */
  57552. defaultButtonHeight: string;
  57553. /** Gets or sets default key button left padding */
  57554. defaultButtonPaddingLeft: string;
  57555. /** Gets or sets default key button right padding */
  57556. defaultButtonPaddingRight: string;
  57557. /** Gets or sets default key button top padding */
  57558. defaultButtonPaddingTop: string;
  57559. /** Gets or sets default key button bottom padding */
  57560. defaultButtonPaddingBottom: string;
  57561. /** Gets or sets default key button foreground color */
  57562. defaultButtonColor: string;
  57563. /** Gets or sets default key button background color */
  57564. defaultButtonBackground: string;
  57565. /** Gets or sets shift button foreground color */
  57566. shiftButtonColor: string;
  57567. /** Gets or sets shift button thickness*/
  57568. selectedShiftThickness: number;
  57569. /** Gets shift key state */
  57570. shiftState: number;
  57571. protected _getTypeName(): string;
  57572. private _createKey;
  57573. /**
  57574. * Adds a new row of keys
  57575. * @param keys defines the list of keys to add
  57576. * @param propertySets defines the associated property sets
  57577. */
  57578. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  57579. /**
  57580. * Set the shift key to a specific state
  57581. * @param shiftState defines the new shift state
  57582. */
  57583. applyShiftState(shiftState: number): void;
  57584. private _currentlyConnectedInputText;
  57585. private _connectedInputTexts;
  57586. private _onKeyPressObserver;
  57587. /** Gets the input text control currently attached to the keyboard */
  57588. readonly connectedInputText: BABYLON.Nullable<InputText>;
  57589. /**
  57590. * Connects the keyboard with an input text control
  57591. *
  57592. * @param input defines the target control
  57593. */
  57594. connect(input: InputText): void;
  57595. /**
  57596. * Disconnects the keyboard from connected InputText controls
  57597. *
  57598. * @param input optionally defines a target control, otherwise all are disconnected
  57599. */
  57600. disconnect(input?: InputText): void;
  57601. private _removeConnectedInputObservables;
  57602. /**
  57603. * Release all resources
  57604. */
  57605. dispose(): void;
  57606. /**
  57607. * Creates a new keyboard using a default layout
  57608. *
  57609. * @param name defines control name
  57610. * @returns a new VirtualKeyboard
  57611. */
  57612. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  57613. }
  57614. }
  57615. declare module BABYLON.GUI {
  57616. /**
  57617. * Class used to create input text control
  57618. */
  57619. export class InputText extends Control implements IFocusableControl {
  57620. name?: string | undefined;
  57621. private _text;
  57622. private _placeholderText;
  57623. private _background;
  57624. private _focusedBackground;
  57625. private _focusedColor;
  57626. private _placeholderColor;
  57627. private _thickness;
  57628. private _margin;
  57629. private _autoStretchWidth;
  57630. private _maxWidth;
  57631. private _isFocused;
  57632. private _blinkTimeout;
  57633. private _blinkIsEven;
  57634. private _cursorOffset;
  57635. private _scrollLeft;
  57636. private _textWidth;
  57637. private _clickedCoordinate;
  57638. private _deadKey;
  57639. private _addKey;
  57640. private _currentKey;
  57641. private _isTextHighlightOn;
  57642. private _textHighlightColor;
  57643. private _highligherOpacity;
  57644. private _highlightedText;
  57645. private _startHighlightIndex;
  57646. private _endHighlightIndex;
  57647. private _cursorIndex;
  57648. private _onFocusSelectAll;
  57649. private _isPointerDown;
  57650. private _onClipboardObserver;
  57651. private _onPointerDblTapObserver;
  57652. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  57653. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  57654. promptMessage: string;
  57655. /** BABYLON.Observable raised when the text changes */
  57656. onTextChangedObservable: BABYLON.Observable<InputText>;
  57657. /** BABYLON.Observable raised just before an entered character is to be added */
  57658. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  57659. /** BABYLON.Observable raised when the control gets the focus */
  57660. onFocusObservable: BABYLON.Observable<InputText>;
  57661. /** BABYLON.Observable raised when the control loses the focus */
  57662. onBlurObservable: BABYLON.Observable<InputText>;
  57663. /**Observable raised when the text is highlighted */
  57664. onTextHighlightObservable: BABYLON.Observable<InputText>;
  57665. /**Observable raised when copy event is triggered */
  57666. onTextCopyObservable: BABYLON.Observable<InputText>;
  57667. /** BABYLON.Observable raised when cut event is triggered */
  57668. onTextCutObservable: BABYLON.Observable<InputText>;
  57669. /** BABYLON.Observable raised when paste event is triggered */
  57670. onTextPasteObservable: BABYLON.Observable<InputText>;
  57671. /** BABYLON.Observable raised when a key event was processed */
  57672. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  57673. /** Gets or sets the maximum width allowed by the control */
  57674. maxWidth: string | number;
  57675. /** Gets the maximum width allowed by the control in pixels */
  57676. readonly maxWidthInPixels: number;
  57677. /** Gets or sets the text highlighter transparency; default: 0.4 */
  57678. highligherOpacity: number;
  57679. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  57680. onFocusSelectAll: boolean;
  57681. /** Gets or sets the text hightlight color */
  57682. textHighlightColor: string;
  57683. /** Gets or sets control margin */
  57684. margin: string;
  57685. /** Gets control margin in pixels */
  57686. readonly marginInPixels: number;
  57687. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  57688. autoStretchWidth: boolean;
  57689. /** Gets or sets border thickness */
  57690. thickness: number;
  57691. /** Gets or sets the background color when focused */
  57692. focusedBackground: string;
  57693. /** Gets or sets the background color when focused */
  57694. focusedColor: string;
  57695. /** Gets or sets the background color */
  57696. background: string;
  57697. /** Gets or sets the placeholder color */
  57698. placeholderColor: string;
  57699. /** Gets or sets the text displayed when the control is empty */
  57700. placeholderText: string;
  57701. /** Gets or sets the dead key flag */
  57702. deadKey: boolean;
  57703. /** Gets or sets the highlight text */
  57704. highlightedText: string;
  57705. /** Gets or sets if the current key should be added */
  57706. addKey: boolean;
  57707. /** Gets or sets the value of the current key being entered */
  57708. currentKey: string;
  57709. /** Gets or sets the text displayed in the control */
  57710. text: string;
  57711. /** Gets or sets control width */
  57712. width: string | number;
  57713. /**
  57714. * Creates a new InputText
  57715. * @param name defines the control name
  57716. * @param text defines the text of the control
  57717. */
  57718. constructor(name?: string | undefined, text?: string);
  57719. /** @hidden */
  57720. onBlur(): void;
  57721. /** @hidden */
  57722. onFocus(): void;
  57723. protected _getTypeName(): string;
  57724. /**
  57725. * Function called to get the list of controls that should not steal the focus from this control
  57726. * @returns an array of controls
  57727. */
  57728. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  57729. /** @hidden */
  57730. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  57731. /** @hidden */
  57732. private _updateValueFromCursorIndex;
  57733. /** @hidden */
  57734. private _processDblClick;
  57735. /** @hidden */
  57736. private _selectAllText;
  57737. /**
  57738. * Handles the keyboard event
  57739. * @param evt Defines the KeyboardEvent
  57740. */
  57741. processKeyboard(evt: KeyboardEvent): void;
  57742. /** @hidden */
  57743. private _onCopyText;
  57744. /** @hidden */
  57745. private _onCutText;
  57746. /** @hidden */
  57747. private _onPasteText; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57748. protected _beforeRenderText(text: string): string;
  57749. dispose(): void;
  57750. }
  57751. }
  57752. declare module BABYLON.GUI {
  57753. /**
  57754. * Class used to create a 2D grid container
  57755. */
  57756. export class Grid extends Container {
  57757. name?: string | undefined;
  57758. private _rowDefinitions;
  57759. private _columnDefinitions;
  57760. private _cells;
  57761. private _childControls;
  57762. /**
  57763. * Gets the number of columns
  57764. */
  57765. readonly columnCount: number;
  57766. /**
  57767. * Gets the number of rows
  57768. */
  57769. readonly rowCount: number;
  57770. /** Gets the list of children */
  57771. readonly children: Control[];
  57772. /**
  57773. * Gets the definition of a specific row
  57774. * @param index defines the index of the row
  57775. * @returns the row definition
  57776. */
  57777. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  57778. /**
  57779. * Gets the definition of a specific column
  57780. * @param index defines the index of the column
  57781. * @returns the column definition
  57782. */
  57783. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  57784. /**
  57785. * Adds a new row to the grid
  57786. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  57787. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  57788. * @returns the current grid
  57789. */
  57790. addRowDefinition(height: number, isPixel?: boolean): Grid;
  57791. /**
  57792. * Adds a new column to the grid
  57793. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  57794. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  57795. * @returns the current grid
  57796. */
  57797. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  57798. /**
  57799. * Update a row definition
  57800. * @param index defines the index of the row to update
  57801. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  57802. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  57803. * @returns the current grid
  57804. */
  57805. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  57806. /**
  57807. * Update a column definition
  57808. * @param index defines the index of the column to update
  57809. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  57810. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  57811. * @returns the current grid
  57812. */
  57813. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  57814. /**
  57815. * Gets the list of children stored in a specific cell
  57816. * @param row defines the row to check
  57817. * @param column defines the column to check
  57818. * @returns the list of controls
  57819. */
  57820. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  57821. /**
  57822. * Gets a string representing the child cell info (row x column)
  57823. * @param child defines the control to get info from
  57824. * @returns a string containing the child cell info (row x column)
  57825. */
  57826. getChildCellInfo(child: Control): string;
  57827. private _removeCell;
  57828. private _offsetCell;
  57829. /**
  57830. * Remove a column definition at specified index
  57831. * @param index defines the index of the column to remove
  57832. * @returns the current grid
  57833. */
  57834. removeColumnDefinition(index: number): Grid;
  57835. /**
  57836. * Remove a row definition at specified index
  57837. * @param index defines the index of the row to remove
  57838. * @returns the current grid
  57839. */
  57840. removeRowDefinition(index: number): Grid;
  57841. /**
  57842. * Adds a new control to the current grid
  57843. * @param control defines the control to add
  57844. * @param row defines the row where to add the control (0 by default)
  57845. * @param column defines the column where to add the control (0 by default)
  57846. * @returns the current grid
  57847. */
  57848. addControl(control: Control, row?: number, column?: number): Grid;
  57849. /**
  57850. * Removes a control from the current container
  57851. * @param control defines the control to remove
  57852. * @returns the current container
  57853. */
  57854. removeControl(control: Control): Container;
  57855. /**
  57856. * Creates a new Grid
  57857. * @param name defines control name
  57858. */
  57859. constructor(name?: string | undefined);
  57860. protected _getTypeName(): string;
  57861. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  57862. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  57863. /** Releases associated resources */
  57864. dispose(): void;
  57865. }
  57866. }
  57867. declare module BABYLON.GUI {
  57868. /** Class used to create color pickers */
  57869. export class ColorPicker extends Control {
  57870. name?: string | undefined;
  57871. private static _Epsilon;
  57872. private _colorWheelCanvas;
  57873. private _value;
  57874. private _tmpColor;
  57875. private _pointerStartedOnSquare;
  57876. private _pointerStartedOnWheel;
  57877. private _squareLeft;
  57878. private _squareTop;
  57879. private _squareSize;
  57880. private _h;
  57881. private _s;
  57882. private _v;
  57883. /**
  57884. * BABYLON.Observable raised when the value changes
  57885. */
  57886. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  57887. /** Gets or sets the color of the color picker */
  57888. value: BABYLON.Color3;
  57889. /**
  57890. * Gets or sets control width
  57891. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57892. */
  57893. width: string | number;
  57894. /**
  57895. * Gets or sets control height
  57896. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57897. */
  57898. /** Gets or sets control height */
  57899. height: string | number;
  57900. /** Gets or sets control size */
  57901. size: string | number;
  57902. /**
  57903. * Creates a new ColorPicker
  57904. * @param name defines the control name
  57905. */
  57906. constructor(name?: string | undefined);
  57907. protected _getTypeName(): string;
  57908. /** @hidden */
  57909. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57910. private _updateSquareProps;
  57911. private _drawGradientSquare;
  57912. private _drawCircle;
  57913. private _createColorWheelCanvas;
  57914. private _RGBtoHSV;
  57915. private _HSVtoRGB;
  57916. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57917. private _pointerIsDown;
  57918. private _updateValueFromPointer;
  57919. private _isPointOnSquare;
  57920. private _isPointOnWheel; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57921. /**
  57922. * This function expands the color picker by creating a color picker dialog with manual
  57923. * color value input and the ability to save colors into an array to be used later in
  57924. * subsequent launches of the dialogue.
  57925. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  57926. * @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.
  57927. * @returns picked color as a hex string and the saved colors array as hex strings.
  57928. */
  57929. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  57930. pickerWidth?: string;
  57931. pickerHeight?: string;
  57932. headerHeight?: string;
  57933. lastColor?: string;
  57934. swatchLimit?: number;
  57935. numSwatchesPerLine?: number;
  57936. savedColors?: Array<string>;
  57937. }): Promise<{
  57938. savedColors?: string[];
  57939. pickedColor: string;
  57940. }>;
  57941. }
  57942. }
  57943. declare module BABYLON.GUI {
  57944. /** Class used to create 2D ellipse containers */
  57945. export class Ellipse extends Container {
  57946. name?: string | undefined;
  57947. private _thickness;
  57948. /** Gets or sets border thickness */
  57949. thickness: number;
  57950. /**
  57951. * Creates a new Ellipse
  57952. * @param name defines the control name
  57953. */
  57954. constructor(name?: string | undefined);
  57955. protected _getTypeName(): string;
  57956. protected _localDraw(context: CanvasRenderingContext2D): void;
  57957. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57958. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57959. }
  57960. }
  57961. declare module BABYLON.GUI {
  57962. /**
  57963. * Class used to create a password control
  57964. */
  57965. export class InputPassword extends InputText {
  57966. protected _beforeRenderText(text: string): string;
  57967. }
  57968. }
  57969. declare module BABYLON.GUI {
  57970. /** Class used to render 2D lines */
  57971. export class Line extends Control {
  57972. name?: string | undefined;
  57973. private _lineWidth;
  57974. private _x1;
  57975. private _y1;
  57976. private _x2;
  57977. private _y2;
  57978. private _dash;
  57979. private _connectedControl;
  57980. private _connectedControlDirtyObserver;
  57981. /** Gets or sets the dash pattern */
  57982. dash: Array<number>;
  57983. /** Gets or sets the control connected with the line end */
  57984. connectedControl: Control;
  57985. /** Gets or sets start coordinates on X axis */
  57986. x1: string | number;
  57987. /** Gets or sets start coordinates on Y axis */
  57988. y1: string | number;
  57989. /** Gets or sets end coordinates on X axis */
  57990. x2: string | number;
  57991. /** Gets or sets end coordinates on Y axis */
  57992. y2: string | number;
  57993. /** Gets or sets line width */
  57994. lineWidth: number;
  57995. /** Gets or sets horizontal alignment */
  57996. horizontalAlignment: number;
  57997. /** Gets or sets vertical alignment */
  57998. verticalAlignment: number;
  57999. private readonly _effectiveX2;
  58000. private readonly _effectiveY2;
  58001. /**
  58002. * Creates a new Line
  58003. * @param name defines the control name
  58004. */
  58005. constructor(name?: string | undefined);
  58006. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  58007. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58008. /**
  58009. * Move one end of the line given 3D cartesian coordinates.
  58010. * @param position Targeted world position
  58011. * @param scene BABYLON.Scene
  58012. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58013. */
  58014. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  58015. /**
  58016. * Move one end of the line to a position in screen absolute space.
  58017. * @param projectedPosition Position in screen absolute space (X, Y)
  58018. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58019. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  58020. }
  58021. }
  58022. declare module BABYLON.GUI {
  58023. /**
  58024. * Class used to store a point for a MultiLine object.
  58025. * The point can be pure 2D coordinates, a mesh or a control
  58026. */
  58027. export class MultiLinePoint {
  58028. private _multiLine;
  58029. private _x;
  58030. private _y;
  58031. private _control;
  58032. private _mesh;
  58033. private _controlObserver;
  58034. private _meshObserver;
  58035. /** @hidden */ point: BABYLON.Vector2;
  58036. /**
  58037. * Creates a new MultiLinePoint
  58038. * @param multiLine defines the source MultiLine object
  58039. */
  58040. constructor(multiLine: MultiLine);
  58041. /** Gets or sets x coordinate */
  58042. x: string | number;
  58043. /** Gets or sets y coordinate */
  58044. y: string | number;
  58045. /** Gets or sets the control associated with this point */
  58046. control: BABYLON.Nullable<Control>;
  58047. /** Gets or sets the mesh associated with this point */
  58048. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58049. /** Resets links */
  58050. resetLinks(): void;
  58051. /**
  58052. * Gets a translation vector
  58053. * @returns the translation vector
  58054. */
  58055. translate(): BABYLON.Vector2;
  58056. private _translatePoint;
  58057. /** Release associated resources */
  58058. dispose(): void;
  58059. }
  58060. }
  58061. declare module BABYLON.GUI {
  58062. /**
  58063. * Class used to create multi line control
  58064. */
  58065. export class MultiLine extends Control {
  58066. name?: string | undefined;
  58067. private _lineWidth;
  58068. private _dash;
  58069. private _points;
  58070. private _minX;
  58071. private _minY;
  58072. private _maxX;
  58073. private _maxY;
  58074. /**
  58075. * Creates a new MultiLine
  58076. * @param name defines the control name
  58077. */
  58078. constructor(name?: string | undefined);
  58079. /** Gets or sets dash pattern */
  58080. dash: Array<number>;
  58081. /**
  58082. * Gets point stored at specified index
  58083. * @param index defines the index to look for
  58084. * @returns the requested point if found
  58085. */
  58086. getAt(index: number): MultiLinePoint;
  58087. /** Function called when a point is updated */
  58088. onPointUpdate: () => void;
  58089. /**
  58090. * Adds new points to the point collection
  58091. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  58092. * @returns the list of created MultiLinePoint
  58093. */
  58094. add(...items: (AbstractMesh | Control | {
  58095. x: string | number;
  58096. y: string | number;
  58097. })[]): MultiLinePoint[];
  58098. /**
  58099. * Adds a new point to the point collection
  58100. * @param item defines the item (mesh, control or 2d coordiantes) to add
  58101. * @returns the created MultiLinePoint
  58102. */
  58103. push(item?: (AbstractMesh | Control | {
  58104. x: string | number;
  58105. y: string | number;
  58106. })): MultiLinePoint;
  58107. /**
  58108. * Remove a specific value or point from the active point collection
  58109. * @param value defines the value or point to remove
  58110. */
  58111. remove(value: number | MultiLinePoint): void;
  58112. /**
  58113. * Resets this object to initial state (no point)
  58114. */
  58115. reset(): void;
  58116. /**
  58117. * Resets all links
  58118. */
  58119. resetLinks(): void;
  58120. /** Gets or sets line width */
  58121. lineWidth: number;
  58122. horizontalAlignment: number;
  58123. verticalAlignment: number;
  58124. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58125. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  58126. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58127. dispose(): void;
  58128. }
  58129. }
  58130. declare module BABYLON.GUI {
  58131. /**
  58132. * Class used to create radio button controls
  58133. */
  58134. export class RadioButton extends Control {
  58135. name?: string | undefined;
  58136. private _isChecked;
  58137. private _background;
  58138. private _checkSizeRatio;
  58139. private _thickness;
  58140. /** Gets or sets border thickness */
  58141. thickness: number;
  58142. /** Gets or sets group name */
  58143. group: string;
  58144. /** BABYLON.Observable raised when isChecked is changed */
  58145. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  58146. /** Gets or sets a value indicating the ratio between overall size and check size */
  58147. checkSizeRatio: number;
  58148. /** Gets or sets background color */
  58149. background: string;
  58150. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  58151. isChecked: boolean;
  58152. /**
  58153. * Creates a new RadioButton
  58154. * @param name defines the control name
  58155. */
  58156. constructor(name?: string | undefined);
  58157. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58158. /**
  58159. * Utility function to easily create a radio button with a header
  58160. * @param title defines the label to use for the header
  58161. * @param group defines the group to use for the radio button
  58162. * @param isChecked defines the initial state of the radio button
  58163. * @param onValueChanged defines the callback to call when value changes
  58164. * @returns a StackPanel containing the radio button and a textBlock
  58165. */
  58166. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  58167. }
  58168. }
  58169. declare module BABYLON.GUI {
  58170. /**
  58171. * Class used to create slider controls
  58172. */
  58173. export class BaseSlider extends Control {
  58174. name?: string | undefined;
  58175. protected _thumbWidth: ValueAndUnit;
  58176. private _minimum;
  58177. private _maximum;
  58178. private _value;
  58179. private _isVertical;
  58180. protected _barOffset: ValueAndUnit;
  58181. private _isThumbClamped;
  58182. protected _displayThumb: boolean;
  58183. private _step;
  58184. protected _effectiveBarOffset: number;
  58185. protected _renderLeft: number;
  58186. protected _renderTop: number;
  58187. protected _renderWidth: number;
  58188. protected _renderHeight: number;
  58189. protected _backgroundBoxLength: number;
  58190. protected _backgroundBoxThickness: number;
  58191. protected _effectiveThumbThickness: number;
  58192. /** BABYLON.Observable raised when the sldier value changes */
  58193. onValueChangedObservable: BABYLON.Observable<number>;
  58194. /** Gets or sets a boolean indicating if the thumb must be rendered */
  58195. displayThumb: boolean;
  58196. /** Gets or sets a step to apply to values (0 by default) */
  58197. step: number;
  58198. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  58199. barOffset: string | number;
  58200. /** Gets main bar offset in pixels*/
  58201. readonly barOffsetInPixels: number;
  58202. /** Gets or sets thumb width */
  58203. thumbWidth: string | number;
  58204. /** Gets thumb width in pixels */
  58205. readonly thumbWidthInPixels: number;
  58206. /** Gets or sets minimum value */
  58207. minimum: number;
  58208. /** Gets or sets maximum value */
  58209. maximum: number;
  58210. /** Gets or sets current value */
  58211. value: number;
  58212. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  58213. isVertical: boolean;
  58214. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  58215. isThumbClamped: boolean;
  58216. /**
  58217. * Creates a new BaseSlider
  58218. * @param name defines the control name
  58219. */
  58220. constructor(name?: string | undefined);
  58221. protected _getTypeName(): string;
  58222. protected _getThumbPosition(): number;
  58223. protected _getThumbThickness(type: string): number;
  58224. protected _prepareRenderingData(type: string): void;
  58225. private _pointerIsDown;
  58226. /** @hidden */
  58227. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58228. }
  58229. }
  58230. declare module BABYLON.GUI {
  58231. /**
  58232. * Class used to create slider controls
  58233. */
  58234. export class Slider extends BaseSlider {
  58235. name?: string | undefined;
  58236. private _background;
  58237. private _borderColor;
  58238. private _isThumbCircle;
  58239. protected _displayValueBar: boolean;
  58240. /** Gets or sets a boolean indicating if the value bar must be rendered */
  58241. displayValueBar: boolean;
  58242. /** Gets or sets border color */
  58243. borderColor: string;
  58244. /** Gets or sets background color */
  58245. background: string;
  58246. /** Gets or sets a boolean indicating if the thumb should be round or square */
  58247. isThumbCircle: boolean;
  58248. /**
  58249. * Creates a new Slider
  58250. * @param name defines the control name
  58251. */
  58252. constructor(name?: string | undefined);
  58253. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58254. }
  58255. }
  58256. declare module BABYLON.GUI {
  58257. /** Class used to create a RadioGroup
  58258. * which contains groups of radio buttons
  58259. */
  58260. export class SelectorGroup {
  58261. /** name of SelectorGroup */
  58262. name: string;
  58263. private _groupPanel;
  58264. private _selectors;
  58265. private _groupHeader;
  58266. /**
  58267. * Creates a new SelectorGroup
  58268. * @param name of group, used as a group heading
  58269. */
  58270. constructor(
  58271. /** name of SelectorGroup */
  58272. name: string);
  58273. /** Gets the groupPanel of the SelectorGroup */
  58274. readonly groupPanel: StackPanel;
  58275. /** Gets the selectors array */
  58276. readonly selectors: StackPanel[];
  58277. /** Gets and sets the group header */
  58278. header: string;
  58279. /** @hidden */
  58280. private _addGroupHeader;
  58281. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  58282. /** Removes the selector at the given position
  58283. * @param selectorNb the position of the selector within the group
  58284. */
  58285. removeSelector(selectorNb: number): void;
  58286. }
  58287. /** Class used to create a CheckboxGroup
  58288. * which contains groups of checkbox buttons
  58289. */
  58290. export class CheckboxGroup extends SelectorGroup {
  58291. /** Adds a checkbox as a control
  58292. * @param text is the label for the selector
  58293. * @param func is the function called when the Selector is checked
  58294. * @param checked is true when Selector is checked
  58295. */
  58296. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  58297. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58298. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58299. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58300. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58301. }
  58302. /** Class used to create a RadioGroup
  58303. * which contains groups of radio buttons
  58304. */
  58305. export class RadioGroup extends SelectorGroup {
  58306. private _selectNb;
  58307. /** Adds a radio button as a control
  58308. * @param label is the label for the selector
  58309. * @param func is the function called when the Selector is checked
  58310. * @param checked is true when Selector is checked
  58311. */
  58312. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  58313. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58314. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58315. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58316. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58317. }
  58318. /** Class used to create a SliderGroup
  58319. * which contains groups of slider buttons
  58320. */
  58321. export class SliderGroup extends SelectorGroup {
  58322. /**
  58323. * Adds a slider to the SelectorGroup
  58324. * @param label is the label for the SliderBar
  58325. * @param func is the function called when the Slider moves
  58326. * @param unit is a string describing the units used, eg degrees or metres
  58327. * @param min is the minimum value for the Slider
  58328. * @param max is the maximum value for the Slider
  58329. * @param value is the start value for the Slider between min and max
  58330. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  58331. */
  58332. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  58333. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58334. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58335. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58336. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58337. }
  58338. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  58339. * @see http://doc.babylonjs.com/how_to/selector
  58340. */
  58341. export class SelectionPanel extends Rectangle {
  58342. /** name of SelectionPanel */
  58343. name: string;
  58344. /** an array of SelectionGroups */
  58345. groups: SelectorGroup[];
  58346. private _panel;
  58347. private _buttonColor;
  58348. private _buttonBackground;
  58349. private _headerColor;
  58350. private _barColor;
  58351. private _barHeight;
  58352. private _spacerHeight;
  58353. private _labelColor;
  58354. private _groups;
  58355. private _bars;
  58356. /**
  58357. * Creates a new SelectionPanel
  58358. * @param name of SelectionPanel
  58359. * @param groups is an array of SelectionGroups
  58360. */
  58361. constructor(
  58362. /** name of SelectionPanel */
  58363. name: string,
  58364. /** an array of SelectionGroups */
  58365. groups?: SelectorGroup[]);
  58366. protected _getTypeName(): string;
  58367. /** Gets or sets the headerColor */
  58368. headerColor: string;
  58369. private _setHeaderColor;
  58370. /** Gets or sets the button color */
  58371. buttonColor: string;
  58372. private _setbuttonColor;
  58373. /** Gets or sets the label color */
  58374. labelColor: string;
  58375. private _setLabelColor;
  58376. /** Gets or sets the button background */
  58377. buttonBackground: string;
  58378. private _setButtonBackground;
  58379. /** Gets or sets the color of separator bar */
  58380. barColor: string;
  58381. private _setBarColor;
  58382. /** Gets or sets the height of separator bar */
  58383. barHeight: string;
  58384. private _setBarHeight;
  58385. /** Gets or sets the height of spacers*/
  58386. spacerHeight: string;
  58387. private _setSpacerHeight;
  58388. /** Adds a bar between groups */
  58389. private _addSpacer;
  58390. /** Add a group to the selection panel
  58391. * @param group is the selector group to add
  58392. */
  58393. addGroup(group: SelectorGroup): void;
  58394. /** Remove the group from the given position
  58395. * @param groupNb is the position of the group in the list
  58396. */
  58397. removeGroup(groupNb: number): void;
  58398. /** Change a group header label
  58399. * @param label is the new group header label
  58400. * @param groupNb is the number of the group to relabel
  58401. * */
  58402. setHeaderName(label: string, groupNb: number): void;
  58403. /** Change selector label to the one given
  58404. * @param label is the new selector label
  58405. * @param groupNb is the number of the groupcontaining the selector
  58406. * @param selectorNb is the number of the selector within a group to relabel
  58407. * */
  58408. relabel(label: string, groupNb: number, selectorNb: number): void;
  58409. /** For a given group position remove the selector at the given position
  58410. * @param groupNb is the number of the group to remove the selector from
  58411. * @param selectorNb is the number of the selector within the group
  58412. */
  58413. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  58414. /** For a given group position of correct type add a checkbox button
  58415. * @param groupNb is the number of the group to remove the selector from
  58416. * @param label is the label for the selector
  58417. * @param func is the function called when the Selector is checked
  58418. * @param checked is true when Selector is checked
  58419. */
  58420. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58421. /** For a given group position of correct type add a radio button
  58422. * @param groupNb is the number of the group to remove the selector from
  58423. * @param label is the label for the selector
  58424. * @param func is the function called when the Selector is checked
  58425. * @param checked is true when Selector is checked
  58426. */
  58427. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58428. /**
  58429. * For a given slider group add a slider
  58430. * @param groupNb is the number of the group to add the slider to
  58431. * @param label is the label for the Slider
  58432. * @param func is the function called when the Slider moves
  58433. * @param unit is a string describing the units used, eg degrees or metres
  58434. * @param min is the minimum value for the Slider
  58435. * @param max is the maximum value for the Slider
  58436. * @param value is the start value for the Slider between min and max
  58437. * @param onVal is the function used to format the value displayed, eg radians to degrees
  58438. */
  58439. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  58440. }
  58441. }
  58442. declare module BABYLON.GUI {
  58443. /**
  58444. * Class used to hold a the container for ScrollViewer
  58445. * @hidden
  58446. */
  58447. export class _ScrollViewerWindow extends Container {
  58448. parentClientWidth: number;
  58449. parentClientHeight: number;
  58450. /**
  58451. * Creates a new ScrollViewerWindow
  58452. * @param name of ScrollViewerWindow
  58453. */
  58454. constructor(name?: string);
  58455. protected _getTypeName(): string;
  58456. /** @hidden */
  58457. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58458. protected _postMeasure(): void;
  58459. }
  58460. }
  58461. declare module BABYLON.GUI {
  58462. /**
  58463. * Class used to create slider controls
  58464. */
  58465. export class ScrollBar extends BaseSlider {
  58466. name?: string | undefined;
  58467. private _background;
  58468. private _borderColor;
  58469. private _thumbMeasure;
  58470. /** Gets or sets border color */
  58471. borderColor: string;
  58472. /** Gets or sets background color */
  58473. background: string;
  58474. /**
  58475. * Creates a new Slider
  58476. * @param name defines the control name
  58477. */
  58478. constructor(name?: string | undefined);
  58479. protected _getTypeName(): string;
  58480. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  58481. private _first;
  58482. private _originX;
  58483. private _originY;
  58484. /** @hidden */
  58485. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58486. }
  58487. }
  58488. declare module BABYLON.GUI {
  58489. /**
  58490. * Class used to hold a viewer window and sliders in a grid
  58491. */
  58492. export class ScrollViewer extends Rectangle {
  58493. private _grid;
  58494. private _horizontalBarSpace;
  58495. private _verticalBarSpace;
  58496. private _dragSpace;
  58497. private _horizontalBar;
  58498. private _verticalBar;
  58499. private _barColor;
  58500. private _barBackground;
  58501. private _barSize;
  58502. private _endLeft;
  58503. private _endTop;
  58504. private _window;
  58505. private _pointerIsOver;
  58506. private _wheelPrecision;
  58507. private _onPointerObserver;
  58508. private _clientWidth;
  58509. private _clientHeight;
  58510. /**
  58511. * Gets the horizontal scrollbar
  58512. */
  58513. readonly horizontalBar: ScrollBar;
  58514. /**
  58515. * Gets the vertical scrollbar
  58516. */
  58517. readonly verticalBar: ScrollBar;
  58518. /**
  58519. * Adds a new control to the current container
  58520. * @param control defines the control to add
  58521. * @returns the current container
  58522. */
  58523. addControl(control: BABYLON.Nullable<Control>): Container;
  58524. /**
  58525. * Removes a control from the current container
  58526. * @param control defines the control to remove
  58527. * @returns the current container
  58528. */
  58529. removeControl(control: Control): Container;
  58530. /** Gets the list of children */
  58531. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  58532. /**
  58533. * Creates a new ScrollViewer
  58534. * @param name of ScrollViewer
  58535. */
  58536. constructor(name?: string);
  58537. /** Reset the scroll viewer window to initial size */
  58538. resetWindow(): void;
  58539. protected _getTypeName(): string;
  58540. private _buildClientSizes;
  58541. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58542. protected _postMeasure(): void;
  58543. /**
  58544. * Gets or sets the mouse wheel precision
  58545. * from 0 to 1 with a default value of 0.05
  58546. * */
  58547. wheelPrecision: number;
  58548. /** Gets or sets the bar color */
  58549. barColor: string;
  58550. /** Gets or sets the size of the bar */
  58551. barSize: number;
  58552. /** Gets or sets the bar background */
  58553. barBackground: string;
  58554. /** @hidden */
  58555. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  58556. /** @hidden */
  58557. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58558. /** Releases associated resources */
  58559. dispose(): void;
  58560. }
  58561. }
  58562. declare module BABYLON.GUI {
  58563. /** Class used to render a grid */
  58564. export class DisplayGrid extends Control {
  58565. name?: string | undefined;
  58566. private _cellWidth;
  58567. private _cellHeight;
  58568. private _minorLineTickness;
  58569. private _minorLineColor;
  58570. private _majorLineTickness;
  58571. private _majorLineColor;
  58572. private _majorLineFrequency;
  58573. private _background;
  58574. private _displayMajorLines;
  58575. private _displayMinorLines;
  58576. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  58577. displayMinorLines: boolean;
  58578. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  58579. displayMajorLines: boolean;
  58580. /** Gets or sets background color (Black by default) */
  58581. background: string;
  58582. /** Gets or sets the width of each cell (20 by default) */
  58583. cellWidth: number;
  58584. /** Gets or sets the height of each cell (20 by default) */
  58585. cellHeight: number;
  58586. /** Gets or sets the tickness of minor lines (1 by default) */
  58587. minorLineTickness: number;
  58588. /** Gets or sets the color of minor lines (DarkGray by default) */
  58589. minorLineColor: string;
  58590. /** Gets or sets the tickness of major lines (2 by default) */
  58591. majorLineTickness: number;
  58592. /** Gets or sets the color of major lines (White by default) */
  58593. majorLineColor: string;
  58594. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  58595. majorLineFrequency: number;
  58596. /**
  58597. * Creates a new GridDisplayRectangle
  58598. * @param name defines the control name
  58599. */
  58600. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  58601. protected _getTypeName(): string;
  58602. }
  58603. }
  58604. declare module BABYLON.GUI {
  58605. /**
  58606. * Class used to create slider controls based on images
  58607. */
  58608. export class ImageBasedSlider extends BaseSlider {
  58609. name?: string | undefined;
  58610. private _backgroundImage;
  58611. private _thumbImage;
  58612. private _valueBarImage;
  58613. private _tempMeasure;
  58614. displayThumb: boolean;
  58615. /**
  58616. * Gets or sets the image used to render the background
  58617. */
  58618. backgroundImage: Image;
  58619. /**
  58620. * Gets or sets the image used to render the value bar
  58621. */
  58622. valueBarImage: Image;
  58623. /**
  58624. * Gets or sets the image used to render the thumb
  58625. */
  58626. thumbImage: Image;
  58627. /**
  58628. * Creates a new ImageBasedSlider
  58629. * @param name defines the control name
  58630. */
  58631. constructor(name?: string | undefined);
  58632. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58633. }
  58634. }
  58635. declare module BABYLON.GUI {
  58636. /**
  58637. * Forcing an export so that this code will execute
  58638. * @hidden
  58639. */
  58640. const name = "Statics";
  58641. }
  58642. declare module BABYLON.GUI {
  58643. /**
  58644. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  58645. */
  58646. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  58647. /**
  58648. * Define the instrumented AdvancedDynamicTexture.
  58649. */
  58650. texture: AdvancedDynamicTexture;
  58651. private _captureRenderTime;
  58652. private _renderTime;
  58653. private _captureLayoutTime;
  58654. private _layoutTime;
  58655. private _onBeginRenderObserver;
  58656. private _onEndRenderObserver;
  58657. private _onBeginLayoutObserver;
  58658. private _onEndLayoutObserver;
  58659. /**
  58660. * Gets the perf counter used to capture render time
  58661. */
  58662. readonly renderTimeCounter: BABYLON.PerfCounter;
  58663. /**
  58664. * Gets the perf counter used to capture layout time
  58665. */
  58666. readonly layoutTimeCounter: BABYLON.PerfCounter;
  58667. /**
  58668. * Enable or disable the render time capture
  58669. */
  58670. captureRenderTime: boolean;
  58671. /**
  58672. * Enable or disable the layout time capture
  58673. */
  58674. captureLayoutTime: boolean;
  58675. /**
  58676. * Instantiates a new advanced dynamic texture instrumentation.
  58677. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  58678. * @param texture Defines the AdvancedDynamicTexture to instrument
  58679. */
  58680. constructor(
  58681. /**
  58682. * Define the instrumented AdvancedDynamicTexture.
  58683. */
  58684. texture: AdvancedDynamicTexture);
  58685. /**
  58686. * Dispose and release associated resources.
  58687. */
  58688. dispose(): void;
  58689. }
  58690. }
  58691. declare module BABYLON.GUI {
  58692. /**
  58693. * Class used to create containers for controls
  58694. */
  58695. export class Container3D extends Control3D {
  58696. private _blockLayout;
  58697. /**
  58698. * Gets the list of child controls
  58699. */
  58700. protected _children: Control3D[];
  58701. /**
  58702. * Gets the list of child controls
  58703. */
  58704. readonly children: Array<Control3D>;
  58705. /**
  58706. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  58707. * This is helpful to optimize layout operation when adding multiple children in a row
  58708. */
  58709. blockLayout: boolean;
  58710. /**
  58711. * Creates a new container
  58712. * @param name defines the container name
  58713. */
  58714. constructor(name?: string);
  58715. /**
  58716. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  58717. * @returns the current container
  58718. */
  58719. updateLayout(): Container3D;
  58720. /**
  58721. * Gets a boolean indicating if the given control is in the children of this control
  58722. * @param control defines the control to check
  58723. * @returns true if the control is in the child list
  58724. */
  58725. containsControl(control: Control3D): boolean;
  58726. /**
  58727. * Adds a control to the children of this control
  58728. * @param control defines the control to add
  58729. * @returns the current container
  58730. */
  58731. addControl(control: Control3D): Container3D;
  58732. /**
  58733. * This function will be called everytime a new control is added
  58734. */
  58735. protected _arrangeChildren(): void;
  58736. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  58737. /**
  58738. * Removes a control from the children of this control
  58739. * @param control defines the control to remove
  58740. * @returns the current container
  58741. */
  58742. removeControl(control: Control3D): Container3D;
  58743. protected _getTypeName(): string;
  58744. /**
  58745. * Releases all associated resources
  58746. */
  58747. dispose(): void;
  58748. /** Control rotation will remain unchanged */
  58749. static readonly UNSET_ORIENTATION: number;
  58750. /** Control will rotate to make it look at sphere central axis */
  58751. static readonly FACEORIGIN_ORIENTATION: number;
  58752. /** Control will rotate to make it look back at sphere central axis */
  58753. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  58754. /** Control will rotate to look at z axis (0, 0, 1) */
  58755. static readonly FACEFORWARD_ORIENTATION: number;
  58756. /** Control will rotate to look at negative z axis (0, 0, -1) */
  58757. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  58758. }
  58759. }
  58760. declare module BABYLON.GUI {
  58761. /**
  58762. * Class used to manage 3D user interface
  58763. * @see http://doc.babylonjs.com/how_to/gui3d
  58764. */
  58765. export class GUI3DManager implements BABYLON.IDisposable {
  58766. private _scene;
  58767. private _sceneDisposeObserver;
  58768. private _utilityLayer;
  58769. private _rootContainer;
  58770. private _pointerObserver;
  58771. private _pointerOutObserver;
  58772. /** @hidden */ lastPickedControl: Control3D;
  58773. /** @hidden */ lastControlOver: {
  58774. [pointerId: number]: Control3D;
  58775. };
  58776. /** @hidden */ lastControlDown: {
  58777. [pointerId: number]: Control3D;
  58778. };
  58779. /**
  58780. * BABYLON.Observable raised when the point picked by the pointer events changed
  58781. */
  58782. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  58783. /** @hidden */ sharedMaterials: {
  58784. [key: string]: BABYLON.Material;
  58785. };
  58786. /** Gets the hosting scene */
  58787. readonly scene: BABYLON.Scene;
  58788. /** Gets associated utility layer */
  58789. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  58790. /**
  58791. * Creates a new GUI3DManager
  58792. * @param scene
  58793. */
  58794. constructor(scene?: BABYLON.Scene);
  58795. private _handlePointerOut;
  58796. private _doPicking;
  58797. /**
  58798. * Gets the root container
  58799. */
  58800. readonly rootContainer: Container3D;
  58801. /**
  58802. * Gets a boolean indicating if the given control is in the root child list
  58803. * @param control defines the control to check
  58804. * @returns true if the control is in the root child list
  58805. */
  58806. containsControl(control: Control3D): boolean;
  58807. /**
  58808. * Adds a control to the root child list
  58809. * @param control defines the control to add
  58810. * @returns the current manager
  58811. */
  58812. addControl(control: Control3D): GUI3DManager;
  58813. /**
  58814. * Removes a control from the root child list
  58815. * @param control defines the control to remove
  58816. * @returns the current container
  58817. */
  58818. removeControl(control: Control3D): GUI3DManager;
  58819. /**
  58820. * Releases all associated resources
  58821. */
  58822. dispose(): void;
  58823. }
  58824. }
  58825. declare module BABYLON.GUI {
  58826. /**
  58827. * Class used to transport BABYLON.Vector3 information for pointer events
  58828. */
  58829. export class Vector3WithInfo extends BABYLON.Vector3 {
  58830. /** defines the current mouse button index */
  58831. buttonIndex: number;
  58832. /**
  58833. * Creates a new Vector3WithInfo
  58834. * @param source defines the vector3 data to transport
  58835. * @param buttonIndex defines the current mouse button index
  58836. */
  58837. constructor(source: BABYLON.Vector3,
  58838. /** defines the current mouse button index */
  58839. buttonIndex?: number);
  58840. }
  58841. }
  58842. declare module BABYLON.GUI {
  58843. /**
  58844. * Class used as base class for controls
  58845. */
  58846. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  58847. /** Defines the control name */
  58848. name?: string | undefined;
  58849. /** @hidden */ host: GUI3DManager;
  58850. private _node;
  58851. private _downCount;
  58852. private _enterCount;
  58853. private _downPointerIds;
  58854. private _isVisible;
  58855. /** Gets or sets the control position in world space */
  58856. position: BABYLON.Vector3;
  58857. /** Gets or sets the control scaling in world space */
  58858. scaling: BABYLON.Vector3;
  58859. /** Callback used to start pointer enter animation */
  58860. pointerEnterAnimation: () => void;
  58861. /** Callback used to start pointer out animation */
  58862. pointerOutAnimation: () => void;
  58863. /** Callback used to start pointer down animation */
  58864. pointerDownAnimation: () => void;
  58865. /** Callback used to start pointer up animation */
  58866. pointerUpAnimation: () => void;
  58867. /**
  58868. * An event triggered when the pointer move over the control
  58869. */
  58870. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  58871. /**
  58872. * An event triggered when the pointer move out of the control
  58873. */
  58874. onPointerOutObservable: BABYLON.Observable<Control3D>;
  58875. /**
  58876. * An event triggered when the pointer taps the control
  58877. */
  58878. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  58879. /**
  58880. * An event triggered when pointer is up
  58881. */
  58882. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  58883. /**
  58884. * An event triggered when a control is clicked on (with a mouse)
  58885. */
  58886. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  58887. /**
  58888. * An event triggered when pointer enters the control
  58889. */
  58890. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  58891. /**
  58892. * Gets or sets the parent container
  58893. */
  58894. parent: BABYLON.Nullable<Container3D>;
  58895. private _behaviors;
  58896. /**
  58897. * Gets the list of attached behaviors
  58898. * @see http://doc.babylonjs.com/features/behaviour
  58899. */
  58900. readonly behaviors: BABYLON.Behavior<Control3D>[];
  58901. /**
  58902. * Attach a behavior to the control
  58903. * @see http://doc.babylonjs.com/features/behaviour
  58904. * @param behavior defines the behavior to attach
  58905. * @returns the current control
  58906. */
  58907. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  58908. /**
  58909. * Remove an attached behavior
  58910. * @see http://doc.babylonjs.com/features/behaviour
  58911. * @param behavior defines the behavior to attach
  58912. * @returns the current control
  58913. */
  58914. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  58915. /**
  58916. * Gets an attached behavior by name
  58917. * @param name defines the name of the behavior to look for
  58918. * @see http://doc.babylonjs.com/features/behaviour
  58919. * @returns null if behavior was not found else the requested behavior
  58920. */
  58921. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  58922. /** Gets or sets a boolean indicating if the control is visible */
  58923. isVisible: boolean;
  58924. /**
  58925. * Creates a new control
  58926. * @param name defines the control name
  58927. */
  58928. constructor(
  58929. /** Defines the control name */
  58930. name?: string | undefined);
  58931. /**
  58932. * Gets a string representing the class name
  58933. */
  58934. readonly typeName: string;
  58935. /**
  58936. * Get the current class name of the control.
  58937. * @returns current class name
  58938. */
  58939. getClassName(): string;
  58940. protected _getTypeName(): string;
  58941. /**
  58942. * Gets the transform node used by this control
  58943. */
  58944. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  58945. /**
  58946. * Gets the mesh used to render this control
  58947. */
  58948. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58949. /**
  58950. * Link the control as child of the given node
  58951. * @param node defines the node to link to. Use null to unlink the control
  58952. * @returns the current control
  58953. */
  58954. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  58955. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  58956. /**
  58957. * Node creation.
  58958. * Can be overriden by children
  58959. * @param scene defines the scene where the node must be attached
  58960. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  58961. */
  58962. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  58963. /**
  58964. * Affect a material to the given mesh
  58965. * @param mesh defines the mesh which will represent the control
  58966. */
  58967. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  58968. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  58969. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  58970. /** @hidden */ onPointerOut(target: Control3D): void;
  58971. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  58972. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58973. /** @hidden */
  58974. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  58975. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  58976. /** @hidden */ disposeNode(): void;
  58977. /**
  58978. * Releases all associated resources
  58979. */
  58980. dispose(): void;
  58981. }
  58982. }
  58983. declare module BABYLON.GUI {
  58984. /**
  58985. * Class used as a root to all buttons
  58986. */
  58987. export class AbstractButton3D extends Control3D {
  58988. /**
  58989. * Creates a new button
  58990. * @param name defines the control name
  58991. */
  58992. constructor(name?: string);
  58993. protected _getTypeName(): string;
  58994. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  58995. }
  58996. }
  58997. declare module BABYLON.GUI {
  58998. /**
  58999. * Class used to create a button in 3D
  59000. */
  59001. export class Button3D extends AbstractButton3D {
  59002. /** @hidden */
  59003. protected _currentMaterial: BABYLON.Material;
  59004. private _facadeTexture;
  59005. private _content;
  59006. private _contentResolution;
  59007. private _contentScaleRatio;
  59008. /**
  59009. * Gets or sets the texture resolution used to render content (512 by default)
  59010. */
  59011. contentResolution: BABYLON.int;
  59012. /**
  59013. * Gets or sets the texture scale ratio used to render content (2 by default)
  59014. */
  59015. contentScaleRatio: number;
  59016. protected _disposeFacadeTexture(): void;
  59017. protected _resetContent(): void;
  59018. /**
  59019. * Creates a new button
  59020. * @param name defines the control name
  59021. */
  59022. constructor(name?: string);
  59023. /**
  59024. * Gets or sets the GUI 2D content used to display the button's facade
  59025. */
  59026. content: Control;
  59027. /**
  59028. * Apply the facade texture (created from the content property).
  59029. * This function can be overloaded by child classes
  59030. * @param facadeTexture defines the AdvancedDynamicTexture to use
  59031. */
  59032. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59033. protected _getTypeName(): string;
  59034. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59035. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59036. /**
  59037. * Releases all associated resources
  59038. */
  59039. dispose(): void;
  59040. }
  59041. }
  59042. declare module BABYLON.GUI {
  59043. /**
  59044. * Abstract class used to create a container panel deployed on the surface of a volume
  59045. */
  59046. export abstract class VolumeBasedPanel extends Container3D {
  59047. private _columns;
  59048. private _rows;
  59049. private _rowThenColum;
  59050. private _orientation;
  59051. protected _cellWidth: number;
  59052. protected _cellHeight: number;
  59053. /**
  59054. * Gets or sets the distance between elements
  59055. */
  59056. margin: number;
  59057. /**
  59058. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  59059. * | Value | Type | Description |
  59060. * | ----- | ----------------------------------- | ----------- |
  59061. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  59062. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  59063. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  59064. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  59065. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  59066. */
  59067. orientation: number;
  59068. /**
  59069. * Gets or sets the number of columns requested (10 by default).
  59070. * The panel will automatically compute the number of rows based on number of child controls.
  59071. */
  59072. columns: BABYLON.int;
  59073. /**
  59074. * Gets or sets a the number of rows requested.
  59075. * The panel will automatically compute the number of columns based on number of child controls.
  59076. */
  59077. rows: BABYLON.int;
  59078. /**
  59079. * Creates new VolumeBasedPanel
  59080. */
  59081. constructor();
  59082. protected _arrangeChildren(): void;
  59083. /** Child classes must implement this function to provide correct control positioning */
  59084. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59085. /** Child classes can implement this function to provide additional processing */
  59086. protected _finalProcessing(): void;
  59087. }
  59088. }
  59089. declare module BABYLON.GUI {
  59090. /**
  59091. * Class used to create a container panel deployed on the surface of a cylinder
  59092. */
  59093. export class CylinderPanel extends VolumeBasedPanel {
  59094. private _radius;
  59095. /**
  59096. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  59097. */
  59098. radius: BABYLON.float;
  59099. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59100. private _cylindricalMapping;
  59101. }
  59102. }
  59103. declare module BABYLON.GUI {
  59104. /** @hidden */
  59105. export var fluentVertexShader: {
  59106. name: string;
  59107. shader: string;
  59108. };
  59109. }
  59110. declare module BABYLON.GUI {
  59111. /** @hidden */
  59112. export var fluentPixelShader: {
  59113. name: string;
  59114. shader: string;
  59115. };
  59116. }
  59117. declare module BABYLON.GUI {
  59118. /** @hidden */
  59119. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  59120. INNERGLOW: boolean;
  59121. BORDER: boolean;
  59122. HOVERLIGHT: boolean;
  59123. TEXTURE: boolean;
  59124. constructor();
  59125. }
  59126. /**
  59127. * Class used to render controls with fluent desgin
  59128. */
  59129. export class FluentMaterial extends BABYLON.PushMaterial {
  59130. /**
  59131. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  59132. */
  59133. innerGlowColorIntensity: number;
  59134. /**
  59135. * Gets or sets the inner glow color (white by default)
  59136. */
  59137. innerGlowColor: BABYLON.Color3;
  59138. /**
  59139. * Gets or sets alpha value (default is 1.0)
  59140. */
  59141. alpha: number;
  59142. /**
  59143. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  59144. */
  59145. albedoColor: BABYLON.Color3;
  59146. /**
  59147. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  59148. */
  59149. renderBorders: boolean;
  59150. /**
  59151. * Gets or sets border width (default is 0.5)
  59152. */
  59153. borderWidth: number;
  59154. /**
  59155. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  59156. */
  59157. edgeSmoothingValue: number;
  59158. /**
  59159. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  59160. */
  59161. borderMinValue: number;
  59162. /**
  59163. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  59164. */
  59165. renderHoverLight: boolean;
  59166. /**
  59167. * Gets or sets the radius used to render the hover light (default is 1.0)
  59168. */
  59169. hoverRadius: number;
  59170. /**
  59171. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  59172. */
  59173. hoverColor: BABYLON.Color4;
  59174. /**
  59175. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  59176. */
  59177. hoverPosition: BABYLON.Vector3;
  59178. private _albedoTexture;
  59179. /** Gets or sets the texture to use for albedo color */
  59180. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  59181. /**
  59182. * Creates a new Fluent material
  59183. * @param name defines the name of the material
  59184. * @param scene defines the hosting scene
  59185. */
  59186. constructor(name: string, scene: BABYLON.Scene);
  59187. needAlphaBlending(): boolean;
  59188. needAlphaTesting(): boolean;
  59189. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  59190. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  59191. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  59192. getActiveTextures(): BABYLON.BaseTexture[];
  59193. hasTexture(texture: BABYLON.BaseTexture): boolean;
  59194. dispose(forceDisposeEffect?: boolean): void;
  59195. clone(name: string): FluentMaterial;
  59196. serialize(): any;
  59197. getClassName(): string;
  59198. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  59199. }
  59200. }
  59201. declare module BABYLON.GUI {
  59202. /**
  59203. * Class used to create a holographic button in 3D
  59204. */
  59205. export class HolographicButton extends Button3D {
  59206. private _backPlate;
  59207. private _textPlate;
  59208. private _frontPlate;
  59209. private _text;
  59210. private _imageUrl;
  59211. private _shareMaterials;
  59212. private _frontMaterial;
  59213. private _backMaterial;
  59214. private _plateMaterial;
  59215. private _pickedPointObserver;
  59216. private _tooltipFade;
  59217. private _tooltipTextBlock;
  59218. private _tooltipTexture;
  59219. private _tooltipMesh;
  59220. private _tooltipHoverObserver;
  59221. private _tooltipOutObserver;
  59222. private _disposeTooltip;
  59223. /**
  59224. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  59225. */
  59226. tooltipText: BABYLON.Nullable<string>;
  59227. /**
  59228. * Gets or sets text for the button
  59229. */
  59230. text: string;
  59231. /**
  59232. * Gets or sets the image url for the button
  59233. */
  59234. imageUrl: string;
  59235. /**
  59236. * Gets the back material used by this button
  59237. */
  59238. readonly backMaterial: FluentMaterial;
  59239. /**
  59240. * Gets the front material used by this button
  59241. */
  59242. readonly frontMaterial: FluentMaterial;
  59243. /**
  59244. * Gets the plate material used by this button
  59245. */
  59246. readonly plateMaterial: BABYLON.StandardMaterial;
  59247. /**
  59248. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  59249. */
  59250. readonly shareMaterials: boolean;
  59251. /**
  59252. * Creates a new button
  59253. * @param name defines the control name
  59254. */
  59255. constructor(name?: string, shareMaterials?: boolean);
  59256. protected _getTypeName(): string;
  59257. private _rebuildContent;
  59258. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59259. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59260. private _createBackMaterial;
  59261. private _createFrontMaterial;
  59262. private _createPlateMaterial;
  59263. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  59264. /**
  59265. * Releases all associated resources
  59266. */
  59267. dispose(): void;
  59268. }
  59269. }
  59270. declare module BABYLON.GUI {
  59271. /**
  59272. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  59273. */
  59274. export class MeshButton3D extends Button3D {
  59275. /** @hidden */
  59276. protected _currentMesh: BABYLON.Mesh;
  59277. /**
  59278. * Creates a new 3D button based on a mesh
  59279. * @param mesh mesh to become a 3D button
  59280. * @param name defines the control name
  59281. */
  59282. constructor(mesh: BABYLON.Mesh, name?: string);
  59283. protected _getTypeName(): string;
  59284. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59285. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59286. }
  59287. }
  59288. declare module BABYLON.GUI {
  59289. /**
  59290. * Class used to create a container panel deployed on the surface of a plane
  59291. */
  59292. export class PlanePanel extends VolumeBasedPanel {
  59293. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59294. }
  59295. }
  59296. declare module BABYLON.GUI {
  59297. /**
  59298. * Class used to create a container panel where items get randomized planar mapping
  59299. */
  59300. export class ScatterPanel extends VolumeBasedPanel {
  59301. private _iteration;
  59302. /**
  59303. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  59304. */
  59305. iteration: BABYLON.float;
  59306. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59307. private _scatterMapping;
  59308. protected _finalProcessing(): void;
  59309. }
  59310. }
  59311. declare module BABYLON.GUI {
  59312. /**
  59313. * Class used to create a container panel deployed on the surface of a sphere
  59314. */
  59315. export class SpherePanel extends VolumeBasedPanel {
  59316. private _radius;
  59317. /**
  59318. * Gets or sets the radius of the sphere where to project controls (5 by default)
  59319. */
  59320. radius: BABYLON.float;
  59321. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59322. private _sphericalMapping;
  59323. }
  59324. }
  59325. declare module BABYLON.GUI {
  59326. /**
  59327. * Class used to create a stack panel in 3D on XY plane
  59328. */
  59329. export class StackPanel3D extends Container3D {
  59330. private _isVertical;
  59331. /**
  59332. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  59333. */
  59334. isVertical: boolean;
  59335. /**
  59336. * Gets or sets the distance between elements
  59337. */
  59338. margin: number;
  59339. /**
  59340. * Creates new StackPanel
  59341. * @param isVertical
  59342. */
  59343. constructor(isVertical?: boolean);
  59344. protected _arrangeChildren(): void;
  59345. }
  59346. }
  59347. declare module BABYLON {
  59348. /**
  59349. * Mode that determines the coordinate system to use.
  59350. */
  59351. export enum GLTFLoaderCoordinateSystemMode {
  59352. /**
  59353. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  59354. */
  59355. AUTO = 0,
  59356. /**
  59357. * Sets the useRightHandedSystem flag on the scene.
  59358. */
  59359. FORCE_RIGHT_HANDED = 1
  59360. }
  59361. /**
  59362. * Mode that determines what animations will start.
  59363. */
  59364. export enum GLTFLoaderAnimationStartMode {
  59365. /**
  59366. * No animation will start.
  59367. */
  59368. NONE = 0,
  59369. /**
  59370. * The first animation will start.
  59371. */
  59372. FIRST = 1,
  59373. /**
  59374. * All animations will start.
  59375. */
  59376. ALL = 2
  59377. }
  59378. /**
  59379. * Interface that contains the data for the glTF asset.
  59380. */
  59381. export interface IGLTFLoaderData {
  59382. /**
  59383. * Object that represents the glTF JSON.
  59384. */
  59385. json: Object;
  59386. /**
  59387. * The BIN chunk of a binary glTF.
  59388. */
  59389. bin: Nullable<ArrayBufferView>;
  59390. }
  59391. /**
  59392. * Interface for extending the loader.
  59393. */
  59394. export interface IGLTFLoaderExtension {
  59395. /**
  59396. * The name of this extension.
  59397. */
  59398. readonly name: string;
  59399. /**
  59400. * Defines whether this extension is enabled.
  59401. */
  59402. enabled: boolean;
  59403. }
  59404. /**
  59405. * Loader state.
  59406. */
  59407. export enum GLTFLoaderState {
  59408. /**
  59409. * The asset is loading.
  59410. */
  59411. LOADING = 0,
  59412. /**
  59413. * The asset is ready for rendering.
  59414. */
  59415. READY = 1,
  59416. /**
  59417. * The asset is completely loaded.
  59418. */
  59419. COMPLETE = 2
  59420. }
  59421. /** @hidden */
  59422. export interface IGLTFLoader extends IDisposable {
  59423. readonly state: Nullable<GLTFLoaderState>;
  59424. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  59425. meshes: AbstractMesh[];
  59426. particleSystems: IParticleSystem[];
  59427. skeletons: Skeleton[];
  59428. animationGroups: AnimationGroup[];
  59429. }>;
  59430. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  59431. }
  59432. /**
  59433. * File loader for loading glTF files into a scene.
  59434. */
  59435. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  59436. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59437. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59438. /**
  59439. * Raised when the asset has been parsed
  59440. */
  59441. onParsedObservable: Observable<IGLTFLoaderData>;
  59442. private _onParsedObserver;
  59443. /**
  59444. * Raised when the asset has been parsed
  59445. */
  59446. onParsed: (loaderData: IGLTFLoaderData) => void;
  59447. /**
  59448. * 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.
  59449. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  59450. * Defaults to true.
  59451. * @hidden
  59452. */
  59453. static IncrementalLoading: boolean;
  59454. /**
  59455. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  59456. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  59457. * @hidden
  59458. */
  59459. static HomogeneousCoordinates: boolean;
  59460. /**
  59461. * The coordinate system mode. Defaults to AUTO.
  59462. */
  59463. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  59464. /**
  59465. * The animation start mode. Defaults to FIRST.
  59466. */
  59467. animationStartMode: GLTFLoaderAnimationStartMode;
  59468. /**
  59469. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  59470. */
  59471. compileMaterials: boolean;
  59472. /**
  59473. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  59474. */
  59475. useClipPlane: boolean;
  59476. /**
  59477. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  59478. */
  59479. compileShadowGenerators: boolean;
  59480. /**
  59481. * Defines if the Alpha blended materials are only applied as coverage.
  59482. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  59483. * If true, no extra effects are applied to transparent pixels.
  59484. */
  59485. transparencyAsCoverage: boolean;
  59486. /**
  59487. * Function called before loading a url referenced by the asset.
  59488. */
  59489. preprocessUrlAsync: (url: string) => Promise<string>;
  59490. /**
  59491. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59492. */
  59493. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  59494. private _onMeshLoadedObserver;
  59495. /**
  59496. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59497. */
  59498. onMeshLoaded: (mesh: AbstractMesh) => void;
  59499. /**
  59500. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  59501. */
  59502. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  59503. private _onTextureLoadedObserver;
  59504. /**
  59505. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  59506. */
  59507. onTextureLoaded: (texture: BaseTexture) => void;
  59508. /**
  59509. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  59510. */
  59511. readonly onMaterialLoadedObservable: Observable<Material>;
  59512. private _onMaterialLoadedObserver;
  59513. /**
  59514. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  59515. */
  59516. onMaterialLoaded: (material: Material) => void;
  59517. /**
  59518. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  59519. */
  59520. readonly onCameraLoadedObservable: Observable<Camera>;
  59521. private _onCameraLoadedObserver;
  59522. /**
  59523. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  59524. */
  59525. onCameraLoaded: (camera: Camera) => void;
  59526. /**
  59527. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  59528. * For assets with LODs, raised when all of the LODs are complete.
  59529. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59530. */
  59531. readonly onCompleteObservable: Observable<void>;
  59532. private _onCompleteObserver;
  59533. /**
  59534. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  59535. * For assets with LODs, raised when all of the LODs are complete.
  59536. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59537. */
  59538. onComplete: () => void;
  59539. /**
  59540. * Observable raised when an error occurs.
  59541. */
  59542. readonly onErrorObservable: Observable<any>;
  59543. private _onErrorObserver;
  59544. /**
  59545. * Callback raised when an error occurs.
  59546. */
  59547. onError: (reason: any) => void;
  59548. /**
  59549. * Observable raised after the loader is disposed.
  59550. */
  59551. readonly onDisposeObservable: Observable<void>;
  59552. private _onDisposeObserver;
  59553. /**
  59554. * Callback raised after the loader is disposed.
  59555. */
  59556. onDispose: () => void;
  59557. /**
  59558. * Observable raised after a loader extension is created.
  59559. * Set additional options for a loader extension in this event.
  59560. */
  59561. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  59562. private _onExtensionLoadedObserver;
  59563. /**
  59564. * Callback raised after a loader extension is created.
  59565. */
  59566. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  59567. /**
  59568. * Defines if the loader logging is enabled.
  59569. */
  59570. loggingEnabled: boolean;
  59571. /**
  59572. * Defines if the loader should capture performance counters.
  59573. */
  59574. capturePerformanceCounters: boolean;
  59575. /**
  59576. * Defines if the loader should validate the asset.
  59577. */
  59578. validate: boolean;
  59579. /**
  59580. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  59581. */
  59582. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  59583. private _onValidatedObserver;
  59584. /**
  59585. * Callback raised after a loader extension is created.
  59586. */
  59587. onValidated: (results: IGLTFValidationResults) => void;
  59588. private _loader;
  59589. /**
  59590. * Name of the loader ("gltf")
  59591. */
  59592. name: string;
  59593. /**
  59594. * Supported file extensions of the loader (.gltf, .glb)
  59595. */
  59596. extensions: ISceneLoaderPluginExtensions;
  59597. /**
  59598. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  59599. */
  59600. dispose(): void;
  59601. /** @hidden */ clear(): void;
  59602. /**
  59603. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  59604. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  59605. * @param scene the scene the meshes should be added to
  59606. * @param data the glTF data to load
  59607. * @param rootUrl root url to load from
  59608. * @param onProgress event that fires when loading progress has occured
  59609. * @param fileName Defines the name of the file to load
  59610. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  59611. */
  59612. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  59613. meshes: AbstractMesh[];
  59614. particleSystems: IParticleSystem[];
  59615. skeletons: Skeleton[];
  59616. animationGroups: AnimationGroup[];
  59617. }>;
  59618. /**
  59619. * Imports all objects from the loaded glTF data and adds them to the scene
  59620. * @param scene the scene the objects should be added to
  59621. * @param data the glTF data to load
  59622. * @param rootUrl root url to load from
  59623. * @param onProgress event that fires when loading progress has occured
  59624. * @param fileName Defines the name of the file to load
  59625. * @returns a promise which completes when objects have been loaded to the scene
  59626. */
  59627. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  59628. /**
  59629. * Load into an asset container.
  59630. * @param scene The scene to load into
  59631. * @param data The data to import
  59632. * @param rootUrl The root url for scene and resources
  59633. * @param onProgress The callback when the load progresses
  59634. * @param fileName Defines the name of the file to load
  59635. * @returns The loaded asset container
  59636. */
  59637. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  59638. /**
  59639. * If the data string can be loaded directly.
  59640. * @param data string contianing the file data
  59641. * @returns if the data can be loaded directly
  59642. */
  59643. canDirectLoad(data: string): boolean;
  59644. /**
  59645. * Rewrites a url by combining a root url and response url.
  59646. */
  59647. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  59648. /**
  59649. * Instantiates a glTF file loader plugin.
  59650. * @returns the created plugin
  59651. */
  59652. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  59653. /**
  59654. * The loader state or null if the loader is not active.
  59655. */
  59656. readonly loaderState: Nullable<GLTFLoaderState>;
  59657. /**
  59658. * Returns a promise that resolves when the asset is completely loaded.
  59659. * @returns a promise that resolves when the asset is completely loaded.
  59660. */
  59661. whenCompleteAsync(): Promise<void>;
  59662. private _parseAsync;
  59663. private _validateAsync;
  59664. private _getLoader;
  59665. private _unpackBinary;
  59666. private _unpackBinaryV1;
  59667. private _unpackBinaryV2;
  59668. private static _parseVersion;
  59669. private static _compareVersion;
  59670. private static _decodeBufferToText;
  59671. private static readonly _logSpaces;
  59672. private _logIndentLevel;
  59673. private _loggingEnabled;
  59674. /** @hidden */ log: (message: string) => void;
  59675. /** @hidden */ logOpen(message: string): void;
  59676. /** @hidden */ logClose(): void;
  59677. private _logEnabled;
  59678. private _logDisabled;
  59679. private _capturePerformanceCounters;
  59680. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  59681. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  59682. private _startPerformanceCounterEnabled;
  59683. private _startPerformanceCounterDisabled;
  59684. private _endPerformanceCounterEnabled;
  59685. private _endPerformanceCounterDisabled;
  59686. }
  59687. }
  59688. declare module BABYLON.GLTF1 {
  59689. /**
  59690. * Enums
  59691. * @hidden
  59692. */
  59693. export enum EComponentType {
  59694. BYTE = 5120,
  59695. UNSIGNED_BYTE = 5121,
  59696. SHORT = 5122,
  59697. UNSIGNED_SHORT = 5123,
  59698. FLOAT = 5126
  59699. }
  59700. /** @hidden */
  59701. export enum EShaderType {
  59702. FRAGMENT = 35632,
  59703. VERTEX = 35633
  59704. }
  59705. /** @hidden */
  59706. export enum EParameterType {
  59707. BYTE = 5120,
  59708. UNSIGNED_BYTE = 5121,
  59709. SHORT = 5122,
  59710. UNSIGNED_SHORT = 5123,
  59711. INT = 5124,
  59712. UNSIGNED_INT = 5125,
  59713. FLOAT = 5126,
  59714. FLOAT_VEC2 = 35664,
  59715. FLOAT_VEC3 = 35665,
  59716. FLOAT_VEC4 = 35666,
  59717. INT_VEC2 = 35667,
  59718. INT_VEC3 = 35668,
  59719. INT_VEC4 = 35669,
  59720. BOOL = 35670,
  59721. BOOL_VEC2 = 35671,
  59722. BOOL_VEC3 = 35672,
  59723. BOOL_VEC4 = 35673,
  59724. FLOAT_MAT2 = 35674,
  59725. FLOAT_MAT3 = 35675,
  59726. FLOAT_MAT4 = 35676,
  59727. SAMPLER_2D = 35678
  59728. }
  59729. /** @hidden */
  59730. export enum ETextureWrapMode {
  59731. CLAMP_TO_EDGE = 33071,
  59732. MIRRORED_REPEAT = 33648,
  59733. REPEAT = 10497
  59734. }
  59735. /** @hidden */
  59736. export enum ETextureFilterType {
  59737. NEAREST = 9728,
  59738. LINEAR = 9728,
  59739. NEAREST_MIPMAP_NEAREST = 9984,
  59740. LINEAR_MIPMAP_NEAREST = 9985,
  59741. NEAREST_MIPMAP_LINEAR = 9986,
  59742. LINEAR_MIPMAP_LINEAR = 9987
  59743. }
  59744. /** @hidden */
  59745. export enum ETextureFormat {
  59746. ALPHA = 6406,
  59747. RGB = 6407,
  59748. RGBA = 6408,
  59749. LUMINANCE = 6409,
  59750. LUMINANCE_ALPHA = 6410
  59751. }
  59752. /** @hidden */
  59753. export enum ECullingType {
  59754. FRONT = 1028,
  59755. BACK = 1029,
  59756. FRONT_AND_BACK = 1032
  59757. }
  59758. /** @hidden */
  59759. export enum EBlendingFunction {
  59760. ZERO = 0,
  59761. ONE = 1,
  59762. SRC_COLOR = 768,
  59763. ONE_MINUS_SRC_COLOR = 769,
  59764. DST_COLOR = 774,
  59765. ONE_MINUS_DST_COLOR = 775,
  59766. SRC_ALPHA = 770,
  59767. ONE_MINUS_SRC_ALPHA = 771,
  59768. DST_ALPHA = 772,
  59769. ONE_MINUS_DST_ALPHA = 773,
  59770. CONSTANT_COLOR = 32769,
  59771. ONE_MINUS_CONSTANT_COLOR = 32770,
  59772. CONSTANT_ALPHA = 32771,
  59773. ONE_MINUS_CONSTANT_ALPHA = 32772,
  59774. SRC_ALPHA_SATURATE = 776
  59775. }
  59776. /** @hidden */
  59777. export interface IGLTFProperty {
  59778. extensions?: {
  59779. [key: string]: any;
  59780. };
  59781. extras?: Object;
  59782. }
  59783. /** @hidden */
  59784. export interface IGLTFChildRootProperty extends IGLTFProperty {
  59785. name?: string;
  59786. }
  59787. /** @hidden */
  59788. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  59789. bufferView: string;
  59790. byteOffset: number;
  59791. byteStride: number;
  59792. count: number;
  59793. type: string;
  59794. componentType: EComponentType;
  59795. max?: number[];
  59796. min?: number[];
  59797. name?: string;
  59798. }
  59799. /** @hidden */
  59800. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  59801. buffer: string;
  59802. byteOffset: number;
  59803. byteLength: number;
  59804. byteStride: number;
  59805. target?: number;
  59806. }
  59807. /** @hidden */
  59808. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  59809. uri: string;
  59810. byteLength?: number;
  59811. type?: string;
  59812. }
  59813. /** @hidden */
  59814. export interface IGLTFShader extends IGLTFChildRootProperty {
  59815. uri: string;
  59816. type: EShaderType;
  59817. }
  59818. /** @hidden */
  59819. export interface IGLTFProgram extends IGLTFChildRootProperty {
  59820. attributes: string[];
  59821. fragmentShader: string;
  59822. vertexShader: string;
  59823. }
  59824. /** @hidden */
  59825. export interface IGLTFTechniqueParameter {
  59826. type: number;
  59827. count?: number;
  59828. semantic?: string;
  59829. node?: string;
  59830. value?: number | boolean | string | Array<any>;
  59831. source?: string;
  59832. babylonValue?: any;
  59833. }
  59834. /** @hidden */
  59835. export interface IGLTFTechniqueCommonProfile {
  59836. lightingModel: string;
  59837. texcoordBindings: Object;
  59838. parameters?: Array<any>;
  59839. }
  59840. /** @hidden */
  59841. export interface IGLTFTechniqueStatesFunctions {
  59842. blendColor?: number[];
  59843. blendEquationSeparate?: number[];
  59844. blendFuncSeparate?: number[];
  59845. colorMask: boolean[];
  59846. cullFace: number[];
  59847. }
  59848. /** @hidden */
  59849. export interface IGLTFTechniqueStates {
  59850. enable: number[];
  59851. functions: IGLTFTechniqueStatesFunctions;
  59852. }
  59853. /** @hidden */
  59854. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  59855. parameters: {
  59856. [key: string]: IGLTFTechniqueParameter;
  59857. };
  59858. program: string;
  59859. attributes: {
  59860. [key: string]: string;
  59861. };
  59862. uniforms: {
  59863. [key: string]: string;
  59864. };
  59865. states: IGLTFTechniqueStates;
  59866. }
  59867. /** @hidden */
  59868. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  59869. technique?: string;
  59870. values: string[];
  59871. }
  59872. /** @hidden */
  59873. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  59874. attributes: {
  59875. [key: string]: string;
  59876. };
  59877. indices: string;
  59878. material: string;
  59879. mode?: number;
  59880. }
  59881. /** @hidden */
  59882. export interface IGLTFMesh extends IGLTFChildRootProperty {
  59883. primitives: IGLTFMeshPrimitive[];
  59884. }
  59885. /** @hidden */
  59886. export interface IGLTFImage extends IGLTFChildRootProperty {
  59887. uri: string;
  59888. }
  59889. /** @hidden */
  59890. export interface IGLTFSampler extends IGLTFChildRootProperty {
  59891. magFilter?: number;
  59892. minFilter?: number;
  59893. wrapS?: number;
  59894. wrapT?: number;
  59895. }
  59896. /** @hidden */
  59897. export interface IGLTFTexture extends IGLTFChildRootProperty {
  59898. sampler: string;
  59899. source: string;
  59900. format?: ETextureFormat;
  59901. internalFormat?: ETextureFormat;
  59902. target?: number;
  59903. type?: number;
  59904. babylonTexture?: Texture;
  59905. }
  59906. /** @hidden */
  59907. export interface IGLTFAmbienLight {
  59908. color?: number[];
  59909. }
  59910. /** @hidden */
  59911. export interface IGLTFDirectionalLight {
  59912. color?: number[];
  59913. }
  59914. /** @hidden */
  59915. export interface IGLTFPointLight {
  59916. color?: number[];
  59917. constantAttenuation?: number;
  59918. linearAttenuation?: number;
  59919. quadraticAttenuation?: number;
  59920. }
  59921. /** @hidden */
  59922. export interface IGLTFSpotLight {
  59923. color?: number[];
  59924. constantAttenuation?: number;
  59925. fallOfAngle?: number;
  59926. fallOffExponent?: number;
  59927. linearAttenuation?: number;
  59928. quadraticAttenuation?: number;
  59929. }
  59930. /** @hidden */
  59931. export interface IGLTFLight extends IGLTFChildRootProperty {
  59932. type: string;
  59933. }
  59934. /** @hidden */
  59935. export interface IGLTFCameraOrthographic {
  59936. xmag: number;
  59937. ymag: number;
  59938. zfar: number;
  59939. znear: number;
  59940. }
  59941. /** @hidden */
  59942. export interface IGLTFCameraPerspective {
  59943. aspectRatio: number;
  59944. yfov: number;
  59945. zfar: number;
  59946. znear: number;
  59947. }
  59948. /** @hidden */
  59949. export interface IGLTFCamera extends IGLTFChildRootProperty {
  59950. type: string;
  59951. }
  59952. /** @hidden */
  59953. export interface IGLTFAnimationChannelTarget {
  59954. id: string;
  59955. path: string;
  59956. }
  59957. /** @hidden */
  59958. export interface IGLTFAnimationChannel {
  59959. sampler: string;
  59960. target: IGLTFAnimationChannelTarget;
  59961. }
  59962. /** @hidden */
  59963. export interface IGLTFAnimationSampler {
  59964. input: string;
  59965. output: string;
  59966. interpolation?: string;
  59967. }
  59968. /** @hidden */
  59969. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  59970. channels?: IGLTFAnimationChannel[];
  59971. parameters?: {
  59972. [key: string]: string;
  59973. };
  59974. samplers?: {
  59975. [key: string]: IGLTFAnimationSampler;
  59976. };
  59977. }
  59978. /** @hidden */
  59979. export interface IGLTFNodeInstanceSkin {
  59980. skeletons: string[];
  59981. skin: string;
  59982. meshes: string[];
  59983. }
  59984. /** @hidden */
  59985. export interface IGLTFSkins extends IGLTFChildRootProperty {
  59986. bindShapeMatrix: number[];
  59987. inverseBindMatrices: string;
  59988. jointNames: string[];
  59989. babylonSkeleton?: Skeleton;
  59990. }
  59991. /** @hidden */
  59992. export interface IGLTFNode extends IGLTFChildRootProperty {
  59993. camera?: string;
  59994. children: string[];
  59995. skin?: string;
  59996. jointName?: string;
  59997. light?: string;
  59998. matrix: number[];
  59999. mesh?: string;
  60000. meshes?: string[];
  60001. rotation?: number[];
  60002. scale?: number[];
  60003. translation?: number[];
  60004. babylonNode?: Node;
  60005. }
  60006. /** @hidden */
  60007. export interface IGLTFScene extends IGLTFChildRootProperty {
  60008. nodes: string[];
  60009. }
  60010. /** @hidden */
  60011. export interface IGLTFRuntime {
  60012. extensions: {
  60013. [key: string]: any;
  60014. };
  60015. accessors: {
  60016. [key: string]: IGLTFAccessor;
  60017. };
  60018. buffers: {
  60019. [key: string]: IGLTFBuffer;
  60020. };
  60021. bufferViews: {
  60022. [key: string]: IGLTFBufferView;
  60023. };
  60024. meshes: {
  60025. [key: string]: IGLTFMesh;
  60026. };
  60027. lights: {
  60028. [key: string]: IGLTFLight;
  60029. };
  60030. cameras: {
  60031. [key: string]: IGLTFCamera;
  60032. };
  60033. nodes: {
  60034. [key: string]: IGLTFNode;
  60035. };
  60036. images: {
  60037. [key: string]: IGLTFImage;
  60038. };
  60039. textures: {
  60040. [key: string]: IGLTFTexture;
  60041. };
  60042. shaders: {
  60043. [key: string]: IGLTFShader;
  60044. };
  60045. programs: {
  60046. [key: string]: IGLTFProgram;
  60047. };
  60048. samplers: {
  60049. [key: string]: IGLTFSampler;
  60050. };
  60051. techniques: {
  60052. [key: string]: IGLTFTechnique;
  60053. };
  60054. materials: {
  60055. [key: string]: IGLTFMaterial;
  60056. };
  60057. animations: {
  60058. [key: string]: IGLTFAnimation;
  60059. };
  60060. skins: {
  60061. [key: string]: IGLTFSkins;
  60062. };
  60063. currentScene?: Object;
  60064. scenes: {
  60065. [key: string]: IGLTFScene;
  60066. };
  60067. extensionsUsed: string[];
  60068. extensionsRequired?: string[];
  60069. buffersCount: number;
  60070. shaderscount: number;
  60071. scene: Scene;
  60072. rootUrl: string;
  60073. loadedBufferCount: number;
  60074. loadedBufferViews: {
  60075. [name: string]: ArrayBufferView;
  60076. };
  60077. loadedShaderCount: number;
  60078. importOnlyMeshes: boolean;
  60079. importMeshesNames?: string[];
  60080. dummyNodes: Node[];
  60081. }
  60082. /** @hidden */
  60083. export interface INodeToRoot {
  60084. bone: Bone;
  60085. node: IGLTFNode;
  60086. id: string;
  60087. }
  60088. /** @hidden */
  60089. export interface IJointNode {
  60090. node: IGLTFNode;
  60091. id: string;
  60092. }
  60093. }
  60094. declare module BABYLON.GLTF1 {
  60095. /**
  60096. * Utils functions for GLTF
  60097. * @hidden
  60098. */
  60099. export class GLTFUtils {
  60100. /**
  60101. * Sets the given "parameter" matrix
  60102. * @param scene: the Scene object
  60103. * @param source: the source node where to pick the matrix
  60104. * @param parameter: the GLTF technique parameter
  60105. * @param uniformName: the name of the shader's uniform
  60106. * @param shaderMaterial: the shader material
  60107. */
  60108. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  60109. /**
  60110. * Sets the given "parameter" matrix
  60111. * @param shaderMaterial: the shader material
  60112. * @param uniform: the name of the shader's uniform
  60113. * @param value: the value of the uniform
  60114. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  60115. */
  60116. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  60117. /**
  60118. * Returns the wrap mode of the texture
  60119. * @param mode: the mode value
  60120. */
  60121. static GetWrapMode(mode: number): number;
  60122. /**
  60123. * Returns the byte stride giving an accessor
  60124. * @param accessor: the GLTF accessor objet
  60125. */
  60126. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  60127. /**
  60128. * Returns the texture filter mode giving a mode value
  60129. * @param mode: the filter mode value
  60130. */
  60131. static GetTextureFilterMode(mode: number): ETextureFilterType;
  60132. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  60133. /**
  60134. * Returns a buffer from its accessor
  60135. * @param gltfRuntime: the GLTF runtime
  60136. * @param accessor: the GLTF accessor
  60137. */
  60138. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  60139. /**
  60140. * Decodes a buffer view into a string
  60141. * @param view: the buffer view
  60142. */
  60143. static DecodeBufferToText(view: ArrayBufferView): string;
  60144. /**
  60145. * Returns the default material of gltf. Related to
  60146. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  60147. * @param scene: the Babylon.js scene
  60148. */
  60149. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  60150. private static _DefaultMaterial;
  60151. }
  60152. }
  60153. declare module BABYLON.GLTF1 {
  60154. /**
  60155. * Implementation of the base glTF spec
  60156. * @hidden
  60157. */
  60158. export class GLTFLoaderBase {
  60159. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  60160. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60161. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  60162. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60163. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  60164. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60165. }
  60166. /**
  60167. * glTF V1 Loader
  60168. * @hidden
  60169. */
  60170. export class GLTFLoader implements IGLTFLoader {
  60171. static Extensions: {
  60172. [name: string]: GLTFLoaderExtension;
  60173. };
  60174. static RegisterExtension(extension: GLTFLoaderExtension): void;
  60175. state: Nullable<GLTFLoaderState>;
  60176. dispose(): void;
  60177. private _importMeshAsync;
  60178. /**
  60179. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  60180. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  60181. * @param scene the scene the meshes should be added to
  60182. * @param data gltf data containing information of the meshes in a loaded file
  60183. * @param rootUrl root url to load from
  60184. * @param onProgress event that fires when loading progress has occured
  60185. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  60186. */
  60187. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  60188. meshes: AbstractMesh[];
  60189. particleSystems: IParticleSystem[];
  60190. skeletons: Skeleton[];
  60191. animationGroups: AnimationGroup[];
  60192. }>;
  60193. private _loadAsync;
  60194. /**
  60195. * Imports all objects from a loaded gltf file and adds them to the scene
  60196. * @param scene the scene the objects should be added to
  60197. * @param data gltf data containing information of the meshes in a loaded file
  60198. * @param rootUrl root url to load from
  60199. * @param onProgress event that fires when loading progress has occured
  60200. * @returns a promise which completes when objects have been loaded to the scene
  60201. */
  60202. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  60203. private _loadShadersAsync;
  60204. private _loadBuffersAsync;
  60205. private _createNodes;
  60206. }
  60207. /** @hidden */
  60208. export abstract class GLTFLoaderExtension {
  60209. private _name;
  60210. constructor(name: string);
  60211. readonly name: string;
  60212. /**
  60213. * Defines an override for loading the runtime
  60214. * Return true to stop further extensions from loading the runtime
  60215. */
  60216. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  60217. /**
  60218. * Defines an onverride for creating gltf runtime
  60219. * Return true to stop further extensions from creating the runtime
  60220. */
  60221. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  60222. /**
  60223. * Defines an override for loading buffers
  60224. * Return true to stop further extensions from loading this buffer
  60225. */
  60226. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  60227. /**
  60228. * Defines an override for loading texture buffers
  60229. * Return true to stop further extensions from loading this texture data
  60230. */
  60231. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60232. /**
  60233. * Defines an override for creating textures
  60234. * Return true to stop further extensions from loading this texture
  60235. */
  60236. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  60237. /**
  60238. * Defines an override for loading shader strings
  60239. * Return true to stop further extensions from loading this shader data
  60240. */
  60241. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60242. /**
  60243. * Defines an override for loading materials
  60244. * Return true to stop further extensions from loading this material
  60245. */
  60246. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60247. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  60248. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  60249. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60250. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60251. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  60252. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60253. private static LoadTextureBufferAsync;
  60254. private static CreateTextureAsync;
  60255. private static ApplyExtensions;
  60256. }
  60257. }
  60258. declare module BABYLON.GLTF1 {
  60259. /** @hidden */
  60260. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  60261. private _bin;
  60262. constructor();
  60263. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  60264. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60265. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60266. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60267. }
  60268. }
  60269. declare module BABYLON.GLTF1 {
  60270. /** @hidden */
  60271. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  60272. constructor();
  60273. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  60274. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60275. private _loadTexture;
  60276. }
  60277. }
  60278. declare module BABYLON.GLTF2.Loader {
  60279. /**
  60280. * Loader interface with an index field.
  60281. */
  60282. export interface IArrayItem {
  60283. /**
  60284. * The index of this item in the array.
  60285. */
  60286. index: number;
  60287. }
  60288. /**
  60289. * Loader interface with additional members.
  60290. */
  60291. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  60292. /** @hidden */ data?: Promise<ArrayBufferView>;
  60293. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  60294. }
  60295. /**
  60296. * Loader interface with additional members.
  60297. */
  60298. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  60299. }
  60300. /** @hidden */
  60301. export interface _IAnimationSamplerData {
  60302. input: Float32Array;
  60303. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  60304. output: Float32Array;
  60305. }
  60306. /**
  60307. * Loader interface with additional members.
  60308. */
  60309. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  60310. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  60311. }
  60312. /**
  60313. * Loader interface with additional members.
  60314. */
  60315. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  60316. channels: IAnimationChannel[];
  60317. samplers: IAnimationSampler[];
  60318. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  60319. }
  60320. /**
  60321. * Loader interface with additional members.
  60322. */
  60323. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  60324. /** @hidden */ data?: Promise<ArrayBufferView>;
  60325. }
  60326. /**
  60327. * Loader interface with additional members.
  60328. */
  60329. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  60330. /** @hidden */ data?: Promise<ArrayBufferView>;
  60331. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  60332. }
  60333. /**
  60334. * Loader interface with additional members.
  60335. */
  60336. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  60337. }
  60338. /**
  60339. * Loader interface with additional members.
  60340. */
  60341. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  60342. /** @hidden */ data?: Promise<ArrayBufferView>;
  60343. }
  60344. /**
  60345. * Loader interface with additional members.
  60346. */
  60347. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  60348. }
  60349. /**
  60350. * Loader interface with additional members.
  60351. */
  60352. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  60353. }
  60354. /**
  60355. * Loader interface with additional members.
  60356. */
  60357. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  60358. baseColorTexture?: ITextureInfo;
  60359. metallicRoughnessTexture?: ITextureInfo;
  60360. }
  60361. /**
  60362. * Loader interface with additional members.
  60363. */
  60364. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  60365. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  60366. normalTexture?: IMaterialNormalTextureInfo;
  60367. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60368. emissiveTexture?: ITextureInfo;
  60369. /** @hidden */ data?: {
  60370. [babylonDrawMode: number]: {
  60371. babylonMaterial: Material;
  60372. babylonMeshes: AbstractMesh[];
  60373. promise: Promise<void>;
  60374. };
  60375. };
  60376. }
  60377. /**
  60378. * Loader interface with additional members.
  60379. */
  60380. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  60381. primitives: IMeshPrimitive[];
  60382. }
  60383. /**
  60384. * Loader interface with additional members.
  60385. */
  60386. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  60387. /** @hidden */ instanceData?: {
  60388. babylonSourceMesh: Mesh;
  60389. promise: Promise<any>;
  60390. };
  60391. }
  60392. /**
  60393. * Loader interface with additional members.
  60394. */
  60395. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  60396. /**
  60397. * The parent glTF node.
  60398. */
  60399. parent?: INode;
  60400. /** @hidden */ babylonTransformNode?: TransformNode;
  60401. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  60402. /** @hidden */ babylonBones?: Bone[];
  60403. /** @hidden */ numMorphTargets?: number;
  60404. }
  60405. /** @hidden */
  60406. export interface _ISamplerData {
  60407. noMipMaps: boolean;
  60408. samplingMode: number;
  60409. wrapU: number;
  60410. wrapV: number;
  60411. }
  60412. /**
  60413. * Loader interface with additional members.
  60414. */
  60415. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  60416. /** @hidden */ data?: _ISamplerData;
  60417. }
  60418. /**
  60419. * Loader interface with additional members.
  60420. */
  60421. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  60422. }
  60423. /**
  60424. * Loader interface with additional members.
  60425. */
  60426. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  60427. /** @hidden */ data?: {
  60428. babylonSkeleton: Skeleton;
  60429. promise: Promise<void>;
  60430. };
  60431. }
  60432. /**
  60433. * Loader interface with additional members.
  60434. */
  60435. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  60436. }
  60437. /**
  60438. * Loader interface with additional members.
  60439. */
  60440. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  60441. }
  60442. /**
  60443. * Loader interface with additional members.
  60444. */
  60445. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  60446. accessors?: IAccessor[];
  60447. animations?: IAnimation[];
  60448. buffers?: IBuffer[];
  60449. bufferViews?: IBufferView[];
  60450. cameras?: ICamera[];
  60451. images?: IImage[];
  60452. materials?: IMaterial[];
  60453. meshes?: IMesh[];
  60454. nodes?: INode[];
  60455. samplers?: ISampler[];
  60456. scenes?: IScene[];
  60457. skins?: ISkin[];
  60458. textures?: ITexture[];
  60459. }
  60460. }
  60461. declare module BABYLON.GLTF2 {
  60462. /**
  60463. * Interface for a glTF loader extension.
  60464. */
  60465. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  60466. /**
  60467. * Called after the loader state changes to LOADING.
  60468. */
  60469. onLoading?(): void;
  60470. /**
  60471. * Called after the loader state changes to READY.
  60472. */
  60473. onReady?(): void;
  60474. /**
  60475. * Define this method to modify the default behavior when loading scenes.
  60476. * @param context The context when loading the asset
  60477. * @param scene The glTF scene property
  60478. * @returns A promise that resolves when the load is complete or null if not handled
  60479. */
  60480. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  60481. /**
  60482. * Define this method to modify the default behavior when loading nodes.
  60483. * @param context The context when loading the asset
  60484. * @param node The glTF node property
  60485. * @param assign A function called synchronously after parsing the glTF properties
  60486. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  60487. */
  60488. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60489. /**
  60490. * Define this method to modify the default behavior when loading cameras.
  60491. * @param context The context when loading the asset
  60492. * @param camera The glTF camera property
  60493. * @param assign A function called synchronously after parsing the glTF properties
  60494. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  60495. */
  60496. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  60497. /**
  60498. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  60499. * @param context The context when loading the asset
  60500. * @param primitive The glTF mesh primitive property
  60501. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  60502. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60503. /**
  60504. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  60505. * @param context The context when loading the asset
  60506. * @param material The glTF material property
  60507. * @param assign A function called synchronously after parsing the glTF properties
  60508. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  60509. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  60510. /**
  60511. * Define this method to modify the default behavior when creating materials.
  60512. * @param context The context when loading the asset
  60513. * @param material The glTF material property
  60514. * @param babylonDrawMode The draw mode for the Babylon material
  60515. * @returns The Babylon material or null if not handled
  60516. */
  60517. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  60518. /**
  60519. * Define this method to modify the default behavior when loading material properties.
  60520. * @param context The context when loading the asset
  60521. * @param material The glTF material property
  60522. * @param babylonMaterial The Babylon material
  60523. * @returns A promise that resolves when the load is complete or null if not handled
  60524. */
  60525. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60526. /**
  60527. * Define this method to modify the default behavior when loading texture infos.
  60528. * @param context The context when loading the asset
  60529. * @param textureInfo The glTF texture info property
  60530. * @param assign A function called synchronously after parsing the glTF properties
  60531. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  60532. */
  60533. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60534. /**
  60535. * Define this method to modify the default behavior when loading animations.
  60536. * @param context The context when loading the asset
  60537. * @param animation The glTF animation property
  60538. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  60539. */
  60540. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60541. /**
  60542. * Define this method to modify the default behavior when loading skins.
  60543. * @param context The context when loading the asset
  60544. * @param node The glTF node property
  60545. * @param skin The glTF skin property
  60546. * @returns A promise that resolves when the load is complete or null if not handled
  60547. */ loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  60548. /**
  60549. * Define this method to modify the default behavior when loading uris.
  60550. * @param context The context when loading the asset
  60551. * @param property The glTF property associated with the uri
  60552. * @param uri The uri to load
  60553. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  60554. */ loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  60555. }
  60556. }
  60557. declare module BABYLON.GLTF2 {
  60558. /**
  60559. * Helper class for working with arrays when loading the glTF asset
  60560. */
  60561. export class ArrayItem {
  60562. /**
  60563. * Gets an item from the given array.
  60564. * @param context The context when loading the asset
  60565. * @param array The array to get the item from
  60566. * @param index The index to the array
  60567. * @returns The array item
  60568. */
  60569. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  60570. /**
  60571. * Assign an `index` field to each item of the given array.
  60572. * @param array The array of items
  60573. */
  60574. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  60575. }
  60576. /**
  60577. * The glTF 2.0 loader
  60578. */
  60579. export class GLTFLoader implements IGLTFLoader {
  60580. /** @hidden */ completePromises: Promise<any>[];
  60581. private _disposed;
  60582. private _parent;
  60583. private _state;
  60584. private _extensions;
  60585. private _rootUrl;
  60586. private _fileName;
  60587. private _uniqueRootUrl;
  60588. private _gltf;
  60589. private _babylonScene;
  60590. private _rootBabylonMesh;
  60591. private _defaultBabylonMaterialData;
  60592. private _progressCallback?;
  60593. private _requests;
  60594. private static readonly _DefaultSampler;
  60595. private static _ExtensionNames;
  60596. private static _ExtensionFactories;
  60597. /**
  60598. * Registers a loader extension.
  60599. * @param name The name of the loader extension.
  60600. * @param factory The factory function that creates the loader extension.
  60601. */
  60602. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  60603. /**
  60604. * Unregisters a loader extension.
  60605. * @param name The name of the loader extenion.
  60606. * @returns A boolean indicating whether the extension has been unregistered
  60607. */
  60608. static UnregisterExtension(name: string): boolean;
  60609. /**
  60610. * Gets the loader state.
  60611. */
  60612. readonly state: Nullable<GLTFLoaderState>;
  60613. /**
  60614. * The glTF object parsed from the JSON.
  60615. */
  60616. readonly gltf: IGLTF;
  60617. /**
  60618. * The Babylon scene when loading the asset.
  60619. */
  60620. readonly babylonScene: Scene;
  60621. /**
  60622. * The root Babylon mesh when loading the asset.
  60623. */
  60624. readonly rootBabylonMesh: Mesh;
  60625. /** @hidden */
  60626. constructor(parent: GLTFFileLoader);
  60627. /** @hidden */
  60628. dispose(): void;
  60629. /** @hidden */
  60630. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  60631. meshes: AbstractMesh[];
  60632. particleSystems: IParticleSystem[];
  60633. skeletons: Skeleton[];
  60634. animationGroups: AnimationGroup[];
  60635. }>;
  60636. /** @hidden */
  60637. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  60638. private _loadAsync;
  60639. private _loadData;
  60640. private _setupData;
  60641. private _loadExtensions;
  60642. private _checkExtensions;
  60643. private _setState;
  60644. private _createRootNode;
  60645. /**
  60646. * Loads a glTF scene.
  60647. * @param context The context when loading the asset
  60648. * @param scene The glTF scene property
  60649. * @returns A promise that resolves when the load is complete
  60650. */
  60651. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  60652. private _forEachPrimitive;
  60653. private _getMeshes;
  60654. private _getSkeletons;
  60655. private _getAnimationGroups;
  60656. private _startAnimations;
  60657. /**
  60658. * Loads a glTF node.
  60659. * @param context The context when loading the asset
  60660. * @param node The glTF node property
  60661. * @param assign A function called synchronously after parsing the glTF properties
  60662. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  60663. */
  60664. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  60665. private _loadMeshAsync;
  60666. private _loadMeshPrimitiveAsync;
  60667. private _loadVertexDataAsync;
  60668. private _createMorphTargets;
  60669. private _loadMorphTargetsAsync;
  60670. private _loadMorphTargetVertexDataAsync;
  60671. private static _LoadTransform;
  60672. private _loadSkinAsync;
  60673. private _loadBones;
  60674. private _loadBone;
  60675. private _loadSkinInverseBindMatricesDataAsync;
  60676. private _updateBoneMatrices;
  60677. private _getNodeMatrix;
  60678. /**
  60679. * Loads a glTF camera.
  60680. * @param context The context when loading the asset
  60681. * @param camera The glTF camera property
  60682. * @param assign A function called synchronously after parsing the glTF properties
  60683. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  60684. */
  60685. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  60686. private _loadAnimationsAsync;
  60687. /**
  60688. * Loads a glTF animation.
  60689. * @param context The context when loading the asset
  60690. * @param animation The glTF animation property
  60691. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  60692. */
  60693. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  60694. private _loadAnimationChannelAsync;
  60695. private _loadAnimationSamplerAsync;
  60696. private _loadBufferAsync;
  60697. /**
  60698. * Loads a glTF buffer view.
  60699. * @param context The context when loading the asset
  60700. * @param bufferView The glTF buffer view property
  60701. * @returns A promise that resolves with the loaded data when the load is complete
  60702. */
  60703. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  60704. private _loadIndicesAccessorAsync;
  60705. private _loadFloatAccessorAsync;
  60706. private _loadVertexBufferViewAsync;
  60707. private _loadVertexAccessorAsync;
  60708. private _loadMaterialMetallicRoughnessPropertiesAsync;
  60709. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  60710. private _createDefaultMaterial;
  60711. /**
  60712. * Creates a Babylon material from a glTF material.
  60713. * @param context The context when loading the asset
  60714. * @param material The glTF material property
  60715. * @param babylonDrawMode The draw mode for the Babylon material
  60716. * @returns The Babylon material
  60717. */
  60718. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  60719. /**
  60720. * Loads properties from a glTF material into a Babylon material.
  60721. * @param context The context when loading the asset
  60722. * @param material The glTF material property
  60723. * @param babylonMaterial The Babylon material
  60724. * @returns A promise that resolves when the load is complete
  60725. */
  60726. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  60727. /**
  60728. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  60729. * @param context The context when loading the asset
  60730. * @param material The glTF material property
  60731. * @param babylonMaterial The Babylon material
  60732. * @returns A promise that resolves when the load is complete
  60733. */
  60734. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  60735. /**
  60736. * Loads the alpha properties from a glTF material into a Babylon material.
  60737. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  60738. * @param context The context when loading the asset
  60739. * @param material The glTF material property
  60740. * @param babylonMaterial The Babylon material
  60741. */
  60742. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  60743. /**
  60744. * Loads a glTF texture info.
  60745. * @param context The context when loading the asset
  60746. * @param textureInfo The glTF texture info property
  60747. * @param assign A function called synchronously after parsing the glTF properties
  60748. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  60749. */
  60750. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  60751. private _loadTextureAsync;
  60752. private _loadSampler;
  60753. /**
  60754. * Loads a glTF image.
  60755. * @param context The context when loading the asset
  60756. * @param image The glTF image property
  60757. * @returns A promise that resolves with the loaded data when the load is complete
  60758. */
  60759. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  60760. /**
  60761. * Loads a glTF uri.
  60762. * @param context The context when loading the asset
  60763. * @param property The glTF property associated with the uri
  60764. * @param uri The base64 or relative uri
  60765. * @returns A promise that resolves with the loaded data when the load is complete
  60766. */
  60767. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  60768. private _onProgress;
  60769. /**
  60770. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  60771. * @param babylonObject the Babylon object with metadata
  60772. * @param pointer the JSON pointer
  60773. */
  60774. static AddPointerMetadata(babylonObject: {
  60775. metadata: any;
  60776. }, pointer: string): void;
  60777. private static _GetTextureWrapMode;
  60778. private static _GetTextureSamplingMode;
  60779. private static _GetTypedArray;
  60780. private static _GetNumComponents;
  60781. private static _ValidateUri;
  60782. private static _GetDrawMode;
  60783. private _compileMaterialsAsync;
  60784. private _compileShadowGeneratorsAsync;
  60785. private _forEachExtensions;
  60786. private _applyExtensions;
  60787. private _extensionsOnLoading;
  60788. private _extensionsOnReady;
  60789. private _extensionsLoadSceneAsync;
  60790. private _extensionsLoadNodeAsync;
  60791. private _extensionsLoadCameraAsync;
  60792. private _extensionsLoadVertexDataAsync;
  60793. private _extensionsLoadMaterialAsync;
  60794. private _extensionsCreateMaterial;
  60795. private _extensionsLoadMaterialPropertiesAsync;
  60796. private _extensionsLoadTextureInfoAsync;
  60797. private _extensionsLoadAnimationAsync;
  60798. private _extensionsLoadSkinAsync;
  60799. private _extensionsLoadUriAsync;
  60800. /**
  60801. * Helper method called by a loader extension to load an glTF extension.
  60802. * @param context The context when loading the asset
  60803. * @param property The glTF property to load the extension from
  60804. * @param extensionName The name of the extension to load
  60805. * @param actionAsync The action to run
  60806. * @returns The promise returned by actionAsync or null if the extension does not exist
  60807. */
  60808. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  60809. /**
  60810. * Helper method called by a loader extension to load a glTF extra.
  60811. * @param context The context when loading the asset
  60812. * @param property The glTF property to load the extra from
  60813. * @param extensionName The name of the extension to load
  60814. * @param actionAsync The action to run
  60815. * @returns The promise returned by actionAsync or null if the extra does not exist
  60816. */
  60817. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  60818. /**
  60819. * Increments the indentation level and logs a message.
  60820. * @param message The message to log
  60821. */
  60822. logOpen(message: string): void;
  60823. /**
  60824. * Decrements the indentation level.
  60825. */
  60826. logClose(): void;
  60827. /**
  60828. * Logs a message
  60829. * @param message The message to log
  60830. */
  60831. log(message: string): void;
  60832. /**
  60833. * Starts a performance counter.
  60834. * @param counterName The name of the performance counter
  60835. */
  60836. startPerformanceCounter(counterName: string): void;
  60837. /**
  60838. * Ends a performance counter.
  60839. * @param counterName The name of the performance counter
  60840. */
  60841. endPerformanceCounter(counterName: string): void;
  60842. }
  60843. }
  60844. declare module BABYLON.GLTF2.Loader.Extensions {
  60845. /**
  60846. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  60847. */
  60848. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  60849. /** The name of this extension. */
  60850. readonly name: string;
  60851. /** Defines whether this extension is enabled. */
  60852. enabled: boolean;
  60853. private _loader;
  60854. private _lights?;
  60855. /** @hidden */
  60856. constructor(loader: GLTFLoader);
  60857. /** @hidden */
  60858. dispose(): void;
  60859. /** @hidden */
  60860. onLoading(): void;
  60861. /** @hidden */
  60862. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  60863. private _loadLightAsync;
  60864. }
  60865. }
  60866. declare module BABYLON.GLTF2.Loader.Extensions {
  60867. /**
  60868. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  60869. */
  60870. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  60871. /** The name of this extension. */
  60872. readonly name: string;
  60873. /** The draco compression used to decode vertex data. */
  60874. dracoCompression?: DracoCompression;
  60875. /** Defines whether this extension is enabled. */
  60876. enabled: boolean;
  60877. private _loader;
  60878. private _dracoCompressionOwned;
  60879. /** @hidden */
  60880. constructor(loader: GLTFLoader);
  60881. /** @hidden */
  60882. dispose(): void;
  60883. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60884. }
  60885. }
  60886. declare module BABYLON.GLTF2.Loader.Extensions {
  60887. /**
  60888. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  60889. */
  60890. export class KHR_lights implements IGLTFLoaderExtension {
  60891. /** The name of this extension. */
  60892. readonly name: string;
  60893. /** Defines whether this extension is enabled. */
  60894. enabled: boolean;
  60895. private _loader;
  60896. private _lights?;
  60897. /** @hidden */
  60898. constructor(loader: GLTFLoader);
  60899. /** @hidden */
  60900. dispose(): void;
  60901. /** @hidden */
  60902. onLoading(): void;
  60903. /** @hidden */
  60904. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60905. }
  60906. }
  60907. declare module BABYLON.GLTF2.Loader.Extensions {
  60908. /**
  60909. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  60910. */
  60911. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  60912. /** The name of this extension. */
  60913. readonly name: string;
  60914. /** Defines whether this extension is enabled. */
  60915. enabled: boolean;
  60916. private _loader;
  60917. /** @hidden */
  60918. constructor(loader: GLTFLoader);
  60919. /** @hidden */
  60920. dispose(): void;
  60921. /** @hidden */
  60922. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60923. private _loadSpecularGlossinessPropertiesAsync;
  60924. }
  60925. }
  60926. declare module BABYLON.GLTF2.Loader.Extensions {
  60927. /**
  60928. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  60929. */
  60930. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  60931. /** The name of this extension. */
  60932. readonly name: string;
  60933. /** Defines whether this extension is enabled. */
  60934. enabled: boolean;
  60935. private _loader;
  60936. /** @hidden */
  60937. constructor(loader: GLTFLoader);
  60938. /** @hidden */
  60939. dispose(): void;
  60940. /** @hidden */
  60941. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60942. private _loadUnlitPropertiesAsync;
  60943. }
  60944. }
  60945. declare module BABYLON.GLTF2.Loader.Extensions {
  60946. /**
  60947. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  60948. */
  60949. export class KHR_texture_transform implements IGLTFLoaderExtension {
  60950. /** The name of this extension. */
  60951. readonly name: string;
  60952. /** Defines whether this extension is enabled. */
  60953. enabled: boolean;
  60954. private _loader;
  60955. /** @hidden */
  60956. constructor(loader: GLTFLoader);
  60957. /** @hidden */
  60958. dispose(): void;
  60959. /** @hidden */
  60960. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60961. }
  60962. }
  60963. declare module BABYLON.GLTF2.Loader.Extensions {
  60964. /**
  60965. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  60966. */
  60967. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  60968. /** The name of this extension. */
  60969. readonly name: string;
  60970. /** Defines whether this extension is enabled. */
  60971. enabled: boolean;
  60972. private _loader;
  60973. private _clips;
  60974. private _emitters;
  60975. /** @hidden */
  60976. constructor(loader: GLTFLoader);
  60977. /** @hidden */
  60978. dispose(): void;
  60979. /** @hidden */
  60980. onLoading(): void;
  60981. /** @hidden */
  60982. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  60983. /** @hidden */
  60984. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60985. /** @hidden */
  60986. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60987. private _loadClipAsync;
  60988. private _loadEmitterAsync;
  60989. private _getEventAction;
  60990. private _loadAnimationEventAsync;
  60991. }
  60992. }
  60993. declare module BABYLON.GLTF2.Loader.Extensions {
  60994. /**
  60995. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  60996. */
  60997. export class MSFT_lod implements IGLTFLoaderExtension {
  60998. /** The name of this extension. */
  60999. readonly name: string;
  61000. /** Defines whether this extension is enabled. */
  61001. enabled: boolean;
  61002. /**
  61003. * Maximum number of LODs to load, starting from the lowest LOD.
  61004. */
  61005. maxLODsToLoad: number;
  61006. /**
  61007. * Observable raised when all node LODs of one level are loaded.
  61008. * The event data is the index of the loaded LOD starting from zero.
  61009. * Dispose the loader to cancel the loading of the next level of LODs.
  61010. */
  61011. onNodeLODsLoadedObservable: Observable<number>;
  61012. /**
  61013. * Observable raised when all material LODs of one level are loaded.
  61014. * The event data is the index of the loaded LOD starting from zero.
  61015. * Dispose the loader to cancel the loading of the next level of LODs.
  61016. */
  61017. onMaterialLODsLoadedObservable: Observable<number>;
  61018. private _loader;
  61019. private _nodeIndexLOD;
  61020. private _nodeSignalLODs;
  61021. private _nodePromiseLODs;
  61022. private _materialIndexLOD;
  61023. private _materialSignalLODs;
  61024. private _materialPromiseLODs;
  61025. /** @hidden */
  61026. constructor(loader: GLTFLoader);
  61027. /** @hidden */
  61028. dispose(): void;
  61029. /** @hidden */
  61030. onReady(): void;
  61031. /** @hidden */
  61032. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61033. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  61034. /** @hidden */ loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  61035. /**
  61036. * Gets an array of LOD properties from lowest to highest.
  61037. */
  61038. private _getLODs;
  61039. private _disposeUnusedMaterials;
  61040. }
  61041. }
  61042. declare module BABYLON.GLTF2.Loader.Extensions {
  61043. /** @hidden */
  61044. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  61045. readonly name: string;
  61046. enabled: boolean;
  61047. private _loader;
  61048. constructor(loader: GLTFLoader);
  61049. dispose(): void;
  61050. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61051. }
  61052. }
  61053. declare module BABYLON.GLTF2.Loader.Extensions {
  61054. /** @hidden */
  61055. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  61056. readonly name: string;
  61057. enabled: boolean;
  61058. private _loader;
  61059. constructor(loader: GLTFLoader);
  61060. dispose(): void;
  61061. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61062. }
  61063. }
  61064. declare module BABYLON {
  61065. /**
  61066. * Class reading and parsing the MTL file bundled with the obj file.
  61067. */
  61068. export class MTLFileLoader {
  61069. /**
  61070. * All material loaded from the mtl will be set here
  61071. */
  61072. materials: StandardMaterial[];
  61073. /**
  61074. * This function will read the mtl file and create each material described inside
  61075. * This function could be improve by adding :
  61076. * -some component missing (Ni, Tf...)
  61077. * -including the specific options available
  61078. *
  61079. * @param scene defines the scene the material will be created in
  61080. * @param data defines the mtl data to parse
  61081. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  61082. */
  61083. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  61084. /**
  61085. * Gets the texture for the material.
  61086. *
  61087. * If the material is imported from input file,
  61088. * We sanitize the url to ensure it takes the textre from aside the material.
  61089. *
  61090. * @param rootUrl The root url to load from
  61091. * @param value The value stored in the mtl
  61092. * @return The Texture
  61093. */
  61094. private static _getTexture;
  61095. }
  61096. /**
  61097. * Options for loading OBJ/MTL files
  61098. */
  61099. type MeshLoadOptions = {
  61100. /**
  61101. * Defines if UVs are optimized by default during load.
  61102. */
  61103. OptimizeWithUV: boolean;
  61104. /**
  61105. * Invert model on y-axis (does a model scaling inversion)
  61106. */
  61107. InvertY: boolean;
  61108. /**
  61109. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61110. */
  61111. ImportVertexColors: boolean;
  61112. /**
  61113. * Compute the normals for the model, even if normals are present in the file.
  61114. */
  61115. ComputeNormals: boolean;
  61116. /**
  61117. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61118. */
  61119. SkipMaterials: boolean;
  61120. /**
  61121. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61122. */
  61123. MaterialLoadingFailsSilently: boolean;
  61124. };
  61125. /**
  61126. * OBJ file type loader.
  61127. * This is a babylon scene loader plugin.
  61128. */
  61129. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  61130. /**
  61131. * Defines if UVs are optimized by default during load.
  61132. */
  61133. static OPTIMIZE_WITH_UV: boolean;
  61134. /**
  61135. * Invert model on y-axis (does a model scaling inversion)
  61136. */
  61137. static INVERT_Y: boolean;
  61138. /**
  61139. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61140. */
  61141. static IMPORT_VERTEX_COLORS: boolean;
  61142. /**
  61143. * Compute the normals for the model, even if normals are present in the file.
  61144. */
  61145. static COMPUTE_NORMALS: boolean;
  61146. /**
  61147. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61148. */
  61149. static SKIP_MATERIALS: boolean;
  61150. /**
  61151. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61152. *
  61153. * Defaults to true for backwards compatibility.
  61154. */
  61155. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  61156. /**
  61157. * Defines the name of the plugin.
  61158. */
  61159. name: string;
  61160. /**
  61161. * Defines the extension the plugin is able to load.
  61162. */
  61163. extensions: string;
  61164. /** @hidden */
  61165. obj: RegExp;
  61166. /** @hidden */
  61167. group: RegExp;
  61168. /** @hidden */
  61169. mtllib: RegExp;
  61170. /** @hidden */
  61171. usemtl: RegExp;
  61172. /** @hidden */
  61173. smooth: RegExp;
  61174. /** @hidden */
  61175. vertexPattern: RegExp;
  61176. /** @hidden */
  61177. normalPattern: RegExp;
  61178. /** @hidden */
  61179. uvPattern: RegExp;
  61180. /** @hidden */
  61181. facePattern1: RegExp;
  61182. /** @hidden */
  61183. facePattern2: RegExp;
  61184. /** @hidden */
  61185. facePattern3: RegExp;
  61186. /** @hidden */
  61187. facePattern4: RegExp;
  61188. /** @hidden */
  61189. facePattern5: RegExp;
  61190. private _meshLoadOptions;
  61191. /**
  61192. * Creates loader for .OBJ files
  61193. *
  61194. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  61195. */
  61196. constructor(meshLoadOptions?: MeshLoadOptions);
  61197. private static readonly currentMeshLoadOptions;
  61198. /**
  61199. * Calls synchronously the MTL file attached to this obj.
  61200. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  61201. * Without this function materials are not displayed in the first frame (but displayed after).
  61202. * In consequence it is impossible to get material information in your HTML file
  61203. *
  61204. * @param url The URL of the MTL file
  61205. * @param rootUrl
  61206. * @param onSuccess Callback function to be called when the MTL file is loaded
  61207. * @private
  61208. */
  61209. private _loadMTL;
  61210. /**
  61211. * Instantiates a OBJ file loader plugin.
  61212. * @returns the created plugin
  61213. */
  61214. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  61215. /**
  61216. * If the data string can be loaded directly.
  61217. *
  61218. * @param data string containing the file data
  61219. * @returns if the data can be loaded directly
  61220. */
  61221. canDirectLoad(data: string): boolean;
  61222. /**
  61223. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  61224. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  61225. * @param scene the scene the meshes should be added to
  61226. * @param data the OBJ data to load
  61227. * @param rootUrl root url to load from
  61228. * @param onProgress event that fires when loading progress has occured
  61229. * @param fileName Defines the name of the file to load
  61230. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  61231. */
  61232. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61233. meshes: AbstractMesh[];
  61234. particleSystems: IParticleSystem[];
  61235. skeletons: Skeleton[];
  61236. animationGroups: AnimationGroup[];
  61237. }>;
  61238. /**
  61239. * Imports all objects from the loaded OBJ data and adds them to the scene
  61240. * @param scene the scene the objects should be added to
  61241. * @param data the OBJ data to load
  61242. * @param rootUrl root url to load from
  61243. * @param onProgress event that fires when loading progress has occured
  61244. * @param fileName Defines the name of the file to load
  61245. * @returns a promise which completes when objects have been loaded to the scene
  61246. */
  61247. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61248. /**
  61249. * Load into an asset container.
  61250. * @param scene The scene to load into
  61251. * @param data The data to import
  61252. * @param rootUrl The root url for scene and resources
  61253. * @param onProgress The callback when the load progresses
  61254. * @param fileName Defines the name of the file to load
  61255. * @returns The loaded asset container
  61256. */
  61257. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  61258. /**
  61259. * Read the OBJ file and create an Array of meshes.
  61260. * Each mesh contains all information given by the OBJ and the MTL file.
  61261. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  61262. *
  61263. * @param meshesNames
  61264. * @param scene Scene The scene where are displayed the data
  61265. * @param data String The content of the obj file
  61266. * @param rootUrl String The path to the folder
  61267. * @returns Array<AbstractMesh>
  61268. * @private
  61269. */
  61270. private _parseSolid;
  61271. }
  61272. }
  61273. declare module BABYLON {
  61274. /**
  61275. * STL file type loader.
  61276. * This is a babylon scene loader plugin.
  61277. */
  61278. export class STLFileLoader implements ISceneLoaderPlugin {
  61279. /** @hidden */
  61280. solidPattern: RegExp;
  61281. /** @hidden */
  61282. facetsPattern: RegExp;
  61283. /** @hidden */
  61284. normalPattern: RegExp;
  61285. /** @hidden */
  61286. vertexPattern: RegExp;
  61287. /**
  61288. * Defines the name of the plugin.
  61289. */
  61290. name: string;
  61291. /**
  61292. * Defines the extensions the stl loader is able to load.
  61293. * force data to come in as an ArrayBuffer
  61294. * we'll convert to string if it looks like it's an ASCII .stl
  61295. */
  61296. extensions: ISceneLoaderPluginExtensions;
  61297. /**
  61298. * Import meshes into a scene.
  61299. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  61300. * @param scene The scene to import into
  61301. * @param data The data to import
  61302. * @param rootUrl The root url for scene and resources
  61303. * @param meshes The meshes array to import into
  61304. * @param particleSystems The particle systems array to import into
  61305. * @param skeletons The skeletons array to import into
  61306. * @param onError The callback when import fails
  61307. * @returns True if successful or false otherwise
  61308. */
  61309. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  61310. /**
  61311. * Load into a scene.
  61312. * @param scene The scene to load into
  61313. * @param data The data to import
  61314. * @param rootUrl The root url for scene and resources
  61315. * @param onError The callback when import fails
  61316. * @returns true if successful or false otherwise
  61317. */
  61318. load(scene: Scene, data: any, rootUrl: string): boolean;
  61319. /**
  61320. * Load into an asset container.
  61321. * @param scene The scene to load into
  61322. * @param data The data to import
  61323. * @param rootUrl The root url for scene and resources
  61324. * @param onError The callback when import fails
  61325. * @returns The loaded asset container
  61326. */
  61327. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  61328. private _isBinary;
  61329. private _parseBinary;
  61330. private _parseASCII;
  61331. }
  61332. }
  61333. declare module BABYLON {
  61334. /**
  61335. * Class for generating OBJ data from a Babylon scene.
  61336. */
  61337. export class OBJExport {
  61338. /**
  61339. * Exports the geometry of a Mesh array in .OBJ file format (text)
  61340. * @param mesh defines the list of meshes to serialize
  61341. * @param materials defines if materials should be exported
  61342. * @param matlibname defines the name of the associated mtl file
  61343. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  61344. * @returns the OBJ content
  61345. */
  61346. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  61347. /**
  61348. * Exports the material(s) of a mesh in .MTL file format (text)
  61349. * @param mesh defines the mesh to extract the material from
  61350. * @returns the mtl content
  61351. */
  61352. static MTL(mesh: Mesh): string;
  61353. }
  61354. }
  61355. declare module BABYLON {
  61356. /** @hidden */
  61357. export var __IGLTFExporterExtension: number;
  61358. /**
  61359. * Interface for extending the exporter
  61360. * @hidden
  61361. */
  61362. export interface IGLTFExporterExtension {
  61363. /**
  61364. * The name of this extension
  61365. */
  61366. readonly name: string;
  61367. /**
  61368. * Defines whether this extension is enabled
  61369. */
  61370. enabled: boolean;
  61371. /**
  61372. * Defines whether this extension is required
  61373. */
  61374. required: boolean;
  61375. }
  61376. }
  61377. declare module BABYLON.GLTF2.Exporter {
  61378. /** @hidden */
  61379. export var __IGLTFExporterExtensionV2: number;
  61380. /**
  61381. * Interface for a glTF exporter extension
  61382. * @hidden
  61383. */
  61384. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  61385. /**
  61386. * Define this method to modify the default behavior before exporting a texture
  61387. * @param context The context when loading the asset
  61388. * @param babylonTexture The glTF texture info property
  61389. * @param mimeType The mime-type of the generated image
  61390. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  61391. */
  61392. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  61393. /**
  61394. * Define this method to modify the default behavior when exporting texture info
  61395. * @param context The context when loading the asset
  61396. * @param meshPrimitive glTF mesh primitive
  61397. * @param babylonSubMesh Babylon submesh
  61398. * @param binaryWriter glTF serializer binary writer instance
  61399. * @returns nullable IMeshPrimitive promise
  61400. */
  61401. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  61402. /**
  61403. * Define this method to modify the default behavior when exporting a node
  61404. * @param context The context when exporting the node
  61405. * @param node glTF node
  61406. * @param babylonNode BabylonJS node
  61407. * @returns nullable INode promise
  61408. */
  61409. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  61410. /**
  61411. * Called after the exporter state changes to EXPORTING
  61412. */
  61413. onExporting?(): void;
  61414. }
  61415. }
  61416. declare module BABYLON.GLTF2.Exporter {
  61417. /**
  61418. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  61419. * @hidden
  61420. */
  61421. export class _GLTFMaterialExporter {
  61422. /**
  61423. * Represents the dielectric specular values for R, G and B
  61424. */
  61425. private static readonly _DielectricSpecular;
  61426. /**
  61427. * Allows the maximum specular power to be defined for material calculations
  61428. */
  61429. private static readonly _MaxSpecularPower;
  61430. /**
  61431. * Mapping to store textures
  61432. */
  61433. private _textureMap;
  61434. /**
  61435. * Numeric tolerance value
  61436. */
  61437. private static readonly _Epsilon;
  61438. /**
  61439. * Reference to the glTF Exporter
  61440. */
  61441. private _exporter;
  61442. constructor(exporter: _Exporter);
  61443. /**
  61444. * Specifies if two colors are approximately equal in value
  61445. * @param color1 first color to compare to
  61446. * @param color2 second color to compare to
  61447. * @param epsilon threshold value
  61448. */
  61449. private static FuzzyEquals;
  61450. /**
  61451. * Gets the materials from a Babylon scene and converts them to glTF materials
  61452. * @param scene babylonjs scene
  61453. * @param mimeType texture mime type
  61454. * @param images array of images
  61455. * @param textures array of textures
  61456. * @param materials array of materials
  61457. * @param imageData mapping of texture names to base64 textures
  61458. * @param hasTextureCoords specifies if texture coordinates are present on the material
  61459. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61460. /**
  61461. * Makes a copy of the glTF material without the texture parameters
  61462. * @param originalMaterial original glTF material
  61463. * @returns glTF material without texture parameters
  61464. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  61465. /**
  61466. * Specifies if the material has any texture parameters present
  61467. * @param material glTF Material
  61468. * @returns boolean specifying if texture parameters are present
  61469. */ hasTexturesPresent(material: IMaterial): boolean;
  61470. /**
  61471. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  61472. * @param babylonStandardMaterial
  61473. * @returns glTF Metallic Roughness Material representation
  61474. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  61475. /**
  61476. * Computes the metallic factor
  61477. * @param diffuse diffused value
  61478. * @param specular specular value
  61479. * @param oneMinusSpecularStrength one minus the specular strength
  61480. * @returns metallic value
  61481. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  61482. /**
  61483. * Gets the glTF alpha mode from the Babylon Material
  61484. * @param babylonMaterial Babylon Material
  61485. * @returns The Babylon alpha mode value
  61486. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  61487. /**
  61488. * Converts a Babylon Standard Material to a glTF Material
  61489. * @param babylonStandardMaterial BJS Standard Material
  61490. * @param mimeType mime type to use for the textures
  61491. * @param images array of glTF image interfaces
  61492. * @param textures array of glTF texture interfaces
  61493. * @param materials array of glTF material interfaces
  61494. * @param imageData map of image file name to data
  61495. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61496. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61497. /**
  61498. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61499. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  61500. * @param mimeType mime type to use for the textures
  61501. * @param images array of glTF image interfaces
  61502. * @param textures array of glTF texture interfaces
  61503. * @param materials array of glTF material interfaces
  61504. * @param imageData map of image file name to data
  61505. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61506. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61507. /**
  61508. * Converts an image typed array buffer to a base64 image
  61509. * @param buffer typed array buffer
  61510. * @param width width of the image
  61511. * @param height height of the image
  61512. * @param mimeType mimetype of the image
  61513. * @returns base64 image string
  61514. */
  61515. private _createBase64FromCanvasAsync;
  61516. /**
  61517. * Generates a white texture based on the specified width and height
  61518. * @param width width of the texture in pixels
  61519. * @param height height of the texture in pixels
  61520. * @param scene babylonjs scene
  61521. * @returns white texture
  61522. */
  61523. private _createWhiteTexture;
  61524. /**
  61525. * 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
  61526. * @param texture1 first texture to resize
  61527. * @param texture2 second texture to resize
  61528. * @param scene babylonjs scene
  61529. * @returns resized textures or null
  61530. */
  61531. private _resizeTexturesToSameDimensions;
  61532. /**
  61533. * Converts an array of pixels to a Float32Array
  61534. * Throws an error if the pixel format is not supported
  61535. * @param pixels - array buffer containing pixel values
  61536. * @returns Float32 of pixels
  61537. */
  61538. private _convertPixelArrayToFloat32;
  61539. /**
  61540. * Convert Specular Glossiness Textures to Metallic Roughness
  61541. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  61542. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  61543. * @param diffuseTexture texture used to store diffuse information
  61544. * @param specularGlossinessTexture texture used to store specular and glossiness information
  61545. * @param factors specular glossiness material factors
  61546. * @param mimeType the mime type to use for the texture
  61547. * @returns pbr metallic roughness interface or null
  61548. */
  61549. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  61550. /**
  61551. * Converts specular glossiness material properties to metallic roughness
  61552. * @param specularGlossiness interface with specular glossiness material properties
  61553. * @returns interface with metallic roughness material properties
  61554. */
  61555. private _convertSpecularGlossinessToMetallicRoughness;
  61556. /**
  61557. * Calculates the surface reflectance, independent of lighting conditions
  61558. * @param color Color source to calculate brightness from
  61559. * @returns number representing the perceived brightness, or zero if color is undefined
  61560. */
  61561. private _getPerceivedBrightness;
  61562. /**
  61563. * Returns the maximum color component value
  61564. * @param color
  61565. * @returns maximum color component value, or zero if color is null or undefined
  61566. */
  61567. private _getMaxComponent;
  61568. /**
  61569. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  61570. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61571. * @param mimeType mime type to use for the textures
  61572. * @param images array of glTF image interfaces
  61573. * @param textures array of glTF texture interfaces
  61574. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61575. * @param imageData map of image file name to data
  61576. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61577. * @returns glTF PBR Metallic Roughness factors
  61578. */
  61579. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  61580. private _getGLTFTextureSampler;
  61581. private _getGLTFTextureWrapMode;
  61582. private _getGLTFTextureWrapModesSampler;
  61583. /**
  61584. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  61585. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61586. * @param mimeType mime type to use for the textures
  61587. * @param images array of glTF image interfaces
  61588. * @param textures array of glTF texture interfaces
  61589. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61590. * @param imageData map of image file name to data
  61591. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61592. * @returns glTF PBR Metallic Roughness factors
  61593. */
  61594. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  61595. /**
  61596. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61597. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61598. * @param mimeType mime type to use for the textures
  61599. * @param images array of glTF image interfaces
  61600. * @param textures array of glTF texture interfaces
  61601. * @param materials array of glTF material interfaces
  61602. * @param imageData map of image file name to data
  61603. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61604. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61605. private setMetallicRoughnessPbrMaterial;
  61606. private getPixelsFromTexture;
  61607. /**
  61608. * Extracts a texture from a Babylon texture into file data and glTF data
  61609. * @param babylonTexture Babylon texture to extract
  61610. * @param mimeType Mime Type of the babylonTexture
  61611. * @return glTF texture info, or null if the texture format is not supported
  61612. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  61613. /**
  61614. * Builds a texture from base64 string
  61615. * @param base64Texture base64 texture string
  61616. * @param baseTextureName Name to use for the texture
  61617. * @param mimeType image mime type for the texture
  61618. * @param images array of images
  61619. * @param textures array of textures
  61620. * @param imageData map of image data
  61621. * @returns glTF texture info, or null if the texture format is not supported
  61622. */
  61623. private _getTextureInfoFromBase64;
  61624. }
  61625. }
  61626. declare module BABYLON {
  61627. /**
  61628. * Class for holding and downloading glTF file data
  61629. */
  61630. export class GLTFData {
  61631. /**
  61632. * Object which contains the file name as the key and its data as the value
  61633. */
  61634. glTFFiles: {
  61635. [fileName: string]: string | Blob;
  61636. };
  61637. /**
  61638. * Initializes the glTF file object
  61639. */
  61640. constructor();
  61641. /**
  61642. * Downloads the glTF data as files based on their names and data
  61643. */
  61644. downloadFiles(): void;
  61645. }
  61646. }
  61647. declare module BABYLON {
  61648. /**
  61649. * Holds a collection of exporter options and parameters
  61650. */
  61651. export interface IExportOptions {
  61652. /**
  61653. * Function which indicates whether a babylon node should be exported or not
  61654. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  61655. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  61656. */
  61657. shouldExportNode?(node: Node): boolean;
  61658. /**
  61659. * The sample rate to bake animation curves
  61660. */
  61661. animationSampleRate?: number;
  61662. /**
  61663. * Begin serialization without waiting for the scene to be ready
  61664. */
  61665. exportWithoutWaitingForScene?: boolean;
  61666. }
  61667. /**
  61668. * Class for generating glTF data from a Babylon scene.
  61669. */
  61670. export class GLTF2Export {
  61671. /**
  61672. * Exports the geometry of the scene to .gltf file format asynchronously
  61673. * @param scene Babylon scene with scene hierarchy information
  61674. * @param filePrefix File prefix to use when generating the glTF file
  61675. * @param options Exporter options
  61676. * @returns Returns an object with a .gltf file and associates texture names
  61677. * as keys and their data and paths as values
  61678. */
  61679. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  61680. private static _PreExportAsync;
  61681. private static _PostExportAsync;
  61682. /**
  61683. * Exports the geometry of the scene to .glb file format asychronously
  61684. * @param scene Babylon scene with scene hierarchy information
  61685. * @param filePrefix File prefix to use when generating glb file
  61686. * @param options Exporter options
  61687. * @returns Returns an object with a .glb filename as key and data as value
  61688. */
  61689. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  61690. }
  61691. }
  61692. declare module BABYLON.GLTF2.Exporter {
  61693. /**
  61694. * @hidden
  61695. */
  61696. export class _GLTFUtilities {
  61697. /**
  61698. * Creates a buffer view based on the supplied arguments
  61699. * @param bufferIndex index value of the specified buffer
  61700. * @param byteOffset byte offset value
  61701. * @param byteLength byte length of the bufferView
  61702. * @param byteStride byte distance between conequential elements
  61703. * @param name name of the buffer view
  61704. * @returns bufferView for glTF
  61705. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  61706. /**
  61707. * Creates an accessor based on the supplied arguments
  61708. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  61709. * @param name The name of the accessor
  61710. * @param type The type of the accessor
  61711. * @param componentType The datatype of components in the attribute
  61712. * @param count The number of attributes referenced by this accessor
  61713. * @param byteOffset The offset relative to the start of the bufferView in bytes
  61714. * @param min Minimum value of each component in this attribute
  61715. * @param max Maximum value of each component in this attribute
  61716. * @returns accessor for glTF
  61717. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  61718. /**
  61719. * Calculates the minimum and maximum values of an array of position floats
  61720. * @param positions Positions array of a mesh
  61721. * @param vertexStart Starting vertex offset to calculate min and max values
  61722. * @param vertexCount Number of vertices to check for min and max values
  61723. * @returns min number array and max number array
  61724. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  61725. min: number[];
  61726. max: number[];
  61727. };
  61728. /**
  61729. * Converts a new right-handed Vector3
  61730. * @param vector vector3 array
  61731. * @returns right-handed Vector3
  61732. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  61733. /**
  61734. * Converts a Vector3 to right-handed
  61735. * @param vector Vector3 to convert to right-handed
  61736. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  61737. /**
  61738. * Converts a three element number array to right-handed
  61739. * @param vector number array to convert to right-handed
  61740. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  61741. /**
  61742. * Converts a new right-handed Vector3
  61743. * @param vector vector3 array
  61744. * @returns right-handed Vector3
  61745. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  61746. /**
  61747. * Converts a Vector3 to right-handed
  61748. * @param vector Vector3 to convert to right-handed
  61749. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  61750. /**
  61751. * Converts a three element number array to right-handed
  61752. * @param vector number array to convert to right-handed
  61753. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  61754. /**
  61755. * Converts a Vector4 to right-handed
  61756. * @param vector Vector4 to convert to right-handed
  61757. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  61758. /**
  61759. * Converts a Vector4 to right-handed
  61760. * @param vector Vector4 to convert to right-handed
  61761. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  61762. /**
  61763. * Converts a Quaternion to right-handed
  61764. * @param quaternion Source quaternion to convert to right-handed
  61765. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  61766. /**
  61767. * Converts a Quaternion to right-handed
  61768. * @param quaternion Source quaternion to convert to right-handed
  61769. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  61770. }
  61771. }
  61772. declare module BABYLON.GLTF2.Exporter {
  61773. /**
  61774. * Converts Babylon Scene into glTF 2.0.
  61775. * @hidden
  61776. */
  61777. export class _Exporter {
  61778. /**
  61779. * Stores the glTF to export
  61780. */ glTF: IGLTF;
  61781. /**
  61782. * Stores all generated buffer views, which represents views into the main glTF buffer data
  61783. */ bufferViews: IBufferView[];
  61784. /**
  61785. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  61786. */ accessors: IAccessor[];
  61787. /**
  61788. * Stores all the generated nodes, which contains transform and/or mesh information per node
  61789. */
  61790. private _nodes;
  61791. /**
  61792. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  61793. */
  61794. private _scenes;
  61795. /**
  61796. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  61797. */
  61798. private _meshes;
  61799. /**
  61800. * Stores all the generated material information, which represents the appearance of each primitive
  61801. */ materials: IMaterial[]; materialMap: {
  61802. [materialID: number]: number;
  61803. };
  61804. /**
  61805. * Stores all the generated texture information, which is referenced by glTF materials
  61806. */ textures: ITexture[];
  61807. /**
  61808. * Stores all the generated image information, which is referenced by glTF textures
  61809. */ images: IImage[];
  61810. /**
  61811. * Stores all the texture samplers
  61812. */ samplers: ISampler[];
  61813. /**
  61814. * Stores all the generated animation samplers, which is referenced by glTF animations
  61815. */
  61816. /**
  61817. * Stores the animations for glTF models
  61818. */
  61819. private _animations;
  61820. /**
  61821. * Stores the total amount of bytes stored in the glTF buffer
  61822. */
  61823. private _totalByteLength;
  61824. /**
  61825. * Stores a reference to the Babylon scene containing the source geometry and material information
  61826. */ babylonScene: Scene;
  61827. /**
  61828. * Stores a map of the image data, where the key is the file name and the value
  61829. * is the image data
  61830. */ imageData: {
  61831. [fileName: string]: {
  61832. data: Uint8Array;
  61833. mimeType: ImageMimeType;
  61834. };
  61835. };
  61836. /**
  61837. * Stores a map of the unique id of a node to its index in the node array
  61838. */
  61839. private _nodeMap;
  61840. /**
  61841. * Specifies if the Babylon scene should be converted to right-handed on export
  61842. */ convertToRightHandedSystem: boolean;
  61843. /**
  61844. * Baked animation sample rate
  61845. */
  61846. private _animationSampleRate;
  61847. /**
  61848. * Callback which specifies if a node should be exported or not
  61849. */
  61850. private _shouldExportNode;
  61851. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  61852. private _extensions;
  61853. private static _ExtensionNames;
  61854. private static _ExtensionFactories;
  61855. private _applyExtensions; extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  61856. private _forEachExtensions;
  61857. private _extensionsOnExporting;
  61858. /**
  61859. * Load glTF serializer extensions
  61860. */
  61861. private _loadExtensions;
  61862. /**
  61863. * Creates a glTF Exporter instance, which can accept optional exporter options
  61864. * @param babylonScene Babylon scene object
  61865. * @param options Options to modify the behavior of the exporter
  61866. */
  61867. constructor(babylonScene: Scene, options?: IExportOptions);
  61868. /**
  61869. * Registers a glTF exporter extension
  61870. * @param name Name of the extension to export
  61871. * @param factory The factory function that creates the exporter extension
  61872. */
  61873. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  61874. /**
  61875. * Un-registers an exporter extension
  61876. * @param name The name fo the exporter extension
  61877. * @returns A boolean indicating whether the extension has been un-registered
  61878. */
  61879. static UnregisterExtension(name: string): boolean;
  61880. /**
  61881. * Lazy load a local engine with premultiplied alpha set to false
  61882. */ getLocalEngine(): Engine;
  61883. private reorderIndicesBasedOnPrimitiveMode;
  61884. /**
  61885. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  61886. * clock-wise during export to glTF
  61887. * @param submesh BabylonJS submesh
  61888. * @param primitiveMode Primitive mode of the mesh
  61889. * @param sideOrientation the winding order of the submesh
  61890. * @param vertexBufferKind The type of vertex attribute
  61891. * @param meshAttributeArray The vertex attribute data
  61892. * @param byteOffset The offset to the binary data
  61893. * @param binaryWriter The binary data for the glTF file
  61894. */
  61895. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  61896. /**
  61897. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  61898. * clock-wise during export to glTF
  61899. * @param submesh BabylonJS submesh
  61900. * @param primitiveMode Primitive mode of the mesh
  61901. * @param sideOrientation the winding order of the submesh
  61902. * @param vertexBufferKind The type of vertex attribute
  61903. * @param meshAttributeArray The vertex attribute data
  61904. * @param byteOffset The offset to the binary data
  61905. * @param binaryWriter The binary data for the glTF file
  61906. */
  61907. private reorderTriangleFillMode;
  61908. /**
  61909. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  61910. * clock-wise during export to glTF
  61911. * @param submesh BabylonJS submesh
  61912. * @param primitiveMode Primitive mode of the mesh
  61913. * @param sideOrientation the winding order of the submesh
  61914. * @param vertexBufferKind The type of vertex attribute
  61915. * @param meshAttributeArray The vertex attribute data
  61916. * @param byteOffset The offset to the binary data
  61917. * @param binaryWriter The binary data for the glTF file
  61918. */
  61919. private reorderTriangleStripDrawMode;
  61920. /**
  61921. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  61922. * clock-wise during export to glTF
  61923. * @param submesh BabylonJS submesh
  61924. * @param primitiveMode Primitive mode of the mesh
  61925. * @param sideOrientation the winding order of the submesh
  61926. * @param vertexBufferKind The type of vertex attribute
  61927. * @param meshAttributeArray The vertex attribute data
  61928. * @param byteOffset The offset to the binary data
  61929. * @param binaryWriter The binary data for the glTF file
  61930. */
  61931. private reorderTriangleFanMode;
  61932. /**
  61933. * Writes the vertex attribute data to binary
  61934. * @param vertices The vertices to write to the binary writer
  61935. * @param byteOffset The offset into the binary writer to overwrite binary data
  61936. * @param vertexAttributeKind The vertex attribute type
  61937. * @param meshAttributeArray The vertex attribute data
  61938. * @param binaryWriter The writer containing the binary data
  61939. */
  61940. private writeVertexAttributeData;
  61941. /**
  61942. * Writes mesh attribute data to a data buffer
  61943. * Returns the bytelength of the data
  61944. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  61945. * @param meshAttributeArray Array containing the attribute data
  61946. * @param binaryWriter The buffer to write the binary data to
  61947. * @param indices Used to specify the order of the vertex data
  61948. */
  61949. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  61950. /**
  61951. * Generates glTF json data
  61952. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  61953. * @param glTFPrefix Text to use when prefixing a glTF file
  61954. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  61955. * @returns json data as string
  61956. */
  61957. private generateJSON;
  61958. /**
  61959. * Generates data for .gltf and .bin files based on the glTF prefix string
  61960. * @param glTFPrefix Text to use when prefixing a glTF file
  61961. * @returns GLTFData with glTF file data
  61962. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  61963. /**
  61964. * Creates a binary buffer for glTF
  61965. * @returns array buffer for binary data
  61966. */
  61967. private _generateBinaryAsync;
  61968. /**
  61969. * Pads the number to a multiple of 4
  61970. * @param num number to pad
  61971. * @returns padded number
  61972. */
  61973. private _getPadding;
  61974. /**
  61975. * Generates a glb file from the json and binary data
  61976. * Returns an object with the glb file name as the key and data as the value
  61977. * @param glTFPrefix
  61978. * @returns object with glb filename as key and data as value
  61979. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  61980. /**
  61981. * Sets the TRS for each node
  61982. * @param node glTF Node for storing the transformation data
  61983. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  61984. */
  61985. private setNodeTransformation;
  61986. private getVertexBufferFromMesh;
  61987. /**
  61988. * Creates a bufferview based on the vertices type for the Babylon mesh
  61989. * @param kind Indicates the type of vertices data
  61990. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  61991. * @param binaryWriter The buffer to write the bufferview data to
  61992. */
  61993. private createBufferViewKind;
  61994. /**
  61995. * The primitive mode of the Babylon mesh
  61996. * @param babylonMesh The BabylonJS mesh
  61997. */
  61998. private getMeshPrimitiveMode;
  61999. /**
  62000. * Sets the primitive mode of the glTF mesh primitive
  62001. * @param meshPrimitive glTF mesh primitive
  62002. * @param primitiveMode The primitive mode
  62003. */
  62004. private setPrimitiveMode;
  62005. /**
  62006. * Sets the vertex attribute accessor based of the glTF mesh primitive
  62007. * @param meshPrimitive glTF mesh primitive
  62008. * @param attributeKind vertex attribute
  62009. * @returns boolean specifying if uv coordinates are present
  62010. */
  62011. private setAttributeKind;
  62012. /**
  62013. * Sets data for the primitive attributes of each submesh
  62014. * @param mesh glTF Mesh object to store the primitive attribute information
  62015. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  62016. * @param binaryWriter Buffer to write the attribute data to
  62017. */
  62018. private setPrimitiveAttributesAsync;
  62019. /**
  62020. * Creates a glTF scene based on the array of meshes
  62021. * Returns the the total byte offset
  62022. * @param babylonScene Babylon scene to get the mesh data from
  62023. * @param binaryWriter Buffer to write binary data to
  62024. */
  62025. private createSceneAsync;
  62026. /**
  62027. * Creates a mapping of Node unique id to node index and handles animations
  62028. * @param babylonScene Babylon Scene
  62029. * @param nodes Babylon transform nodes
  62030. * @param shouldExportNode Callback specifying if a transform node should be exported
  62031. * @param binaryWriter Buffer to write binary data to
  62032. * @returns Node mapping of unique id to index
  62033. */
  62034. private createNodeMapAndAnimationsAsync;
  62035. /**
  62036. * Creates a glTF node from a Babylon mesh
  62037. * @param babylonMesh Source Babylon mesh
  62038. * @param binaryWriter Buffer for storing geometry data
  62039. * @returns glTF node
  62040. */
  62041. private createNodeAsync;
  62042. }
  62043. /**
  62044. * @hidden
  62045. *
  62046. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  62047. */
  62048. export class _BinaryWriter {
  62049. /**
  62050. * Array buffer which stores all binary data
  62051. */
  62052. private _arrayBuffer;
  62053. /**
  62054. * View of the array buffer
  62055. */
  62056. private _dataView;
  62057. /**
  62058. * byte offset of data in array buffer
  62059. */
  62060. private _byteOffset;
  62061. /**
  62062. * Initialize binary writer with an initial byte length
  62063. * @param byteLength Initial byte length of the array buffer
  62064. */
  62065. constructor(byteLength: number);
  62066. /**
  62067. * Resize the array buffer to the specified byte length
  62068. * @param byteLength
  62069. */
  62070. private resizeBuffer;
  62071. /**
  62072. * Get an array buffer with the length of the byte offset
  62073. * @returns ArrayBuffer resized to the byte offset
  62074. */
  62075. getArrayBuffer(): ArrayBuffer;
  62076. /**
  62077. * Get the byte offset of the array buffer
  62078. * @returns byte offset
  62079. */
  62080. getByteOffset(): number;
  62081. /**
  62082. * Stores an UInt8 in the array buffer
  62083. * @param entry
  62084. * @param byteOffset If defined, specifies where to set the value as an offset.
  62085. */
  62086. setUInt8(entry: number, byteOffset?: number): void;
  62087. /**
  62088. * Gets an UInt32 in the array buffer
  62089. * @param entry
  62090. * @param byteOffset If defined, specifies where to set the value as an offset.
  62091. */
  62092. getUInt32(byteOffset: number): number;
  62093. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62094. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62095. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62096. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62097. /**
  62098. * Stores a Float32 in the array buffer
  62099. * @param entry
  62100. */
  62101. setFloat32(entry: number, byteOffset?: number): void;
  62102. /**
  62103. * Stores an UInt32 in the array buffer
  62104. * @param entry
  62105. * @param byteOffset If defined, specifies where to set the value as an offset.
  62106. */
  62107. setUInt32(entry: number, byteOffset?: number): void;
  62108. }
  62109. }
  62110. declare module BABYLON.GLTF2.Exporter {
  62111. /**
  62112. * @hidden
  62113. * Interface to store animation data.
  62114. */
  62115. export interface _IAnimationData {
  62116. /**
  62117. * Keyframe data.
  62118. */
  62119. inputs: number[];
  62120. /**
  62121. * Value data.
  62122. */
  62123. outputs: number[][];
  62124. /**
  62125. * Animation interpolation data.
  62126. */
  62127. samplerInterpolation: AnimationSamplerInterpolation;
  62128. /**
  62129. * Minimum keyframe value.
  62130. */
  62131. inputsMin: number;
  62132. /**
  62133. * Maximum keyframe value.
  62134. */
  62135. inputsMax: number;
  62136. }
  62137. /**
  62138. * @hidden
  62139. */
  62140. export interface _IAnimationInfo {
  62141. /**
  62142. * The target channel for the animation
  62143. */
  62144. animationChannelTargetPath: AnimationChannelTargetPath;
  62145. /**
  62146. * The glTF accessor type for the data.
  62147. */
  62148. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  62149. /**
  62150. * Specifies if quaternions should be used.
  62151. */
  62152. useQuaternion: boolean;
  62153. }
  62154. /**
  62155. * @hidden
  62156. * Utility class for generating glTF animation data from BabylonJS.
  62157. */
  62158. export class _GLTFAnimation {
  62159. /**
  62160. * @ignore
  62161. *
  62162. * Creates glTF channel animation from BabylonJS animation.
  62163. * @param babylonTransformNode - BabylonJS mesh.
  62164. * @param animation - animation.
  62165. * @param animationChannelTargetPath - The target animation channel.
  62166. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  62167. * @param useQuaternion - Specifies if quaternions are used.
  62168. * @returns nullable IAnimationData
  62169. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  62170. private static _DeduceAnimationInfo;
  62171. /**
  62172. * @ignore
  62173. * Create node animations from the transform node animations
  62174. * @param babylonNode
  62175. * @param runtimeGLTFAnimation
  62176. * @param idleGLTFAnimations
  62177. * @param nodeMap
  62178. * @param nodes
  62179. * @param binaryWriter
  62180. * @param bufferViews
  62181. * @param accessors
  62182. * @param convertToRightHandedSystem
  62183. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  62184. [key: number]: number;
  62185. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62186. /**
  62187. * @ignore
  62188. * Create node animations from the animation groups
  62189. * @param babylonScene
  62190. * @param glTFAnimations
  62191. * @param nodeMap
  62192. * @param nodes
  62193. * @param binaryWriter
  62194. * @param bufferViews
  62195. * @param accessors
  62196. * @param convertToRightHandedSystem
  62197. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  62198. [key: number]: number;
  62199. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62200. private static AddAnimation;
  62201. /**
  62202. * Create a baked animation
  62203. * @param babylonTransformNode BabylonJS mesh
  62204. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  62205. * @param animationChannelTargetPath animation target channel
  62206. * @param minFrame minimum animation frame
  62207. * @param maxFrame maximum animation frame
  62208. * @param fps frames per second of the animation
  62209. * @param inputs input key frames of the animation
  62210. * @param outputs output key frame data of the animation
  62211. * @param convertToRightHandedSystem converts the values to right-handed
  62212. * @param useQuaternion specifies if quaternions should be used
  62213. */
  62214. private static _CreateBakedAnimation;
  62215. private static _ConvertFactorToVector3OrQuaternion;
  62216. private static _SetInterpolatedValue;
  62217. /**
  62218. * Creates linear animation from the animation key frames
  62219. * @param babylonTransformNode BabylonJS mesh
  62220. * @param animation BabylonJS animation
  62221. * @param animationChannelTargetPath The target animation channel
  62222. * @param frameDelta The difference between the last and first frame of the animation
  62223. * @param inputs Array to store the key frame times
  62224. * @param outputs Array to store the key frame data
  62225. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62226. * @param useQuaternion Specifies if quaternions are used in the animation
  62227. */
  62228. private static _CreateLinearOrStepAnimation;
  62229. /**
  62230. * Creates cubic spline animation from the animation key frames
  62231. * @param babylonTransformNode BabylonJS mesh
  62232. * @param animation BabylonJS animation
  62233. * @param animationChannelTargetPath The target animation channel
  62234. * @param frameDelta The difference between the last and first frame of the animation
  62235. * @param inputs Array to store the key frame times
  62236. * @param outputs Array to store the key frame data
  62237. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62238. * @param useQuaternion Specifies if quaternions are used in the animation
  62239. */
  62240. private static _CreateCubicSplineAnimation;
  62241. private static _GetBasePositionRotationOrScale;
  62242. /**
  62243. * Adds a key frame value
  62244. * @param keyFrame
  62245. * @param animation
  62246. * @param outputs
  62247. * @param animationChannelTargetPath
  62248. * @param basePositionRotationOrScale
  62249. * @param convertToRightHandedSystem
  62250. * @param useQuaternion
  62251. */
  62252. private static _AddKeyframeValue;
  62253. /**
  62254. * Determine the interpolation based on the key frames
  62255. * @param keyFrames
  62256. * @param animationChannelTargetPath
  62257. * @param useQuaternion
  62258. */
  62259. private static _DeduceInterpolation;
  62260. /**
  62261. * Adds an input tangent or output tangent to the output data
  62262. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  62263. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  62264. * @param outputs The animation data by keyframe
  62265. * @param animationChannelTargetPath The target animation channel
  62266. * @param interpolation The interpolation type
  62267. * @param keyFrame The key frame with the animation data
  62268. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  62269. * @param useQuaternion Specifies if quaternions are used
  62270. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  62271. */
  62272. private static AddSplineTangent;
  62273. /**
  62274. * Get the minimum and maximum key frames' frame values
  62275. * @param keyFrames animation key frames
  62276. * @returns the minimum and maximum key frame value
  62277. */
  62278. private static calculateMinMaxKeyFrames;
  62279. }
  62280. }
  62281. declare module BABYLON.GLTF2.Exporter {
  62282. /** @hidden */
  62283. export var textureTransformPixelShader: {
  62284. name: string;
  62285. shader: string;
  62286. };
  62287. }
  62288. declare module BABYLON.GLTF2.Exporter.Extensions {
  62289. /**
  62290. * @hidden
  62291. */
  62292. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  62293. /** Name of this extension */
  62294. readonly name: string;
  62295. /** Defines whether this extension is enabled */
  62296. enabled: boolean;
  62297. /** Defines whether this extension is required */
  62298. required: boolean;
  62299. /** Reference to the glTF exporter */
  62300. private _exporter;
  62301. constructor(exporter: _Exporter);
  62302. dispose(): void;
  62303. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  62304. /**
  62305. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  62306. * @param babylonTexture
  62307. * @param offset
  62308. * @param rotation
  62309. * @param scale
  62310. * @param scene
  62311. */
  62312. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  62313. }
  62314. }
  62315. declare module BABYLON.GLTF2.Exporter.Extensions {
  62316. /**
  62317. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  62318. */
  62319. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  62320. /** The name of this extension. */
  62321. readonly name: string;
  62322. /** Defines whether this extension is enabled. */
  62323. enabled: boolean;
  62324. /** Defines whether this extension is required */
  62325. required: boolean;
  62326. /** Reference to the glTF exporter */
  62327. private _exporter;
  62328. private _lights;
  62329. /** @hidden */
  62330. constructor(exporter: _Exporter);
  62331. /** @hidden */
  62332. dispose(): void;
  62333. /** @hidden */
  62334. onExporting(): void;
  62335. /**
  62336. * Define this method to modify the default behavior when exporting a node
  62337. * @param context The context when exporting the node
  62338. * @param node glTF node
  62339. * @param babylonNode BabylonJS node
  62340. * @returns nullable INode promise
  62341. */
  62342. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62343. }
  62344. }
  62345. declare module BABYLON {
  62346. /**
  62347. * Class for generating STL data from a Babylon scene.
  62348. */
  62349. export class STLExport {
  62350. /**
  62351. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  62352. * @param meshes list defines the mesh to serialize
  62353. * @param download triggers the automatic download of the file.
  62354. * @param fileName changes the downloads fileName.
  62355. * @param binary changes the STL to a binary type.
  62356. * @param isLittleEndian toggle for binary type exporter.
  62357. * @returns the STL as UTF8 string
  62358. */
  62359. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  62360. }
  62361. }
  62362. /**
  62363. * @ignoreChildren
  62364. * @ignore
  62365. */
  62366. declare module "babylonjs-gltf2interface" {
  62367. export = BABYLON.GLTF2;
  62368. }
  62369. /**
  62370. * Module for glTF 2.0 Interface
  62371. * @ignoreChildren
  62372. * @ignore
  62373. */
  62374. declare module BABYLON.GLTF2 {
  62375. /**
  62376. * The datatype of the components in the attribute
  62377. */
  62378. const enum AccessorComponentType {
  62379. /**
  62380. * Byte
  62381. */
  62382. BYTE = 5120,
  62383. /**
  62384. * Unsigned Byte
  62385. */
  62386. UNSIGNED_BYTE = 5121,
  62387. /**
  62388. * Short
  62389. */
  62390. SHORT = 5122,
  62391. /**
  62392. * Unsigned Short
  62393. */
  62394. UNSIGNED_SHORT = 5123,
  62395. /**
  62396. * Unsigned Int
  62397. */
  62398. UNSIGNED_INT = 5125,
  62399. /**
  62400. * Float
  62401. */
  62402. FLOAT = 5126,
  62403. }
  62404. /**
  62405. * Specifies if the attirbute is a scalar, vector, or matrix
  62406. */
  62407. const enum AccessorType {
  62408. /**
  62409. * Scalar
  62410. */
  62411. SCALAR = "SCALAR",
  62412. /**
  62413. * Vector2
  62414. */
  62415. VEC2 = "VEC2",
  62416. /**
  62417. * Vector3
  62418. */
  62419. VEC3 = "VEC3",
  62420. /**
  62421. * Vector4
  62422. */
  62423. VEC4 = "VEC4",
  62424. /**
  62425. * Matrix2x2
  62426. */
  62427. MAT2 = "MAT2",
  62428. /**
  62429. * Matrix3x3
  62430. */
  62431. MAT3 = "MAT3",
  62432. /**
  62433. * Matrix4x4
  62434. */
  62435. MAT4 = "MAT4",
  62436. }
  62437. /**
  62438. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62439. */
  62440. const enum AnimationChannelTargetPath {
  62441. /**
  62442. * Translation
  62443. */
  62444. TRANSLATION = "translation",
  62445. /**
  62446. * Rotation
  62447. */
  62448. ROTATION = "rotation",
  62449. /**
  62450. * Scale
  62451. */
  62452. SCALE = "scale",
  62453. /**
  62454. * Weights
  62455. */
  62456. WEIGHTS = "weights",
  62457. }
  62458. /**
  62459. * Interpolation algorithm
  62460. */
  62461. const enum AnimationSamplerInterpolation {
  62462. /**
  62463. * The animated values are linearly interpolated between keyframes
  62464. */
  62465. LINEAR = "LINEAR",
  62466. /**
  62467. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  62468. */
  62469. STEP = "STEP",
  62470. /**
  62471. * The animation's interpolation is computed using a cubic spline with specified tangents
  62472. */
  62473. CUBICSPLINE = "CUBICSPLINE",
  62474. }
  62475. /**
  62476. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62477. */
  62478. const enum CameraType {
  62479. /**
  62480. * A perspective camera containing properties to create a perspective projection matrix
  62481. */
  62482. PERSPECTIVE = "perspective",
  62483. /**
  62484. * An orthographic camera containing properties to create an orthographic projection matrix
  62485. */
  62486. ORTHOGRAPHIC = "orthographic",
  62487. }
  62488. /**
  62489. * The mime-type of the image
  62490. */
  62491. const enum ImageMimeType {
  62492. /**
  62493. * JPEG Mime-type
  62494. */
  62495. JPEG = "image/jpeg",
  62496. /**
  62497. * PNG Mime-type
  62498. */
  62499. PNG = "image/png",
  62500. }
  62501. /**
  62502. * The alpha rendering mode of the material
  62503. */
  62504. const enum MaterialAlphaMode {
  62505. /**
  62506. * The alpha value is ignored and the rendered output is fully opaque
  62507. */
  62508. OPAQUE = "OPAQUE",
  62509. /**
  62510. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  62511. */
  62512. MASK = "MASK",
  62513. /**
  62514. * 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)
  62515. */
  62516. BLEND = "BLEND",
  62517. }
  62518. /**
  62519. * The type of the primitives to render
  62520. */
  62521. const enum MeshPrimitiveMode {
  62522. /**
  62523. * Points
  62524. */
  62525. POINTS = 0,
  62526. /**
  62527. * Lines
  62528. */
  62529. LINES = 1,
  62530. /**
  62531. * Line Loop
  62532. */
  62533. LINE_LOOP = 2,
  62534. /**
  62535. * Line Strip
  62536. */
  62537. LINE_STRIP = 3,
  62538. /**
  62539. * Triangles
  62540. */
  62541. TRIANGLES = 4,
  62542. /**
  62543. * Triangle Strip
  62544. */
  62545. TRIANGLE_STRIP = 5,
  62546. /**
  62547. * Triangle Fan
  62548. */
  62549. TRIANGLE_FAN = 6,
  62550. }
  62551. /**
  62552. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  62553. */
  62554. const enum TextureMagFilter {
  62555. /**
  62556. * Nearest
  62557. */
  62558. NEAREST = 9728,
  62559. /**
  62560. * Linear
  62561. */
  62562. LINEAR = 9729,
  62563. }
  62564. /**
  62565. * Minification filter. All valid values correspond to WebGL enums
  62566. */
  62567. const enum TextureMinFilter {
  62568. /**
  62569. * Nearest
  62570. */
  62571. NEAREST = 9728,
  62572. /**
  62573. * Linear
  62574. */
  62575. LINEAR = 9729,
  62576. /**
  62577. * Nearest Mip-Map Nearest
  62578. */
  62579. NEAREST_MIPMAP_NEAREST = 9984,
  62580. /**
  62581. * Linear Mipmap Nearest
  62582. */
  62583. LINEAR_MIPMAP_NEAREST = 9985,
  62584. /**
  62585. * Nearest Mipmap Linear
  62586. */
  62587. NEAREST_MIPMAP_LINEAR = 9986,
  62588. /**
  62589. * Linear Mipmap Linear
  62590. */
  62591. LINEAR_MIPMAP_LINEAR = 9987,
  62592. }
  62593. /**
  62594. * S (U) wrapping mode. All valid values correspond to WebGL enums
  62595. */
  62596. const enum TextureWrapMode {
  62597. /**
  62598. * Clamp to Edge
  62599. */
  62600. CLAMP_TO_EDGE = 33071,
  62601. /**
  62602. * Mirrored Repeat
  62603. */
  62604. MIRRORED_REPEAT = 33648,
  62605. /**
  62606. * Repeat
  62607. */
  62608. REPEAT = 10497,
  62609. }
  62610. /**
  62611. * glTF Property
  62612. */
  62613. interface IProperty {
  62614. /**
  62615. * Dictionary object with extension-specific objects
  62616. */
  62617. extensions?: {
  62618. [key: string]: any;
  62619. };
  62620. /**
  62621. * Application-Specific data
  62622. */
  62623. extras?: any;
  62624. }
  62625. /**
  62626. * glTF Child of Root Property
  62627. */
  62628. interface IChildRootProperty extends IProperty {
  62629. /**
  62630. * The user-defined name of this object
  62631. */
  62632. name?: string;
  62633. }
  62634. /**
  62635. * Indices of those attributes that deviate from their initialization value
  62636. */
  62637. interface IAccessorSparseIndices extends IProperty {
  62638. /**
  62639. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  62640. */
  62641. bufferView: number;
  62642. /**
  62643. * The offset relative to the start of the bufferView in bytes. Must be aligned
  62644. */
  62645. byteOffset?: number;
  62646. /**
  62647. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  62648. */
  62649. componentType: AccessorComponentType;
  62650. }
  62651. /**
  62652. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  62653. */
  62654. interface IAccessorSparseValues extends IProperty {
  62655. /**
  62656. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  62657. */
  62658. bufferView: number;
  62659. /**
  62660. * The offset relative to the start of the bufferView in bytes. Must be aligned
  62661. */
  62662. byteOffset?: number;
  62663. }
  62664. /**
  62665. * Sparse storage of attributes that deviate from their initialization value
  62666. */
  62667. interface IAccessorSparse extends IProperty {
  62668. /**
  62669. * The number of attributes encoded in this sparse accessor
  62670. */
  62671. count: number;
  62672. /**
  62673. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  62674. */
  62675. indices: IAccessorSparseIndices;
  62676. /**
  62677. * 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
  62678. */
  62679. values: IAccessorSparseValues;
  62680. }
  62681. /**
  62682. * 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
  62683. */
  62684. interface IAccessor extends IChildRootProperty {
  62685. /**
  62686. * The index of the bufferview
  62687. */
  62688. bufferView?: number;
  62689. /**
  62690. * The offset relative to the start of the bufferView in bytes
  62691. */
  62692. byteOffset?: number;
  62693. /**
  62694. * The datatype of components in the attribute
  62695. */
  62696. componentType: AccessorComponentType;
  62697. /**
  62698. * Specifies whether integer data values should be normalized
  62699. */
  62700. normalized?: boolean;
  62701. /**
  62702. * The number of attributes referenced by this accessor
  62703. */
  62704. count: number;
  62705. /**
  62706. * Specifies if the attribute is a scalar, vector, or matrix
  62707. */
  62708. type: AccessorType;
  62709. /**
  62710. * Maximum value of each component in this attribute
  62711. */
  62712. max?: number[];
  62713. /**
  62714. * Minimum value of each component in this attribute
  62715. */
  62716. min?: number[];
  62717. /**
  62718. * Sparse storage of attributes that deviate from their initialization value
  62719. */
  62720. sparse?: IAccessorSparse;
  62721. }
  62722. /**
  62723. * Targets an animation's sampler at a node's property
  62724. */
  62725. interface IAnimationChannel extends IProperty {
  62726. /**
  62727. * The index of a sampler in this animation used to compute the value for the target
  62728. */
  62729. sampler: number;
  62730. /**
  62731. * The index of the node and TRS property to target
  62732. */
  62733. target: IAnimationChannelTarget;
  62734. }
  62735. /**
  62736. * The index of the node and TRS property that an animation channel targets
  62737. */
  62738. interface IAnimationChannelTarget extends IProperty {
  62739. /**
  62740. * The index of the node to target
  62741. */
  62742. node: number;
  62743. /**
  62744. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62745. */
  62746. path: AnimationChannelTargetPath;
  62747. }
  62748. /**
  62749. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  62750. */
  62751. interface IAnimationSampler extends IProperty {
  62752. /**
  62753. * The index of an accessor containing keyframe input values, e.g., time
  62754. */
  62755. input: number;
  62756. /**
  62757. * Interpolation algorithm
  62758. */
  62759. interpolation?: AnimationSamplerInterpolation;
  62760. /**
  62761. * The index of an accessor, containing keyframe output values
  62762. */
  62763. output: number;
  62764. }
  62765. /**
  62766. * A keyframe animation
  62767. */
  62768. interface IAnimation extends IChildRootProperty {
  62769. /**
  62770. * An array of channels, each of which targets an animation's sampler at a node's property
  62771. */
  62772. channels: IAnimationChannel[];
  62773. /**
  62774. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  62775. */
  62776. samplers: IAnimationSampler[];
  62777. }
  62778. /**
  62779. * Metadata about the glTF asset
  62780. */
  62781. interface IAsset extends IChildRootProperty {
  62782. /**
  62783. * A copyright message suitable for display to credit the content creator
  62784. */
  62785. copyright?: string;
  62786. /**
  62787. * Tool that generated this glTF model. Useful for debugging
  62788. */
  62789. generator?: string;
  62790. /**
  62791. * The glTF version that this asset targets
  62792. */
  62793. version: string;
  62794. /**
  62795. * The minimum glTF version that this asset targets
  62796. */
  62797. minVersion?: string;
  62798. }
  62799. /**
  62800. * A buffer points to binary geometry, animation, or skins
  62801. */
  62802. interface IBuffer extends IChildRootProperty {
  62803. /**
  62804. * 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
  62805. */
  62806. uri?: string;
  62807. /**
  62808. * The length of the buffer in bytes
  62809. */
  62810. byteLength: number;
  62811. }
  62812. /**
  62813. * A view into a buffer generally representing a subset of the buffer
  62814. */
  62815. interface IBufferView extends IChildRootProperty {
  62816. /**
  62817. * The index of the buffer
  62818. */
  62819. buffer: number;
  62820. /**
  62821. * The offset into the buffer in bytes
  62822. */
  62823. byteOffset?: number;
  62824. /**
  62825. * The lenth of the bufferView in bytes
  62826. */
  62827. byteLength: number;
  62828. /**
  62829. * The stride, in bytes
  62830. */
  62831. byteStride?: number;
  62832. }
  62833. /**
  62834. * An orthographic camera containing properties to create an orthographic projection matrix
  62835. */
  62836. interface ICameraOrthographic extends IProperty {
  62837. /**
  62838. * The floating-point horizontal magnification of the view. Must not be zero
  62839. */
  62840. xmag: number;
  62841. /**
  62842. * The floating-point vertical magnification of the view. Must not be zero
  62843. */
  62844. ymag: number;
  62845. /**
  62846. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  62847. */
  62848. zfar: number;
  62849. /**
  62850. * The floating-point distance to the near clipping plane
  62851. */
  62852. znear: number;
  62853. }
  62854. /**
  62855. * A perspective camera containing properties to create a perspective projection matrix
  62856. */
  62857. interface ICameraPerspective extends IProperty {
  62858. /**
  62859. * The floating-point aspect ratio of the field of view
  62860. */
  62861. aspectRatio?: number;
  62862. /**
  62863. * The floating-point vertical field of view in radians
  62864. */
  62865. yfov: number;
  62866. /**
  62867. * The floating-point distance to the far clipping plane
  62868. */
  62869. zfar?: number;
  62870. /**
  62871. * The floating-point distance to the near clipping plane
  62872. */
  62873. znear: number;
  62874. }
  62875. /**
  62876. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62877. */
  62878. interface ICamera extends IChildRootProperty {
  62879. /**
  62880. * An orthographic camera containing properties to create an orthographic projection matrix
  62881. */
  62882. orthographic?: ICameraOrthographic;
  62883. /**
  62884. * A perspective camera containing properties to create a perspective projection matrix
  62885. */
  62886. perspective?: ICameraPerspective;
  62887. /**
  62888. * Specifies if the camera uses a perspective or orthographic projection
  62889. */
  62890. type: CameraType;
  62891. }
  62892. /**
  62893. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  62894. */
  62895. interface IImage extends IChildRootProperty {
  62896. /**
  62897. * 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
  62898. */
  62899. uri?: string;
  62900. /**
  62901. * The image's MIME type
  62902. */
  62903. mimeType?: ImageMimeType;
  62904. /**
  62905. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  62906. */
  62907. bufferView?: number;
  62908. }
  62909. /**
  62910. * Material Normal Texture Info
  62911. */
  62912. interface IMaterialNormalTextureInfo extends ITextureInfo {
  62913. /**
  62914. * The scalar multiplier applied to each normal vector of the normal texture
  62915. */
  62916. scale?: number;
  62917. }
  62918. /**
  62919. * Material Occlusion Texture Info
  62920. */
  62921. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  62922. /**
  62923. * A scalar multiplier controlling the amount of occlusion applied
  62924. */
  62925. strength?: number;
  62926. }
  62927. /**
  62928. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  62929. */
  62930. interface IMaterialPbrMetallicRoughness {
  62931. /**
  62932. * The material's base color factor
  62933. */
  62934. baseColorFactor?: number[];
  62935. /**
  62936. * The base color texture
  62937. */
  62938. baseColorTexture?: ITextureInfo;
  62939. /**
  62940. * The metalness of the material
  62941. */
  62942. metallicFactor?: number;
  62943. /**
  62944. * The roughness of the material
  62945. */
  62946. roughnessFactor?: number;
  62947. /**
  62948. * The metallic-roughness texture
  62949. */
  62950. metallicRoughnessTexture?: ITextureInfo;
  62951. }
  62952. /**
  62953. * The material appearance of a primitive
  62954. */
  62955. interface IMaterial extends IChildRootProperty {
  62956. /**
  62957. * 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
  62958. */
  62959. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  62960. /**
  62961. * The normal map texture
  62962. */
  62963. normalTexture?: IMaterialNormalTextureInfo;
  62964. /**
  62965. * The occlusion map texture
  62966. */
  62967. occlusionTexture?: IMaterialOcclusionTextureInfo;
  62968. /**
  62969. * The emissive map texture
  62970. */
  62971. emissiveTexture?: ITextureInfo;
  62972. /**
  62973. * 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
  62974. */
  62975. emissiveFactor?: number[];
  62976. /**
  62977. * The alpha rendering mode of the material
  62978. */
  62979. alphaMode?: MaterialAlphaMode;
  62980. /**
  62981. * The alpha cutoff value of the material
  62982. */
  62983. alphaCutoff?: number;
  62984. /**
  62985. * Specifies whether the material is double sided
  62986. */
  62987. doubleSided?: boolean;
  62988. }
  62989. /**
  62990. * Geometry to be rendered with the given material
  62991. */
  62992. interface IMeshPrimitive extends IProperty {
  62993. /**
  62994. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  62995. */
  62996. attributes: {
  62997. [name: string]: number;
  62998. };
  62999. /**
  63000. * The index of the accessor that contains the indices
  63001. */
  63002. indices?: number;
  63003. /**
  63004. * The index of the material to apply to this primitive when rendering
  63005. */
  63006. material?: number;
  63007. /**
  63008. * The type of primitives to render. All valid values correspond to WebGL enums
  63009. */
  63010. mode?: MeshPrimitiveMode;
  63011. /**
  63012. * 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
  63013. */
  63014. targets?: {
  63015. [name: string]: number;
  63016. }[];
  63017. }
  63018. /**
  63019. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  63020. */
  63021. interface IMesh extends IChildRootProperty {
  63022. /**
  63023. * An array of primitives, each defining geometry to be rendered with a material
  63024. */
  63025. primitives: IMeshPrimitive[];
  63026. /**
  63027. * Array of weights to be applied to the Morph Targets
  63028. */
  63029. weights?: number[];
  63030. }
  63031. /**
  63032. * A node in the node hierarchy
  63033. */
  63034. interface INode extends IChildRootProperty {
  63035. /**
  63036. * The index of the camera referenced by this node
  63037. */
  63038. camera?: number;
  63039. /**
  63040. * The indices of this node's children
  63041. */
  63042. children?: number[];
  63043. /**
  63044. * The index of the skin referenced by this node
  63045. */
  63046. skin?: number;
  63047. /**
  63048. * A floating-point 4x4 transformation matrix stored in column-major order
  63049. */
  63050. matrix?: number[];
  63051. /**
  63052. * The index of the mesh in this node
  63053. */
  63054. mesh?: number;
  63055. /**
  63056. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  63057. */
  63058. rotation?: number[];
  63059. /**
  63060. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  63061. */
  63062. scale?: number[];
  63063. /**
  63064. * The node's translation along the x, y, and z axes
  63065. */
  63066. translation?: number[];
  63067. /**
  63068. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  63069. */
  63070. weights?: number[];
  63071. }
  63072. /**
  63073. * Texture sampler properties for filtering and wrapping modes
  63074. */
  63075. interface ISampler extends IChildRootProperty {
  63076. /**
  63077. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  63078. */
  63079. magFilter?: TextureMagFilter;
  63080. /**
  63081. * Minification filter. All valid values correspond to WebGL enums
  63082. */
  63083. minFilter?: TextureMinFilter;
  63084. /**
  63085. * S (U) wrapping mode. All valid values correspond to WebGL enums
  63086. */
  63087. wrapS?: TextureWrapMode;
  63088. /**
  63089. * T (V) wrapping mode. All valid values correspond to WebGL enums
  63090. */
  63091. wrapT?: TextureWrapMode;
  63092. }
  63093. /**
  63094. * The root nodes of a scene
  63095. */
  63096. interface IScene extends IChildRootProperty {
  63097. /**
  63098. * The indices of each root node
  63099. */
  63100. nodes: number[];
  63101. }
  63102. /**
  63103. * Joints and matrices defining a skin
  63104. */
  63105. interface ISkin extends IChildRootProperty {
  63106. /**
  63107. * 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
  63108. */
  63109. inverseBindMatrices?: number;
  63110. /**
  63111. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  63112. */
  63113. skeleton?: number;
  63114. /**
  63115. * 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)
  63116. */
  63117. joints: number[];
  63118. }
  63119. /**
  63120. * A texture and its sampler
  63121. */
  63122. interface ITexture extends IChildRootProperty {
  63123. /**
  63124. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  63125. */
  63126. sampler?: number;
  63127. /**
  63128. * The index of the image used by this texture
  63129. */
  63130. source: number;
  63131. }
  63132. /**
  63133. * Reference to a texture
  63134. */
  63135. interface ITextureInfo extends IProperty {
  63136. /**
  63137. * The index of the texture
  63138. */
  63139. index: number;
  63140. /**
  63141. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  63142. */
  63143. texCoord?: number;
  63144. }
  63145. /**
  63146. * The root object for a glTF asset
  63147. */
  63148. interface IGLTF extends IProperty {
  63149. /**
  63150. * An array of accessors. An accessor is a typed view into a bufferView
  63151. */
  63152. accessors?: IAccessor[];
  63153. /**
  63154. * An array of keyframe animations
  63155. */
  63156. animations?: IAnimation[];
  63157. /**
  63158. * Metadata about the glTF asset
  63159. */
  63160. asset: IAsset;
  63161. /**
  63162. * An array of buffers. A buffer points to binary geometry, animation, or skins
  63163. */
  63164. buffers?: IBuffer[];
  63165. /**
  63166. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  63167. */
  63168. bufferViews?: IBufferView[];
  63169. /**
  63170. * An array of cameras
  63171. */
  63172. cameras?: ICamera[];
  63173. /**
  63174. * Names of glTF extensions used somewhere in this asset
  63175. */
  63176. extensionsUsed?: string[];
  63177. /**
  63178. * Names of glTF extensions required to properly load this asset
  63179. */
  63180. extensionsRequired?: string[];
  63181. /**
  63182. * An array of images. An image defines data used to create a texture
  63183. */
  63184. images?: IImage[];
  63185. /**
  63186. * An array of materials. A material defines the appearance of a primitive
  63187. */
  63188. materials?: IMaterial[];
  63189. /**
  63190. * An array of meshes. A mesh is a set of primitives to be rendered
  63191. */
  63192. meshes?: IMesh[];
  63193. /**
  63194. * An array of nodes
  63195. */
  63196. nodes?: INode[];
  63197. /**
  63198. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  63199. */
  63200. samplers?: ISampler[];
  63201. /**
  63202. * The index of the default scene
  63203. */
  63204. scene?: number;
  63205. /**
  63206. * An array of scenes
  63207. */
  63208. scenes?: IScene[];
  63209. /**
  63210. * An array of skins. A skin is defined by joints and matrices
  63211. */
  63212. skins?: ISkin[];
  63213. /**
  63214. * An array of textures
  63215. */
  63216. textures?: ITexture[];
  63217. }
  63218. /**
  63219. * Interface for glTF validation results
  63220. */
  63221. interface IGLTFValidationResults {
  63222. info: {
  63223. generator: string;
  63224. hasAnimations: boolean;
  63225. hasDefaultScene: boolean;
  63226. hasMaterials: boolean;
  63227. hasMorphTargets: boolean;
  63228. hasSkins: boolean;
  63229. hasTextures: boolean;
  63230. maxAttributesUsed: number;
  63231. primitivesCount: number
  63232. };
  63233. issues: {
  63234. messages: Array<string>;
  63235. numErrors: number;
  63236. numHints: number;
  63237. numInfos: number;
  63238. numWarnings: number;
  63239. truncated: boolean
  63240. };
  63241. mimeType: string;
  63242. uri: string;
  63243. validatedAt: string;
  63244. validatorVersion: string;
  63245. }
  63246. /**
  63247. * Interface for glTF validation options
  63248. */
  63249. interface IGLTFValidationOptions {
  63250. uri?: string;
  63251. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63252. validateAccessorData?: boolean;
  63253. maxIssues?: number;
  63254. ignoredIssues?: Array<string>;
  63255. severityOverrides?: Object;
  63256. }
  63257. /**
  63258. * glTF validator object Tyyings
  63259. */
  63260. interface IGLTFValidatorTypings {
  63261. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63262. }
  63263. }
  63264. /**
  63265. * Interface for glTF validation results
  63266. */
  63267. interface IGLTFValidationResults {
  63268. info: {
  63269. generator: string;
  63270. hasAnimations: boolean;
  63271. hasDefaultScene: boolean;
  63272. hasMaterials: boolean;
  63273. hasMorphTargets: boolean;
  63274. hasSkins: boolean;
  63275. hasTextures: boolean;
  63276. maxAttributesUsed: number;
  63277. primitivesCount: number
  63278. };
  63279. issues: {
  63280. messages: Array<string>;
  63281. numErrors: number;
  63282. numHints: number;
  63283. numInfos: number;
  63284. numWarnings: number;
  63285. truncated: boolean
  63286. };
  63287. mimeType: string;
  63288. uri: string;
  63289. validatedAt: string;
  63290. validatorVersion: string;
  63291. }
  63292. /**
  63293. * Interface for glTF validation options
  63294. */
  63295. interface IGLTFValidationOptions {
  63296. uri?: string;
  63297. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63298. validateAccessorData?: boolean;
  63299. maxIssues?: number;
  63300. ignoredIssues?: Array<string>;
  63301. severityOverrides?: Object;
  63302. }
  63303. /**
  63304. * glTF validator object Tyyings
  63305. */
  63306. interface IGLTFValidatorTypings {
  63307. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63308. }
  63309. declare module BABYLON {
  63310. /** @hidden */
  63311. export var cellPixelShader: {
  63312. name: string;
  63313. shader: string;
  63314. };
  63315. }
  63316. declare module BABYLON {
  63317. /** @hidden */
  63318. export var cellVertexShader: {
  63319. name: string;
  63320. shader: string;
  63321. };
  63322. }
  63323. declare module BABYLON {
  63324. export class CellMaterial extends BABYLON.PushMaterial {
  63325. private _diffuseTexture;
  63326. diffuseTexture: BABYLON.BaseTexture;
  63327. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  63328. computeHighLevel: boolean;
  63329. private _disableLighting;
  63330. disableLighting: boolean;
  63331. private _maxSimultaneousLights;
  63332. maxSimultaneousLights: number;
  63333. private _renderId;
  63334. constructor(name: string, scene: BABYLON.Scene);
  63335. needAlphaBlending(): boolean;
  63336. needAlphaTesting(): boolean;
  63337. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63338. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63339. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63340. getAnimatables(): BABYLON.IAnimatable[];
  63341. getActiveTextures(): BABYLON.BaseTexture[];
  63342. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63343. dispose(forceDisposeEffect?: boolean): void;
  63344. getClassName(): string;
  63345. clone(name: string): CellMaterial;
  63346. serialize(): any;
  63347. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  63348. }
  63349. }
  63350. declare module BABYLON {
  63351. export class CustomShaderStructure {
  63352. FragmentStore: string;
  63353. VertexStore: string;
  63354. constructor();
  63355. }
  63356. export class ShaderSpecialParts {
  63357. constructor();
  63358. Fragment_Begin: string;
  63359. Fragment_Definitions: string;
  63360. Fragment_MainBegin: string;
  63361. Fragment_Custom_Diffuse: string;
  63362. Fragment_Before_Lights: string;
  63363. Fragment_Before_Fog: string;
  63364. Fragment_Custom_Alpha: string;
  63365. Fragment_Before_FragColor: string;
  63366. Vertex_Begin: string;
  63367. Vertex_Definitions: string;
  63368. Vertex_MainBegin: string;
  63369. Vertex_Before_PositionUpdated: string;
  63370. Vertex_Before_NormalUpdated: string;
  63371. Vertex_MainEnd: string;
  63372. }
  63373. export class CustomMaterial extends BABYLON.StandardMaterial {
  63374. static ShaderIndexer: number;
  63375. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63376. FragmentShader: string;
  63377. VertexShader: string;
  63378. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63379. ReviewUniform(name: string, arr: string[]): string[];
  63380. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  63381. constructor(name: string, scene: BABYLON.Scene);
  63382. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  63383. Fragment_Begin(shaderPart: string): CustomMaterial;
  63384. Fragment_Definitions(shaderPart: string): CustomMaterial;
  63385. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  63386. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  63387. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  63388. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  63389. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  63390. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  63391. Vertex_Begin(shaderPart: string): CustomMaterial;
  63392. Vertex_Definitions(shaderPart: string): CustomMaterial;
  63393. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  63394. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  63395. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  63396. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  63397. }
  63398. }
  63399. declare module BABYLON {
  63400. export class ShaderAlebdoParts {
  63401. constructor();
  63402. Fragment_Begin: string;
  63403. Fragment_Definitions: string;
  63404. Fragment_MainBegin: string;
  63405. Fragment_Custom_Albedo: string;
  63406. Fragment_Before_Lights: string;
  63407. Fragment_Before_Fog: string;
  63408. Fragment_Custom_Alpha: string;
  63409. Fragment_Before_FragColor: string;
  63410. Vertex_Begin: string;
  63411. Vertex_Definitions: string;
  63412. Vertex_MainBegin: string;
  63413. Vertex_Before_PositionUpdated: string;
  63414. Vertex_Before_NormalUpdated: string;
  63415. Vertex_MainEnd: string;
  63416. }
  63417. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  63418. static ShaderIndexer: number;
  63419. CustomParts: ShaderAlebdoParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63420. FragmentShader: string;
  63421. VertexShader: string;
  63422. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63423. ReviewUniform(name: string, arr: string[]): string[];
  63424. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  63425. constructor(name: string, scene: BABYLON.Scene);
  63426. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  63427. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  63428. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  63429. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  63430. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  63431. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  63432. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  63433. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  63434. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  63435. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  63436. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  63437. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  63438. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  63439. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  63440. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  63441. }
  63442. }
  63443. declare module BABYLON {
  63444. /** @hidden */
  63445. export var firePixelShader: {
  63446. name: string;
  63447. shader: string;
  63448. };
  63449. }
  63450. declare module BABYLON {
  63451. /** @hidden */
  63452. export var fireVertexShader: {
  63453. name: string;
  63454. shader: string;
  63455. };
  63456. }
  63457. declare module BABYLON {
  63458. export class FireMaterial extends BABYLON.PushMaterial {
  63459. private _diffuseTexture;
  63460. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63461. private _distortionTexture;
  63462. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63463. private _opacityTexture;
  63464. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63465. diffuseColor: BABYLON.Color3;
  63466. speed: number;
  63467. private _scaledDiffuse;
  63468. private _renderId;
  63469. private _lastTime;
  63470. constructor(name: string, scene: BABYLON.Scene);
  63471. needAlphaBlending(): boolean;
  63472. needAlphaTesting(): boolean;
  63473. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63474. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63475. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63476. getAnimatables(): BABYLON.IAnimatable[];
  63477. getActiveTextures(): BABYLON.BaseTexture[];
  63478. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63479. getClassName(): string;
  63480. dispose(forceDisposeEffect?: boolean): void;
  63481. clone(name: string): FireMaterial;
  63482. serialize(): any;
  63483. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  63484. }
  63485. }
  63486. declare module BABYLON {
  63487. /** @hidden */
  63488. export var furPixelShader: {
  63489. name: string;
  63490. shader: string;
  63491. };
  63492. }
  63493. declare module BABYLON {
  63494. /** @hidden */
  63495. export var furVertexShader: {
  63496. name: string;
  63497. shader: string;
  63498. };
  63499. }
  63500. declare module BABYLON {
  63501. export class FurMaterial extends BABYLON.PushMaterial {
  63502. private _diffuseTexture;
  63503. diffuseTexture: BABYLON.BaseTexture;
  63504. private _heightTexture;
  63505. heightTexture: BABYLON.BaseTexture;
  63506. diffuseColor: BABYLON.Color3;
  63507. furLength: number;
  63508. furAngle: number;
  63509. furColor: BABYLON.Color3;
  63510. furOffset: number;
  63511. furSpacing: number;
  63512. furGravity: BABYLON.Vector3;
  63513. furSpeed: number;
  63514. furDensity: number;
  63515. furOcclusion: number;
  63516. furTexture: BABYLON.DynamicTexture;
  63517. private _disableLighting;
  63518. disableLighting: boolean;
  63519. private _maxSimultaneousLights;
  63520. maxSimultaneousLights: number;
  63521. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  63522. private _renderId;
  63523. private _furTime;
  63524. constructor(name: string, scene: BABYLON.Scene);
  63525. furTime: number;
  63526. needAlphaBlending(): boolean;
  63527. needAlphaTesting(): boolean;
  63528. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63529. updateFur(): void;
  63530. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63531. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63532. getAnimatables(): BABYLON.IAnimatable[];
  63533. getActiveTextures(): BABYLON.BaseTexture[];
  63534. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63535. dispose(forceDisposeEffect?: boolean): void;
  63536. clone(name: string): FurMaterial;
  63537. serialize(): any;
  63538. getClassName(): string;
  63539. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  63540. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  63541. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  63542. }
  63543. }
  63544. declare module BABYLON {
  63545. /** @hidden */
  63546. export var gradientPixelShader: {
  63547. name: string;
  63548. shader: string;
  63549. };
  63550. }
  63551. declare module BABYLON {
  63552. /** @hidden */
  63553. export var gradientVertexShader: {
  63554. name: string;
  63555. shader: string;
  63556. };
  63557. }
  63558. declare module BABYLON {
  63559. export class GradientMaterial extends BABYLON.PushMaterial {
  63560. private _maxSimultaneousLights;
  63561. maxSimultaneousLights: number;
  63562. topColor: BABYLON.Color3;
  63563. topColorAlpha: number;
  63564. bottomColor: BABYLON.Color3;
  63565. bottomColorAlpha: number;
  63566. offset: number;
  63567. scale: number;
  63568. smoothness: number;
  63569. private _disableLighting;
  63570. disableLighting: boolean;
  63571. private _renderId;
  63572. constructor(name: string, scene: BABYLON.Scene);
  63573. needAlphaBlending(): boolean;
  63574. needAlphaTesting(): boolean;
  63575. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63576. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63577. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63578. getAnimatables(): BABYLON.IAnimatable[];
  63579. dispose(forceDisposeEffect?: boolean): void;
  63580. clone(name: string): GradientMaterial;
  63581. serialize(): any;
  63582. getClassName(): string;
  63583. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  63584. }
  63585. }
  63586. declare module BABYLON {
  63587. /** @hidden */
  63588. export var gridPixelShader: {
  63589. name: string;
  63590. shader: string;
  63591. };
  63592. }
  63593. declare module BABYLON {
  63594. /** @hidden */
  63595. export var gridVertexShader: {
  63596. name: string;
  63597. shader: string;
  63598. };
  63599. }
  63600. declare module BABYLON {
  63601. /**
  63602. * The grid materials allows you to wrap any shape with a grid.
  63603. * Colors are customizable.
  63604. */
  63605. export class GridMaterial extends BABYLON.PushMaterial {
  63606. /**
  63607. * Main color of the grid (e.g. between lines)
  63608. */
  63609. mainColor: BABYLON.Color3;
  63610. /**
  63611. * Color of the grid lines.
  63612. */
  63613. lineColor: BABYLON.Color3;
  63614. /**
  63615. * The scale of the grid compared to unit.
  63616. */
  63617. gridRatio: number;
  63618. /**
  63619. * Allows setting an offset for the grid lines.
  63620. */
  63621. gridOffset: BABYLON.Vector3;
  63622. /**
  63623. * The frequency of thicker lines.
  63624. */
  63625. majorUnitFrequency: number;
  63626. /**
  63627. * The visibility of minor units in the grid.
  63628. */
  63629. minorUnitVisibility: number;
  63630. /**
  63631. * The grid opacity outside of the lines.
  63632. */
  63633. opacity: number;
  63634. /**
  63635. * Determine RBG output is premultiplied by alpha value.
  63636. */
  63637. preMultiplyAlpha: boolean;
  63638. private _opacityTexture;
  63639. opacityTexture: BABYLON.BaseTexture;
  63640. private _gridControl;
  63641. private _renderId;
  63642. /**
  63643. * constructor
  63644. * @param name The name given to the material in order to identify it afterwards.
  63645. * @param scene The scene the material is used in.
  63646. */
  63647. constructor(name: string, scene: BABYLON.Scene);
  63648. /**
  63649. * Returns wehter or not the grid requires alpha blending.
  63650. */
  63651. needAlphaBlending(): boolean;
  63652. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  63653. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63654. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63655. /**
  63656. * Dispose the material and its associated resources.
  63657. * @param forceDisposeEffect will also dispose the used effect when true
  63658. */
  63659. dispose(forceDisposeEffect?: boolean): void;
  63660. clone(name: string): GridMaterial;
  63661. serialize(): any;
  63662. getClassName(): string;
  63663. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  63664. }
  63665. }
  63666. declare module BABYLON {
  63667. /** @hidden */
  63668. export var lavaPixelShader: {
  63669. name: string;
  63670. shader: string;
  63671. };
  63672. }
  63673. declare module BABYLON {
  63674. /** @hidden */
  63675. export var lavaVertexShader: {
  63676. name: string;
  63677. shader: string;
  63678. };
  63679. }
  63680. declare module BABYLON {
  63681. export class LavaMaterial extends BABYLON.PushMaterial {
  63682. private _diffuseTexture;
  63683. diffuseTexture: BABYLON.BaseTexture;
  63684. noiseTexture: BABYLON.BaseTexture;
  63685. fogColor: BABYLON.Color3;
  63686. speed: number;
  63687. movingSpeed: number;
  63688. lowFrequencySpeed: number;
  63689. fogDensity: number;
  63690. private _lastTime;
  63691. diffuseColor: BABYLON.Color3;
  63692. private _disableLighting;
  63693. disableLighting: boolean;
  63694. private _unlit;
  63695. unlit: boolean;
  63696. private _maxSimultaneousLights;
  63697. maxSimultaneousLights: number;
  63698. private _scaledDiffuse;
  63699. private _renderId;
  63700. constructor(name: string, scene: BABYLON.Scene);
  63701. needAlphaBlending(): boolean;
  63702. needAlphaTesting(): boolean;
  63703. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63704. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63705. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63706. getAnimatables(): BABYLON.IAnimatable[];
  63707. getActiveTextures(): BABYLON.BaseTexture[];
  63708. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63709. dispose(forceDisposeEffect?: boolean): void;
  63710. clone(name: string): LavaMaterial;
  63711. serialize(): any;
  63712. getClassName(): string;
  63713. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  63714. }
  63715. }
  63716. declare module BABYLON {
  63717. /** @hidden */
  63718. export var mixPixelShader: {
  63719. name: string;
  63720. shader: string;
  63721. };
  63722. }
  63723. declare module BABYLON {
  63724. /** @hidden */
  63725. export var mixVertexShader: {
  63726. name: string;
  63727. shader: string;
  63728. };
  63729. }
  63730. declare module BABYLON {
  63731. export class MixMaterial extends BABYLON.PushMaterial {
  63732. /**
  63733. * Mix textures
  63734. */
  63735. private _mixTexture1;
  63736. mixTexture1: BABYLON.BaseTexture;
  63737. private _mixTexture2;
  63738. mixTexture2: BABYLON.BaseTexture;
  63739. /**
  63740. * Diffuse textures
  63741. */
  63742. private _diffuseTexture1;
  63743. diffuseTexture1: BABYLON.Texture;
  63744. private _diffuseTexture2;
  63745. diffuseTexture2: BABYLON.Texture;
  63746. private _diffuseTexture3;
  63747. diffuseTexture3: BABYLON.Texture;
  63748. private _diffuseTexture4;
  63749. diffuseTexture4: BABYLON.Texture;
  63750. private _diffuseTexture5;
  63751. diffuseTexture5: BABYLON.Texture;
  63752. private _diffuseTexture6;
  63753. diffuseTexture6: BABYLON.Texture;
  63754. private _diffuseTexture7;
  63755. diffuseTexture7: BABYLON.Texture;
  63756. private _diffuseTexture8;
  63757. diffuseTexture8: BABYLON.Texture;
  63758. /**
  63759. * Uniforms
  63760. */
  63761. diffuseColor: BABYLON.Color3;
  63762. specularColor: BABYLON.Color3;
  63763. specularPower: number;
  63764. private _disableLighting;
  63765. disableLighting: boolean;
  63766. private _maxSimultaneousLights;
  63767. maxSimultaneousLights: number;
  63768. private _renderId;
  63769. constructor(name: string, scene: BABYLON.Scene);
  63770. needAlphaBlending(): boolean;
  63771. needAlphaTesting(): boolean;
  63772. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63773. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63774. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63775. getAnimatables(): BABYLON.IAnimatable[];
  63776. getActiveTextures(): BABYLON.BaseTexture[];
  63777. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63778. dispose(forceDisposeEffect?: boolean): void;
  63779. clone(name: string): MixMaterial;
  63780. serialize(): any;
  63781. getClassName(): string;
  63782. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  63783. }
  63784. }
  63785. declare module BABYLON {
  63786. /** @hidden */
  63787. export var normalPixelShader: {
  63788. name: string;
  63789. shader: string;
  63790. };
  63791. }
  63792. declare module BABYLON {
  63793. /** @hidden */
  63794. export var normalVertexShader: {
  63795. name: string;
  63796. shader: string;
  63797. };
  63798. }
  63799. declare module BABYLON {
  63800. export class NormalMaterial extends BABYLON.PushMaterial {
  63801. private _diffuseTexture;
  63802. diffuseTexture: BABYLON.BaseTexture;
  63803. diffuseColor: BABYLON.Color3;
  63804. private _disableLighting;
  63805. disableLighting: boolean;
  63806. private _maxSimultaneousLights;
  63807. maxSimultaneousLights: number;
  63808. private _renderId;
  63809. constructor(name: string, scene: BABYLON.Scene);
  63810. needAlphaBlending(): boolean;
  63811. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  63812. needAlphaTesting(): boolean;
  63813. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63814. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63815. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63816. getAnimatables(): BABYLON.IAnimatable[];
  63817. getActiveTextures(): BABYLON.BaseTexture[];
  63818. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63819. dispose(forceDisposeEffect?: boolean): void;
  63820. clone(name: string): NormalMaterial;
  63821. serialize(): any;
  63822. getClassName(): string;
  63823. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  63824. }
  63825. }
  63826. declare module BABYLON {
  63827. /** @hidden */
  63828. export var shadowOnlyPixelShader: {
  63829. name: string;
  63830. shader: string;
  63831. };
  63832. }
  63833. declare module BABYLON {
  63834. /** @hidden */
  63835. export var shadowOnlyVertexShader: {
  63836. name: string;
  63837. shader: string;
  63838. };
  63839. }
  63840. declare module BABYLON {
  63841. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  63842. private _renderId;
  63843. private _activeLight;
  63844. constructor(name: string, scene: BABYLON.Scene);
  63845. shadowColor: BABYLON.Color3;
  63846. needAlphaBlending(): boolean;
  63847. needAlphaTesting(): boolean;
  63848. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63849. activeLight: BABYLON.IShadowLight;
  63850. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63851. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63852. clone(name: string): ShadowOnlyMaterial;
  63853. serialize(): any;
  63854. getClassName(): string;
  63855. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  63856. }
  63857. }
  63858. declare module BABYLON {
  63859. /** @hidden */
  63860. export var simplePixelShader: {
  63861. name: string;
  63862. shader: string;
  63863. };
  63864. }
  63865. declare module BABYLON {
  63866. /** @hidden */
  63867. export var simpleVertexShader: {
  63868. name: string;
  63869. shader: string;
  63870. };
  63871. }
  63872. declare module BABYLON {
  63873. export class SimpleMaterial extends BABYLON.PushMaterial {
  63874. private _diffuseTexture;
  63875. diffuseTexture: BABYLON.BaseTexture;
  63876. diffuseColor: BABYLON.Color3;
  63877. private _disableLighting;
  63878. disableLighting: boolean;
  63879. private _maxSimultaneousLights;
  63880. maxSimultaneousLights: number;
  63881. private _renderId;
  63882. constructor(name: string, scene: BABYLON.Scene);
  63883. needAlphaBlending(): boolean;
  63884. needAlphaTesting(): boolean;
  63885. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63886. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63887. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63888. getAnimatables(): BABYLON.IAnimatable[];
  63889. getActiveTextures(): BABYLON.BaseTexture[];
  63890. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63891. dispose(forceDisposeEffect?: boolean): void;
  63892. clone(name: string): SimpleMaterial;
  63893. serialize(): any;
  63894. getClassName(): string;
  63895. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  63896. }
  63897. }
  63898. declare module BABYLON {
  63899. /** @hidden */
  63900. export var skyPixelShader: {
  63901. name: string;
  63902. shader: string;
  63903. };
  63904. }
  63905. declare module BABYLON {
  63906. /** @hidden */
  63907. export var skyVertexShader: {
  63908. name: string;
  63909. shader: string;
  63910. };
  63911. }
  63912. declare module BABYLON {
  63913. /**
  63914. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  63915. * @see https://doc.babylonjs.com/extensions/sky
  63916. */
  63917. export class SkyMaterial extends BABYLON.PushMaterial {
  63918. /**
  63919. * Defines the overall luminance of sky in interval ]0, 1[.
  63920. */
  63921. luminance: number;
  63922. /**
  63923. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  63924. */
  63925. turbidity: number;
  63926. /**
  63927. * Defines the sky appearance (light intensity).
  63928. */
  63929. rayleigh: number;
  63930. /**
  63931. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  63932. */
  63933. mieCoefficient: number;
  63934. /**
  63935. * Defines the amount of haze particles following the Mie scattering theory.
  63936. */
  63937. mieDirectionalG: number;
  63938. /**
  63939. * Defines the distance of the sun according to the active scene camera.
  63940. */
  63941. distance: number;
  63942. /**
  63943. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  63944. * "inclined".
  63945. */
  63946. inclination: number;
  63947. /**
  63948. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  63949. * an object direction and a reference direction.
  63950. */
  63951. azimuth: number;
  63952. /**
  63953. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  63954. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  63955. */
  63956. sunPosition: BABYLON.Vector3;
  63957. /**
  63958. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  63959. * .sunPosition property.
  63960. */
  63961. useSunPosition: boolean;
  63962. /**
  63963. * Defines an offset vector used to get a horizon offset.
  63964. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  63965. */
  63966. cameraOffset: BABYLON.Vector3;
  63967. private _cameraPosition;
  63968. private _renderId;
  63969. /**
  63970. * Instantiates a new sky material.
  63971. * This material allows to create dynamic and texture free
  63972. * effects for skyboxes by taking care of the atmosphere state.
  63973. * @see https://doc.babylonjs.com/extensions/sky
  63974. * @param name Define the name of the material in the scene
  63975. * @param scene Define the scene the material belong to
  63976. */
  63977. constructor(name: string, scene: BABYLON.Scene);
  63978. /**
  63979. * Specifies if the material will require alpha blending
  63980. * @returns a boolean specifying if alpha blending is needed
  63981. */
  63982. needAlphaBlending(): boolean;
  63983. /**
  63984. * Specifies if this material should be rendered in alpha test mode
  63985. * @returns false as the sky material doesn't need alpha testing.
  63986. */
  63987. needAlphaTesting(): boolean;
  63988. /**
  63989. * Get the texture used for alpha test purpose.
  63990. * @returns null as the sky material has no texture.
  63991. */
  63992. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63993. /**
  63994. * Get if the submesh is ready to be used and all its information available.
  63995. * Child classes can use it to update shaders
  63996. * @param mesh defines the mesh to check
  63997. * @param subMesh defines which submesh to check
  63998. * @param useInstances specifies that instances should be used
  63999. * @returns a boolean indicating that the submesh is ready or not
  64000. */
  64001. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64002. /**
  64003. * Binds the submesh to this material by preparing the effect and shader to draw
  64004. * @param world defines the world transformation matrix
  64005. * @param mesh defines the mesh containing the submesh
  64006. * @param subMesh defines the submesh to bind the material to
  64007. */
  64008. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64009. /**
  64010. * Get the list of animatables in the material.
  64011. * @returns the list of animatables object used in the material
  64012. */
  64013. getAnimatables(): BABYLON.IAnimatable[];
  64014. /**
  64015. * Disposes the material
  64016. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64017. */
  64018. dispose(forceDisposeEffect?: boolean): void;
  64019. /**
  64020. * Makes a duplicate of the material, and gives it a new name
  64021. * @param name defines the new name for the duplicated material
  64022. * @returns the cloned material
  64023. */
  64024. clone(name: string): SkyMaterial;
  64025. /**
  64026. * Serializes this material in a JSON representation
  64027. * @returns the serialized material object
  64028. */
  64029. serialize(): any;
  64030. /**
  64031. * Gets the current class name of the material e.g. "SkyMaterial"
  64032. * Mainly use in serialization.
  64033. * @returns the class name
  64034. */
  64035. getClassName(): string;
  64036. /**
  64037. * Creates a sky material from parsed material data
  64038. * @param source defines the JSON representation of the material
  64039. * @param scene defines the hosting scene
  64040. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64041. * @returns a new sky material
  64042. */
  64043. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  64044. }
  64045. }
  64046. declare module BABYLON {
  64047. /** @hidden */
  64048. export var terrainPixelShader: {
  64049. name: string;
  64050. shader: string;
  64051. };
  64052. }
  64053. declare module BABYLON {
  64054. /** @hidden */
  64055. export var terrainVertexShader: {
  64056. name: string;
  64057. shader: string;
  64058. };
  64059. }
  64060. declare module BABYLON {
  64061. export class TerrainMaterial extends BABYLON.PushMaterial {
  64062. private _mixTexture;
  64063. mixTexture: BABYLON.BaseTexture;
  64064. private _diffuseTexture1;
  64065. diffuseTexture1: BABYLON.Texture;
  64066. private _diffuseTexture2;
  64067. diffuseTexture2: BABYLON.Texture;
  64068. private _diffuseTexture3;
  64069. diffuseTexture3: BABYLON.Texture;
  64070. private _bumpTexture1;
  64071. bumpTexture1: BABYLON.Texture;
  64072. private _bumpTexture2;
  64073. bumpTexture2: BABYLON.Texture;
  64074. private _bumpTexture3;
  64075. bumpTexture3: BABYLON.Texture;
  64076. diffuseColor: BABYLON.Color3;
  64077. specularColor: BABYLON.Color3;
  64078. specularPower: number;
  64079. private _disableLighting;
  64080. disableLighting: boolean;
  64081. private _maxSimultaneousLights;
  64082. maxSimultaneousLights: number;
  64083. private _renderId;
  64084. constructor(name: string, scene: BABYLON.Scene);
  64085. needAlphaBlending(): boolean;
  64086. needAlphaTesting(): boolean;
  64087. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64088. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64089. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64090. getAnimatables(): BABYLON.IAnimatable[];
  64091. getActiveTextures(): BABYLON.BaseTexture[];
  64092. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64093. dispose(forceDisposeEffect?: boolean): void;
  64094. clone(name: string): TerrainMaterial;
  64095. serialize(): any;
  64096. getClassName(): string;
  64097. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  64098. }
  64099. }
  64100. declare module BABYLON {
  64101. /** @hidden */
  64102. export var triplanarPixelShader: {
  64103. name: string;
  64104. shader: string;
  64105. };
  64106. }
  64107. declare module BABYLON {
  64108. /** @hidden */
  64109. export var triplanarVertexShader: {
  64110. name: string;
  64111. shader: string;
  64112. };
  64113. }
  64114. declare module BABYLON {
  64115. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  64116. mixTexture: BABYLON.BaseTexture;
  64117. private _diffuseTextureX;
  64118. diffuseTextureX: BABYLON.BaseTexture;
  64119. private _diffuseTextureY;
  64120. diffuseTextureY: BABYLON.BaseTexture;
  64121. private _diffuseTextureZ;
  64122. diffuseTextureZ: BABYLON.BaseTexture;
  64123. private _normalTextureX;
  64124. normalTextureX: BABYLON.BaseTexture;
  64125. private _normalTextureY;
  64126. normalTextureY: BABYLON.BaseTexture;
  64127. private _normalTextureZ;
  64128. normalTextureZ: BABYLON.BaseTexture;
  64129. tileSize: number;
  64130. diffuseColor: BABYLON.Color3;
  64131. specularColor: BABYLON.Color3;
  64132. specularPower: number;
  64133. private _disableLighting;
  64134. disableLighting: boolean;
  64135. private _maxSimultaneousLights;
  64136. maxSimultaneousLights: number;
  64137. private _renderId;
  64138. constructor(name: string, scene: BABYLON.Scene);
  64139. needAlphaBlending(): boolean;
  64140. needAlphaTesting(): boolean;
  64141. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64142. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64143. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64144. getAnimatables(): BABYLON.IAnimatable[];
  64145. getActiveTextures(): BABYLON.BaseTexture[];
  64146. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64147. dispose(forceDisposeEffect?: boolean): void;
  64148. clone(name: string): TriPlanarMaterial;
  64149. serialize(): any;
  64150. getClassName(): string;
  64151. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  64152. }
  64153. }
  64154. declare module BABYLON {
  64155. /** @hidden */
  64156. export var waterPixelShader: {
  64157. name: string;
  64158. shader: string;
  64159. };
  64160. }
  64161. declare module BABYLON {
  64162. /** @hidden */
  64163. export var waterVertexShader: {
  64164. name: string;
  64165. shader: string;
  64166. };
  64167. }
  64168. declare module BABYLON {
  64169. export class WaterMaterial extends BABYLON.PushMaterial {
  64170. renderTargetSize: BABYLON.Vector2;
  64171. private _bumpTexture;
  64172. bumpTexture: BABYLON.BaseTexture;
  64173. diffuseColor: BABYLON.Color3;
  64174. specularColor: BABYLON.Color3;
  64175. specularPower: number;
  64176. private _disableLighting;
  64177. disableLighting: boolean;
  64178. private _maxSimultaneousLights;
  64179. maxSimultaneousLights: number;
  64180. /**
  64181. * @param {number}: Represents the wind force
  64182. */
  64183. windForce: number;
  64184. /**
  64185. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  64186. */
  64187. windDirection: BABYLON.Vector2;
  64188. /**
  64189. * @param {number}: Wave height, represents the height of the waves
  64190. */
  64191. waveHeight: number;
  64192. /**
  64193. * @param {number}: Bump height, represents the bump height related to the bump map
  64194. */
  64195. bumpHeight: number;
  64196. /**
  64197. * @param {boolean}: Add a smaller moving bump to less steady waves.
  64198. */
  64199. private _bumpSuperimpose;
  64200. bumpSuperimpose: boolean;
  64201. /**
  64202. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  64203. */
  64204. private _fresnelSeparate;
  64205. fresnelSeparate: boolean;
  64206. /**
  64207. * @param {boolean}: bump Waves modify the reflection.
  64208. */
  64209. private _bumpAffectsReflection;
  64210. bumpAffectsReflection: boolean;
  64211. /**
  64212. * @param {number}: The water color blended with the refraction (near)
  64213. */
  64214. waterColor: BABYLON.Color3;
  64215. /**
  64216. * @param {number}: The blend factor related to the water color
  64217. */
  64218. colorBlendFactor: number;
  64219. /**
  64220. * @param {number}: The water color blended with the reflection (far)
  64221. */
  64222. waterColor2: BABYLON.Color3;
  64223. /**
  64224. * @param {number}: The blend factor related to the water color (reflection, far)
  64225. */
  64226. colorBlendFactor2: number;
  64227. /**
  64228. * @param {number}: Represents the maximum length of a wave
  64229. */
  64230. waveLength: number;
  64231. /**
  64232. * @param {number}: Defines the waves speed
  64233. */
  64234. waveSpeed: number;
  64235. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  64236. private _mesh;
  64237. private _refractionRTT;
  64238. private _reflectionRTT;
  64239. private _reflectionTransform;
  64240. private _lastTime;
  64241. private _lastDeltaTime;
  64242. private _renderId;
  64243. private _useLogarithmicDepth;
  64244. private _waitingRenderList;
  64245. /**
  64246. * Gets a boolean indicating that current material needs to register RTT
  64247. */
  64248. readonly hasRenderTargetTextures: boolean;
  64249. /**
  64250. * Constructor
  64251. */
  64252. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  64253. useLogarithmicDepth: boolean;
  64254. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64255. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64256. addToRenderList(node: any): void;
  64257. enableRenderTargets(enable: boolean): void;
  64258. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  64259. readonly renderTargetsEnabled: boolean;
  64260. needAlphaBlending(): boolean;
  64261. needAlphaTesting(): boolean;
  64262. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64263. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64264. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64265. private _createRenderTargets;
  64266. getAnimatables(): BABYLON.IAnimatable[];
  64267. getActiveTextures(): BABYLON.BaseTexture[];
  64268. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64269. dispose(forceDisposeEffect?: boolean): void;
  64270. clone(name: string): WaterMaterial;
  64271. serialize(): any;
  64272. getClassName(): string;
  64273. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  64274. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  64275. }
  64276. }
  64277. declare module BABYLON {
  64278. /** @hidden */
  64279. export var asciiartPixelShader: {
  64280. name: string;
  64281. shader: string;
  64282. };
  64283. }
  64284. declare module BABYLON {
  64285. /**
  64286. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  64287. *
  64288. * It basically takes care rendering the font front the given font size to a texture.
  64289. * This is used later on in the postprocess.
  64290. */
  64291. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  64292. private _font;
  64293. private _text;
  64294. private _charSize;
  64295. /**
  64296. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64297. */
  64298. readonly charSize: number;
  64299. /**
  64300. * Create a new instance of the Ascii Art FontTexture class
  64301. * @param name the name of the texture
  64302. * @param font the font to use, use the W3C CSS notation
  64303. * @param text the caracter set to use in the rendering.
  64304. * @param scene the scene that owns the texture
  64305. */
  64306. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64307. /**
  64308. * Gets the max char width of a font.
  64309. * @param font the font to use, use the W3C CSS notation
  64310. * @return the max char width
  64311. */
  64312. private getFontWidth;
  64313. /**
  64314. * Gets the max char height of a font.
  64315. * @param font the font to use, use the W3C CSS notation
  64316. * @return the max char height
  64317. */
  64318. private getFontHeight;
  64319. /**
  64320. * Clones the current AsciiArtTexture.
  64321. * @return the clone of the texture.
  64322. */
  64323. clone(): AsciiArtFontTexture;
  64324. /**
  64325. * Parses a json object representing the texture and returns an instance of it.
  64326. * @param source the source JSON representation
  64327. * @param scene the scene to create the texture for
  64328. * @return the parsed texture
  64329. */
  64330. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  64331. }
  64332. /**
  64333. * Option available in the Ascii Art Post Process.
  64334. */
  64335. export interface IAsciiArtPostProcessOptions {
  64336. /**
  64337. * The font to use following the w3c font definition.
  64338. */
  64339. font?: string;
  64340. /**
  64341. * The character set to use in the postprocess.
  64342. */
  64343. characterSet?: string;
  64344. /**
  64345. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64346. * This number is defined between 0 and 1;
  64347. */
  64348. mixToTile?: number;
  64349. /**
  64350. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64351. * This number is defined between 0 and 1;
  64352. */
  64353. mixToNormal?: number;
  64354. }
  64355. /**
  64356. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  64357. *
  64358. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64359. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  64360. */
  64361. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  64362. /**
  64363. * The font texture used to render the char in the post process.
  64364. */
  64365. private _asciiArtFontTexture;
  64366. /**
  64367. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64368. * This number is defined between 0 and 1;
  64369. */
  64370. mixToTile: number;
  64371. /**
  64372. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64373. * This number is defined between 0 and 1;
  64374. */
  64375. mixToNormal: number;
  64376. /**
  64377. * Instantiates a new Ascii Art Post Process.
  64378. * @param name the name to give to the postprocess
  64379. * @camera the camera to apply the post process to.
  64380. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  64381. */
  64382. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  64383. }
  64384. }
  64385. declare module BABYLON {
  64386. /** @hidden */
  64387. export var digitalrainPixelShader: {
  64388. name: string;
  64389. shader: string;
  64390. };
  64391. }
  64392. declare module BABYLON {
  64393. /**
  64394. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  64395. *
  64396. * It basically takes care rendering the font front the given font size to a texture.
  64397. * This is used later on in the postprocess.
  64398. */
  64399. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  64400. private _font;
  64401. private _text;
  64402. private _charSize;
  64403. /**
  64404. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64405. */
  64406. readonly charSize: number;
  64407. /**
  64408. * Create a new instance of the Digital Rain FontTexture class
  64409. * @param name the name of the texture
  64410. * @param font the font to use, use the W3C CSS notation
  64411. * @param text the caracter set to use in the rendering.
  64412. * @param scene the scene that owns the texture
  64413. */
  64414. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64415. /**
  64416. * Gets the max char width of a font.
  64417. * @param font the font to use, use the W3C CSS notation
  64418. * @return the max char width
  64419. */
  64420. private getFontWidth;
  64421. /**
  64422. * Gets the max char height of a font.
  64423. * @param font the font to use, use the W3C CSS notation
  64424. * @return the max char height
  64425. */
  64426. private getFontHeight;
  64427. /**
  64428. * Clones the current DigitalRainFontTexture.
  64429. * @return the clone of the texture.
  64430. */
  64431. clone(): DigitalRainFontTexture;
  64432. /**
  64433. * Parses a json object representing the texture and returns an instance of it.
  64434. * @param source the source JSON representation
  64435. * @param scene the scene to create the texture for
  64436. * @return the parsed texture
  64437. */
  64438. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  64439. }
  64440. /**
  64441. * Option available in the Digital Rain Post Process.
  64442. */
  64443. export interface IDigitalRainPostProcessOptions {
  64444. /**
  64445. * The font to use following the w3c font definition.
  64446. */
  64447. font?: string;
  64448. /**
  64449. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64450. * This number is defined between 0 and 1;
  64451. */
  64452. mixToTile?: number;
  64453. /**
  64454. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64455. * This number is defined between 0 and 1;
  64456. */
  64457. mixToNormal?: number;
  64458. }
  64459. /**
  64460. * DigitalRainPostProcess helps rendering everithing in digital rain.
  64461. *
  64462. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64463. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  64464. */
  64465. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  64466. /**
  64467. * The font texture used to render the char in the post process.
  64468. */
  64469. private _digitalRainFontTexture;
  64470. /**
  64471. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64472. * This number is defined between 0 and 1;
  64473. */
  64474. mixToTile: number;
  64475. /**
  64476. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64477. * This number is defined between 0 and 1;
  64478. */
  64479. mixToNormal: number;
  64480. /**
  64481. * Instantiates a new Digital Rain Post Process.
  64482. * @param name the name to give to the postprocess
  64483. * @camera the camera to apply the post process to.
  64484. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  64485. */
  64486. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  64487. }
  64488. }
  64489. declare module BABYLON {
  64490. /** @hidden */
  64491. export var oceanPostProcessPixelShader: {
  64492. name: string;
  64493. shader: string;
  64494. };
  64495. }
  64496. declare module BABYLON {
  64497. /**
  64498. * Option available in the Ocean Post Process.
  64499. */
  64500. export interface IOceanPostProcessOptions {
  64501. /**
  64502. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64503. */
  64504. reflectionSize?: number | {
  64505. width: number;
  64506. height: number;
  64507. } | {
  64508. ratio: number;
  64509. };
  64510. /**
  64511. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64512. */
  64513. refractionSize?: number | {
  64514. width: number;
  64515. height: number;
  64516. } | {
  64517. ratio: number;
  64518. };
  64519. }
  64520. /**
  64521. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  64522. *
  64523. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64524. * Example usage:
  64525. * var pp = new OceanPostProcess("myOcean", camera);
  64526. * pp.reflectionEnabled = true;
  64527. * pp.refractionEnabled = true;
  64528. */
  64529. export class OceanPostProcess extends BABYLON.PostProcess {
  64530. /**
  64531. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  64532. */
  64533. /**
  64534. * Sets weither or not the real-time reflection is enabled on the ocean.
  64535. * Is set to true, the reflection mirror texture will be used as reflection texture.
  64536. */
  64537. reflectionEnabled: boolean;
  64538. /**
  64539. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  64540. */
  64541. /**
  64542. * Sets weither or not the real-time refraction is enabled on the ocean.
  64543. * Is set to true, the refraction render target texture will be used as refraction texture.
  64544. */
  64545. refractionEnabled: boolean;
  64546. /**
  64547. * Gets wether or not the post-processes is supported by the running hardware.
  64548. * This requires draw buffer supports.
  64549. */
  64550. readonly isSupported: boolean;
  64551. /**
  64552. * This is the reflection mirror texture used to display reflections on the ocean.
  64553. * By default, render list is empty.
  64554. */
  64555. reflectionTexture: BABYLON.MirrorTexture;
  64556. /**
  64557. * This is the refraction render target texture used to display refraction on the ocean.
  64558. * By default, render list is empty.
  64559. */
  64560. refractionTexture: BABYLON.RenderTargetTexture;
  64561. private _time;
  64562. private _cameraRotation;
  64563. private _cameraViewMatrix;
  64564. private _reflectionEnabled;
  64565. private _refractionEnabled;
  64566. private _geometryRenderer;
  64567. /**
  64568. * Instantiates a new Ocean Post Process.
  64569. * @param name the name to give to the postprocess.
  64570. * @camera the camera to apply the post process to.
  64571. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  64572. */
  64573. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  64574. /**
  64575. * Returns the appropriate defines according to the current configuration.
  64576. */
  64577. private _getDefines;
  64578. /**
  64579. * Computes the current camera rotation as the shader requires a camera rotation.
  64580. */
  64581. private _computeCameraRotation;
  64582. }
  64583. }
  64584. declare module BABYLON {
  64585. /** @hidden */
  64586. export var brickProceduralTexturePixelShader: {
  64587. name: string;
  64588. shader: string;
  64589. };
  64590. }
  64591. declare module BABYLON {
  64592. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  64593. private _numberOfBricksHeight;
  64594. private _numberOfBricksWidth;
  64595. private _jointColor;
  64596. private _brickColor;
  64597. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64598. updateShaderUniforms(): void;
  64599. numberOfBricksHeight: number;
  64600. numberOfBricksWidth: number;
  64601. jointColor: BABYLON.Color3;
  64602. brickColor: BABYLON.Color3;
  64603. /**
  64604. * Serializes this brick procedural texture
  64605. * @returns a serialized brick procedural texture object
  64606. */
  64607. serialize(): any;
  64608. /**
  64609. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  64610. * @param parsedTexture defines parsed texture data
  64611. * @param scene defines the current scene
  64612. * @param rootUrl defines the root URL containing brick procedural texture information
  64613. * @returns a parsed Brick Procedural BABYLON.Texture
  64614. */
  64615. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  64616. }
  64617. }
  64618. declare module BABYLON {
  64619. /** @hidden */
  64620. export var cloudProceduralTexturePixelShader: {
  64621. name: string;
  64622. shader: string;
  64623. };
  64624. }
  64625. declare module BABYLON {
  64626. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  64627. private _skyColor;
  64628. private _cloudColor;
  64629. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64630. updateShaderUniforms(): void;
  64631. skyColor: BABYLON.Color4;
  64632. cloudColor: BABYLON.Color4;
  64633. /**
  64634. * Serializes this cloud procedural texture
  64635. * @returns a serialized cloud procedural texture object
  64636. */
  64637. serialize(): any;
  64638. /**
  64639. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  64640. * @param parsedTexture defines parsed texture data
  64641. * @param scene defines the current scene
  64642. * @param rootUrl defines the root URL containing cloud procedural texture information
  64643. * @returns a parsed Cloud Procedural BABYLON.Texture
  64644. */
  64645. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  64646. }
  64647. }
  64648. declare module BABYLON {
  64649. /** @hidden */
  64650. export var fireProceduralTexturePixelShader: {
  64651. name: string;
  64652. shader: string;
  64653. };
  64654. }
  64655. declare module BABYLON {
  64656. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  64657. private _time;
  64658. private _speed;
  64659. private _autoGenerateTime;
  64660. private _fireColors;
  64661. private _alphaThreshold;
  64662. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64663. updateShaderUniforms(): void;
  64664. render(useCameraPostProcess?: boolean): void;
  64665. static readonly PurpleFireColors: BABYLON.Color3[];
  64666. static readonly GreenFireColors: BABYLON.Color3[];
  64667. static readonly RedFireColors: BABYLON.Color3[];
  64668. static readonly BlueFireColors: BABYLON.Color3[];
  64669. autoGenerateTime: boolean;
  64670. fireColors: BABYLON.Color3[];
  64671. time: number;
  64672. speed: BABYLON.Vector2;
  64673. alphaThreshold: number;
  64674. /**
  64675. * Serializes this fire procedural texture
  64676. * @returns a serialized fire procedural texture object
  64677. */
  64678. serialize(): any;
  64679. /**
  64680. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  64681. * @param parsedTexture defines parsed texture data
  64682. * @param scene defines the current scene
  64683. * @param rootUrl defines the root URL containing fire procedural texture information
  64684. * @returns a parsed Fire Procedural BABYLON.Texture
  64685. */
  64686. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  64687. }
  64688. }
  64689. declare module BABYLON {
  64690. /** @hidden */
  64691. export var grassProceduralTexturePixelShader: {
  64692. name: string;
  64693. shader: string;
  64694. };
  64695. }
  64696. declare module BABYLON {
  64697. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  64698. private _grassColors;
  64699. private _groundColor;
  64700. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64701. updateShaderUniforms(): void;
  64702. grassColors: BABYLON.Color3[];
  64703. groundColor: BABYLON.Color3;
  64704. /**
  64705. * Serializes this grass procedural texture
  64706. * @returns a serialized grass procedural texture object
  64707. */
  64708. serialize(): any;
  64709. /**
  64710. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  64711. * @param parsedTexture defines parsed texture data
  64712. * @param scene defines the current scene
  64713. * @param rootUrl defines the root URL containing grass procedural texture information
  64714. * @returns a parsed Grass Procedural BABYLON.Texture
  64715. */
  64716. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  64717. }
  64718. }
  64719. declare module BABYLON {
  64720. /** @hidden */
  64721. export var marbleProceduralTexturePixelShader: {
  64722. name: string;
  64723. shader: string;
  64724. };
  64725. }
  64726. declare module BABYLON {
  64727. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  64728. private _numberOfTilesHeight;
  64729. private _numberOfTilesWidth;
  64730. private _amplitude;
  64731. private _jointColor;
  64732. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64733. updateShaderUniforms(): void;
  64734. numberOfTilesHeight: number;
  64735. amplitude: number;
  64736. numberOfTilesWidth: number;
  64737. jointColor: BABYLON.Color3;
  64738. /**
  64739. * Serializes this marble procedural texture
  64740. * @returns a serialized marble procedural texture object
  64741. */
  64742. serialize(): any;
  64743. /**
  64744. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  64745. * @param parsedTexture defines parsed texture data
  64746. * @param scene defines the current scene
  64747. * @param rootUrl defines the root URL containing marble procedural texture information
  64748. * @returns a parsed Marble Procedural BABYLON.Texture
  64749. */
  64750. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  64751. }
  64752. }
  64753. declare module BABYLON {
  64754. /** @hidden */
  64755. export var normalMapProceduralTexturePixelShader: {
  64756. name: string;
  64757. shader: string;
  64758. };
  64759. }
  64760. declare module BABYLON {
  64761. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  64762. private _baseTexture;
  64763. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64764. updateShaderUniforms(): void;
  64765. render(useCameraPostProcess?: boolean): void;
  64766. resize(size: any, generateMipMaps: any): void;
  64767. baseTexture: BABYLON.Texture;
  64768. /**
  64769. * Serializes this normal map procedural texture
  64770. * @returns a serialized normal map procedural texture object
  64771. */
  64772. serialize(): any;
  64773. /**
  64774. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  64775. * @param parsedTexture defines parsed texture data
  64776. * @param scene defines the current scene
  64777. * @param rootUrl defines the root URL containing normal map procedural texture information
  64778. * @returns a parsed Normal Map Procedural BABYLON.Texture
  64779. */
  64780. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  64781. }
  64782. }
  64783. declare module BABYLON {
  64784. /** @hidden */
  64785. export var perlinNoiseProceduralTexturePixelShader: {
  64786. name: string;
  64787. shader: string;
  64788. };
  64789. }
  64790. declare module BABYLON {
  64791. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  64792. time: number;
  64793. timeScale: number;
  64794. translationSpeed: number;
  64795. private _currentTranslation;
  64796. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64797. updateShaderUniforms(): void;
  64798. render(useCameraPostProcess?: boolean): void;
  64799. resize(size: any, generateMipMaps: any): void;
  64800. /**
  64801. * Serializes this perlin noise procedural texture
  64802. * @returns a serialized perlin noise procedural texture object
  64803. */
  64804. serialize(): any;
  64805. /**
  64806. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  64807. * @param parsedTexture defines parsed texture data
  64808. * @param scene defines the current scene
  64809. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  64810. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  64811. */
  64812. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  64813. }
  64814. }
  64815. declare module BABYLON {
  64816. /** @hidden */
  64817. export var roadProceduralTexturePixelShader: {
  64818. name: string;
  64819. shader: string;
  64820. };
  64821. }
  64822. declare module BABYLON {
  64823. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  64824. private _roadColor;
  64825. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64826. updateShaderUniforms(): void;
  64827. roadColor: BABYLON.Color3;
  64828. /**
  64829. * Serializes this road procedural texture
  64830. * @returns a serialized road procedural texture object
  64831. */
  64832. serialize(): any;
  64833. /**
  64834. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  64835. * @param parsedTexture defines parsed texture data
  64836. * @param scene defines the current scene
  64837. * @param rootUrl defines the root URL containing road procedural texture information
  64838. * @returns a parsed Road Procedural BABYLON.Texture
  64839. */
  64840. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  64841. }
  64842. }
  64843. declare module BABYLON {
  64844. /** @hidden */
  64845. export var starfieldProceduralTexturePixelShader: {
  64846. name: string;
  64847. shader: string;
  64848. };
  64849. }
  64850. declare module BABYLON {
  64851. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  64852. private _time;
  64853. private _alpha;
  64854. private _beta;
  64855. private _zoom;
  64856. private _formuparam;
  64857. private _stepsize;
  64858. private _tile;
  64859. private _brightness;
  64860. private _darkmatter;
  64861. private _distfading;
  64862. private _saturation;
  64863. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64864. updateShaderUniforms(): void;
  64865. time: number;
  64866. alpha: number;
  64867. beta: number;
  64868. formuparam: number;
  64869. stepsize: number;
  64870. zoom: number;
  64871. tile: number;
  64872. brightness: number;
  64873. darkmatter: number;
  64874. distfading: number;
  64875. saturation: number;
  64876. /**
  64877. * Serializes this starfield procedural texture
  64878. * @returns a serialized starfield procedural texture object
  64879. */
  64880. serialize(): any;
  64881. /**
  64882. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  64883. * @param parsedTexture defines parsed texture data
  64884. * @param scene defines the current scene
  64885. * @param rootUrl defines the root URL containing startfield procedural texture information
  64886. * @returns a parsed Starfield Procedural BABYLON.Texture
  64887. */
  64888. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  64889. }
  64890. }
  64891. declare module BABYLON {
  64892. /** @hidden */
  64893. export var woodProceduralTexturePixelShader: {
  64894. name: string;
  64895. shader: string;
  64896. };
  64897. }
  64898. declare module BABYLON {
  64899. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  64900. private _ampScale;
  64901. private _woodColor;
  64902. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64903. updateShaderUniforms(): void;
  64904. ampScale: number;
  64905. woodColor: BABYLON.Color3;
  64906. /**
  64907. * Serializes this wood procedural texture
  64908. * @returns a serialized wood procedural texture object
  64909. */
  64910. serialize(): any;
  64911. /**
  64912. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  64913. * @param parsedTexture defines parsed texture data
  64914. * @param scene defines the current scene
  64915. * @param rootUrl defines the root URL containing wood procedural texture information
  64916. * @returns a parsed Wood Procedural BABYLON.Texture
  64917. */
  64918. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  64919. }
  64920. }