babylon.d.txt 2.8 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116
  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. * This represents the required contract to create a new type of texture loader.
  8234. */
  8235. export interface IInternalTextureLoader {
  8236. /**
  8237. * Defines wether the loader supports cascade loading the different faces.
  8238. */
  8239. supportCascades: boolean;
  8240. /**
  8241. * This returns if the loader support the current file information.
  8242. * @param extension defines the file extension of the file being loaded
  8243. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8244. * @param fallback defines the fallback internal texture if any
  8245. * @param isBase64 defines whether the texture is encoded as a base64
  8246. * @param isBuffer defines whether the texture data are stored as a buffer
  8247. * @returns true if the loader can load the specified file
  8248. */
  8249. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8250. /**
  8251. * Transform the url before loading if required.
  8252. * @param rootUrl the url of the texture
  8253. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8254. * @returns the transformed texture
  8255. */
  8256. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8257. /**
  8258. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8259. * @param rootUrl the url of the texture
  8260. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8261. * @returns the fallback texture
  8262. */
  8263. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8264. /**
  8265. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8266. * @param data contains the texture data
  8267. * @param texture defines the BabylonJS internal texture
  8268. * @param createPolynomials will be true if polynomials have been requested
  8269. * @param onLoad defines the callback to trigger once the texture is ready
  8270. * @param onError defines the callback to trigger in case of error
  8271. */
  8272. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8273. /**
  8274. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8275. * @param data contains the texture data
  8276. * @param texture defines the BabylonJS internal texture
  8277. * @param callback defines the method to call once ready to upload
  8278. */
  8279. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8280. }
  8281. }
  8282. declare module BABYLON {
  8283. interface Engine {
  8284. /**
  8285. * Creates a depth stencil cube texture.
  8286. * This is only available in WebGL 2.
  8287. * @param size The size of face edge in the cube texture.
  8288. * @param options The options defining the cube texture.
  8289. * @returns The cube texture
  8290. */ createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8291. /**
  8292. * Creates a cube texture
  8293. * @param rootUrl defines the url where the files to load is located
  8294. * @param scene defines the current scene
  8295. * @param files defines the list of files to load (1 per face)
  8296. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8297. * @param onLoad defines an optional callback raised when the texture is loaded
  8298. * @param onError defines an optional callback raised if there is an issue to load the texture
  8299. * @param format defines the format of the data
  8300. * @param forcedExtension defines the extension to use to pick the right loader
  8301. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8302. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8303. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8304. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8305. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8306. * @returns the cube texture as an InternalTexture
  8307. */
  8308. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8309. /**
  8310. * Creates a cube texture
  8311. * @param rootUrl defines the url where the files to load is located
  8312. * @param scene defines the current scene
  8313. * @param files defines the list of files to load (1 per face)
  8314. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8315. * @param onLoad defines an optional callback raised when the texture is loaded
  8316. * @param onError defines an optional callback raised if there is an issue to load the texture
  8317. * @param format defines the format of the data
  8318. * @param forcedExtension defines the extension to use to pick the right loader
  8319. * @returns the cube texture as an InternalTexture
  8320. */
  8321. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  8322. /**
  8323. * Creates a cube texture
  8324. * @param rootUrl defines the url where the files to load is located
  8325. * @param scene defines the current scene
  8326. * @param files defines the list of files to load (1 per face)
  8327. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8328. * @param onLoad defines an optional callback raised when the texture is loaded
  8329. * @param onError defines an optional callback raised if there is an issue to load the texture
  8330. * @param format defines the format of the data
  8331. * @param forcedExtension defines the extension to use to pick the right loader
  8332. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8333. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8334. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8335. * @returns the cube texture as an InternalTexture
  8336. */
  8337. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8338. /** @hidden */ partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8339. /** @hidden */ cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8340. /** @hidden */ cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8341. /** @hidden */ partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8342. }
  8343. }
  8344. declare module BABYLON {
  8345. /**
  8346. * Class for creating a cube texture
  8347. */
  8348. export class CubeTexture extends BaseTexture {
  8349. private _delayedOnLoad;
  8350. /**
  8351. * The url of the texture
  8352. */
  8353. url: string;
  8354. /**
  8355. * Gets or sets the center of the bounding box associated with the cube texture.
  8356. * It must define where the camera used to render the texture was set
  8357. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8358. */
  8359. boundingBoxPosition: Vector3;
  8360. private _boundingBoxSize;
  8361. /**
  8362. * Gets or sets the size of the bounding box associated with the cube texture
  8363. * When defined, the cubemap will switch to local mode
  8364. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8365. * @example https://www.babylonjs-playground.com/#RNASML
  8366. */
  8367. /**
  8368. * Returns the bounding box size
  8369. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8370. */
  8371. boundingBoxSize: Vector3;
  8372. protected _rotationY: number;
  8373. /**
  8374. * Sets texture matrix rotation angle around Y axis in radians.
  8375. */
  8376. /**
  8377. * Gets texture matrix rotation angle around Y axis radians.
  8378. */
  8379. rotationY: number;
  8380. /**
  8381. * Are mip maps generated for this texture or not.
  8382. */
  8383. readonly noMipmap: boolean;
  8384. private _noMipmap;
  8385. private _files;
  8386. private _extensions;
  8387. private _textureMatrix;
  8388. private _format;
  8389. private _createPolynomials;
  8390. /** @hidden */ prefiltered: boolean;
  8391. /**
  8392. * Creates a cube texture from an array of image urls
  8393. * @param files defines an array of image urls
  8394. * @param scene defines the hosting scene
  8395. * @param noMipmap specifies if mip maps are not used
  8396. * @returns a cube texture
  8397. */
  8398. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8399. /**
  8400. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8401. * @param url defines the url of the prefiltered texture
  8402. * @param scene defines the scene the texture is attached to
  8403. * @param forcedExtension defines the extension of the file if different from the url
  8404. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8405. * @return the prefiltered texture
  8406. */
  8407. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8408. /**
  8409. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8410. * as prefiltered data.
  8411. * @param rootUrl defines the url of the texture or the root name of the six images
  8412. * @param scene defines the scene the texture is attached to
  8413. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8414. * @param noMipmap defines if mipmaps should be created or not
  8415. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8416. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8417. * @param onError defines a callback triggered in case of error during load
  8418. * @param format defines the internal format to use for the texture once loaded
  8419. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8420. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8421. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8422. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8423. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8424. * @return the cube texture
  8425. */
  8426. 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);
  8427. /**
  8428. * Get the current class name of the texture useful for serialization or dynamic coding.
  8429. * @returns "CubeTexture"
  8430. */
  8431. getClassName(): string;
  8432. /**
  8433. * Update the url (and optional buffer) of this texture if url was null during construction.
  8434. * @param url the url of the texture
  8435. * @param forcedExtension defines the extension to use
  8436. * @param onLoad callback called when the texture is loaded (defaults to null)
  8437. */
  8438. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8439. /**
  8440. * Delays loading of the cube texture
  8441. * @param forcedExtension defines the extension to use
  8442. */
  8443. delayLoad(forcedExtension?: string): void;
  8444. /**
  8445. * Returns the reflection texture matrix
  8446. * @returns the reflection texture matrix
  8447. */
  8448. getReflectionTextureMatrix(): Matrix;
  8449. /**
  8450. * Sets the reflection texture matrix
  8451. * @param value Reflection texture matrix
  8452. */
  8453. setReflectionTextureMatrix(value: Matrix): void;
  8454. /**
  8455. * Parses text to create a cube texture
  8456. * @param parsedTexture define the serialized text to read from
  8457. * @param scene defines the hosting scene
  8458. * @param rootUrl defines the root url of the cube texture
  8459. * @returns a cube texture
  8460. */
  8461. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8462. /**
  8463. * Makes a clone, or deep copy, of the cube texture
  8464. * @returns a new cube texture
  8465. */
  8466. clone(): CubeTexture;
  8467. }
  8468. }
  8469. declare module BABYLON {
  8470. /** @hidden */
  8471. export var postprocessVertexShader: {
  8472. name: string;
  8473. shader: string;
  8474. };
  8475. }
  8476. declare module BABYLON {
  8477. /**
  8478. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8479. * This is the base of the follow, arc rotate cameras and Free camera
  8480. * @see http://doc.babylonjs.com/features/cameras
  8481. */
  8482. export class TargetCamera extends Camera {
  8483. private static _RigCamTransformMatrix;
  8484. private static _TargetTransformMatrix;
  8485. private static _TargetFocalPoint;
  8486. /**
  8487. * Define the current direction the camera is moving to
  8488. */
  8489. cameraDirection: Vector3;
  8490. /**
  8491. * Define the current rotation the camera is rotating to
  8492. */
  8493. cameraRotation: Vector2;
  8494. /**
  8495. * When set, the up vector of the camera will be updated by the rotation of the camera
  8496. */
  8497. updateUpVectorFromRotation: boolean;
  8498. private _tmpQuaternion;
  8499. /**
  8500. * Define the current rotation of the camera
  8501. */
  8502. rotation: Vector3;
  8503. /**
  8504. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8505. */
  8506. rotationQuaternion: Quaternion;
  8507. /**
  8508. * Define the current speed of the camera
  8509. */
  8510. speed: number;
  8511. /**
  8512. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8513. * around all axis.
  8514. */
  8515. noRotationConstraint: boolean;
  8516. /**
  8517. * Define the current target of the camera as an object or a position.
  8518. */
  8519. lockedTarget: any;
  8520. /** @hidden */ currentTarget: Vector3;
  8521. /** @hidden */ initialFocalDistance: number;
  8522. /** @hidden */ viewMatrix: Matrix;
  8523. /** @hidden */ camMatrix: Matrix;
  8524. /** @hidden */ cameraTransformMatrix: Matrix;
  8525. /** @hidden */ cameraRotationMatrix: Matrix;
  8526. /** @hidden */ referencePoint: Vector3;
  8527. /** @hidden */ transformedReferencePoint: Vector3;
  8528. protected _globalCurrentTarget: Vector3;
  8529. protected _globalCurrentUpVector: Vector3;
  8530. /** @hidden */ reset: () => void;
  8531. private _defaultUp;
  8532. /**
  8533. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8534. * This is the base of the follow, arc rotate cameras and Free camera
  8535. * @see http://doc.babylonjs.com/features/cameras
  8536. * @param name Defines the name of the camera in the scene
  8537. * @param position Defines the start position of the camera in the scene
  8538. * @param scene Defines the scene the camera belongs to
  8539. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8540. */
  8541. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8542. /**
  8543. * Gets the position in front of the camera at a given distance.
  8544. * @param distance The distance from the camera we want the position to be
  8545. * @returns the position
  8546. */
  8547. getFrontPosition(distance: number): Vector3;
  8548. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  8549. private _storedPosition;
  8550. private _storedRotation;
  8551. private _storedRotationQuaternion;
  8552. /**
  8553. * Store current camera state of the camera (fov, position, rotation, etc..)
  8554. * @returns the camera
  8555. */
  8556. storeState(): Camera;
  8557. /**
  8558. * Restored camera state. You must call storeState() first
  8559. * @returns whether it was successful or not
  8560. * @hidden
  8561. */ restoreStateValues(): boolean;
  8562. /** @hidden */ initCache(): void;
  8563. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  8564. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  8565. /** @hidden */ computeLocalCameraSpeed(): number;
  8566. /**
  8567. * Defines the target the camera should look at.
  8568. * This will automatically adapt alpha beta and radius to fit within the new target.
  8569. * @param target Defines the new target as a Vector or a mesh
  8570. */
  8571. setTarget(target: Vector3): void;
  8572. /**
  8573. * Return the current target position of the camera. This value is expressed in local space.
  8574. * @returns the target position
  8575. */
  8576. getTarget(): Vector3;
  8577. /** @hidden */ decideIfNeedsToMove(): boolean;
  8578. /** @hidden */ updatePosition(): void;
  8579. /** @hidden */ checkInputs(): void;
  8580. protected _updateCameraRotationMatrix(): void;
  8581. /**
  8582. * 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)
  8583. * @returns the current camera
  8584. */
  8585. private _rotateUpVectorWithCameraRotationMatrix;
  8586. private _cachedRotationZ;
  8587. private _cachedQuaternionRotationZ;
  8588. /** @hidden */ getViewMatrix(): Matrix;
  8589. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8590. /**
  8591. * @hidden
  8592. */
  8593. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8594. /**
  8595. * @hidden
  8596. */ updateRigCameras(): void;
  8597. private _getRigCamPositionAndTarget;
  8598. /**
  8599. * Gets the current object class name.
  8600. * @return the class name
  8601. */
  8602. getClassName(): string;
  8603. }
  8604. }
  8605. declare module BABYLON {
  8606. /**
  8607. * @ignore
  8608. * This is a list of all the different input types that are available in the application.
  8609. * Fo instance: ArcRotateCameraGamepadInput...
  8610. */
  8611. export var CameraInputTypes: {};
  8612. /**
  8613. * This is the contract to implement in order to create a new input class.
  8614. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8615. */
  8616. export interface ICameraInput<TCamera extends Camera> {
  8617. /**
  8618. * Defines the camera the input is attached to.
  8619. */
  8620. camera: Nullable<TCamera>;
  8621. /**
  8622. * Gets the class name of the current intput.
  8623. * @returns the class name
  8624. */
  8625. getClassName(): string;
  8626. /**
  8627. * Get the friendly name associated with the input class.
  8628. * @returns the input friendly name
  8629. */
  8630. getSimpleName(): string;
  8631. /**
  8632. * Attach the input controls to a specific dom element to get the input from.
  8633. * @param element Defines the element the controls should be listened from
  8634. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8635. */
  8636. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8637. /**
  8638. * Detach the current controls from the specified dom element.
  8639. * @param element Defines the element to stop listening the inputs from
  8640. */
  8641. detachControl(element: Nullable<HTMLElement>): void;
  8642. /**
  8643. * Update the current camera state depending on the inputs that have been used this frame.
  8644. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8645. */
  8646. checkInputs?: () => void;
  8647. }
  8648. /**
  8649. * Represents a map of input types to input instance or input index to input instance.
  8650. */
  8651. export interface CameraInputsMap<TCamera extends Camera> {
  8652. /**
  8653. * Accessor to the input by input type.
  8654. */
  8655. [name: string]: ICameraInput<TCamera>;
  8656. /**
  8657. * Accessor to the input by input index.
  8658. */
  8659. [idx: number]: ICameraInput<TCamera>;
  8660. }
  8661. /**
  8662. * This represents the input manager used within a camera.
  8663. * It helps dealing with all the different kind of input attached to a camera.
  8664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8665. */
  8666. export class CameraInputsManager<TCamera extends Camera> {
  8667. /**
  8668. * Defines the list of inputs attahed to the camera.
  8669. */
  8670. attached: CameraInputsMap<TCamera>;
  8671. /**
  8672. * Defines the dom element the camera is collecting inputs from.
  8673. * This is null if the controls have not been attached.
  8674. */
  8675. attachedElement: Nullable<HTMLElement>;
  8676. /**
  8677. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8678. */
  8679. noPreventDefault: boolean;
  8680. /**
  8681. * Defined the camera the input manager belongs to.
  8682. */
  8683. camera: TCamera;
  8684. /**
  8685. * Update the current camera state depending on the inputs that have been used this frame.
  8686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8687. */
  8688. checkInputs: () => void;
  8689. /**
  8690. * Instantiate a new Camera Input Manager.
  8691. * @param camera Defines the camera the input manager blongs to
  8692. */
  8693. constructor(camera: TCamera);
  8694. /**
  8695. * Add an input method to a camera
  8696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8697. * @param input camera input method
  8698. */
  8699. add(input: ICameraInput<TCamera>): void;
  8700. /**
  8701. * Remove a specific input method from a camera
  8702. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8703. * @param inputToRemove camera input method
  8704. */
  8705. remove(inputToRemove: ICameraInput<TCamera>): void;
  8706. /**
  8707. * Remove a specific input type from a camera
  8708. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8709. * @param inputType the type of the input to remove
  8710. */
  8711. removeByType(inputType: string): void;
  8712. private _addCheckInputs;
  8713. /**
  8714. * Attach the input controls to the currently attached dom element to listen the events from.
  8715. * @param input Defines the input to attach
  8716. */
  8717. attachInput(input: ICameraInput<TCamera>): void;
  8718. /**
  8719. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8720. * @param element Defines the dom element to collect the events from
  8721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8722. */
  8723. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8724. /**
  8725. * Detach the current manager inputs controls from a specific dom element.
  8726. * @param element Defines the dom element to collect the events from
  8727. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8728. */
  8729. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8730. /**
  8731. * Rebuild the dynamic inputCheck function from the current list of
  8732. * defined inputs in the manager.
  8733. */
  8734. rebuildInputCheck(): void;
  8735. /**
  8736. * Remove all attached input methods from a camera
  8737. */
  8738. clear(): void;
  8739. /**
  8740. * Serialize the current input manager attached to a camera.
  8741. * This ensures than once parsed,
  8742. * the input associated to the camera will be identical to the current ones
  8743. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8744. */
  8745. serialize(serializedCamera: any): void;
  8746. /**
  8747. * Parses an input manager serialized JSON to restore the previous list of inputs
  8748. * and states associated to a camera.
  8749. * @param parsedCamera Defines the JSON to parse
  8750. */
  8751. parse(parsedCamera: any): void;
  8752. }
  8753. }
  8754. declare module BABYLON {
  8755. /**
  8756. * Gather the list of keyboard event types as constants.
  8757. */
  8758. export class KeyboardEventTypes {
  8759. /**
  8760. * The keydown event is fired when a key becomes active (pressed).
  8761. */
  8762. static readonly KEYDOWN: number;
  8763. /**
  8764. * The keyup event is fired when a key has been released.
  8765. */
  8766. static readonly KEYUP: number;
  8767. }
  8768. /**
  8769. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8770. */
  8771. export class KeyboardInfo {
  8772. /**
  8773. * Defines the type of event (KeyboardEventTypes)
  8774. */
  8775. type: number;
  8776. /**
  8777. * Defines the related dom event
  8778. */
  8779. event: KeyboardEvent;
  8780. /**
  8781. * Instantiates a new keyboard info.
  8782. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8783. * @param type Defines the type of event (KeyboardEventTypes)
  8784. * @param event Defines the related dom event
  8785. */
  8786. constructor(
  8787. /**
  8788. * Defines the type of event (KeyboardEventTypes)
  8789. */
  8790. type: number,
  8791. /**
  8792. * Defines the related dom event
  8793. */
  8794. event: KeyboardEvent);
  8795. }
  8796. /**
  8797. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8798. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8799. */
  8800. export class KeyboardInfoPre extends KeyboardInfo {
  8801. /**
  8802. * Defines the type of event (KeyboardEventTypes)
  8803. */
  8804. type: number;
  8805. /**
  8806. * Defines the related dom event
  8807. */
  8808. event: KeyboardEvent;
  8809. /**
  8810. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8811. */
  8812. skipOnPointerObservable: boolean;
  8813. /**
  8814. * Instantiates a new keyboard pre info.
  8815. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8816. * @param type Defines the type of event (KeyboardEventTypes)
  8817. * @param event Defines the related dom event
  8818. */
  8819. constructor(
  8820. /**
  8821. * Defines the type of event (KeyboardEventTypes)
  8822. */
  8823. type: number,
  8824. /**
  8825. * Defines the related dom event
  8826. */
  8827. event: KeyboardEvent);
  8828. }
  8829. }
  8830. declare module BABYLON {
  8831. /**
  8832. * Manage the keyboard inputs to control the movement of a free camera.
  8833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8834. */
  8835. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8836. /**
  8837. * Defines the camera the input is attached to.
  8838. */
  8839. camera: FreeCamera;
  8840. /**
  8841. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8842. */
  8843. keysUp: number[];
  8844. /**
  8845. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8846. */
  8847. keysDown: number[];
  8848. /**
  8849. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8850. */
  8851. keysLeft: number[];
  8852. /**
  8853. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8854. */
  8855. keysRight: number[];
  8856. private _keys;
  8857. private _onCanvasBlurObserver;
  8858. private _onKeyboardObserver;
  8859. private _engine;
  8860. private _scene;
  8861. /**
  8862. * Attach the input controls to a specific dom element to get the input from.
  8863. * @param element Defines the element the controls should be listened from
  8864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8865. */
  8866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8867. /**
  8868. * Detach the current controls from the specified dom element.
  8869. * @param element Defines the element to stop listening the inputs from
  8870. */
  8871. detachControl(element: Nullable<HTMLElement>): void;
  8872. /**
  8873. * Update the current camera state depending on the inputs that have been used this frame.
  8874. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8875. */
  8876. checkInputs(): void;
  8877. /**
  8878. * Gets the class name of the current intput.
  8879. * @returns the class name
  8880. */
  8881. getClassName(): string;
  8882. /** @hidden */ onLostFocus(): void;
  8883. /**
  8884. * Get the friendly name associated with the input class.
  8885. * @returns the input friendly name
  8886. */
  8887. getSimpleName(): string;
  8888. }
  8889. }
  8890. declare module BABYLON {
  8891. /**
  8892. * Interface describing all the common properties and methods a shadow light needs to implement.
  8893. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8894. * as well as binding the different shadow properties to the effects.
  8895. */
  8896. export interface IShadowLight extends Light {
  8897. /**
  8898. * The light id in the scene (used in scene.findLighById for instance)
  8899. */
  8900. id: string;
  8901. /**
  8902. * The position the shdow will be casted from.
  8903. */
  8904. position: Vector3;
  8905. /**
  8906. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8907. */
  8908. direction: Vector3;
  8909. /**
  8910. * The transformed position. Position of the light in world space taking parenting in account.
  8911. */
  8912. transformedPosition: Vector3;
  8913. /**
  8914. * The transformed direction. Direction of the light in world space taking parenting in account.
  8915. */
  8916. transformedDirection: Vector3;
  8917. /**
  8918. * The friendly name of the light in the scene.
  8919. */
  8920. name: string;
  8921. /**
  8922. * Defines the shadow projection clipping minimum z value.
  8923. */
  8924. shadowMinZ: number;
  8925. /**
  8926. * Defines the shadow projection clipping maximum z value.
  8927. */
  8928. shadowMaxZ: number;
  8929. /**
  8930. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8931. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8932. */
  8933. computeTransformedInformation(): boolean;
  8934. /**
  8935. * Gets the scene the light belongs to.
  8936. * @returns The scene
  8937. */
  8938. getScene(): Scene;
  8939. /**
  8940. * Callback defining a custom Projection Matrix Builder.
  8941. * This can be used to override the default projection matrix computation.
  8942. */
  8943. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8944. /**
  8945. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8946. * @param matrix The materix to updated with the projection information
  8947. * @param viewMatrix The transform matrix of the light
  8948. * @param renderList The list of mesh to render in the map
  8949. * @returns The current light
  8950. */
  8951. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8952. /**
  8953. * Gets the current depth scale used in ESM.
  8954. * @returns The scale
  8955. */
  8956. getDepthScale(): number;
  8957. /**
  8958. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8959. * @returns true if a cube texture needs to be use
  8960. */
  8961. needCube(): boolean;
  8962. /**
  8963. * Detects if the projection matrix requires to be recomputed this frame.
  8964. * @returns true if it requires to be recomputed otherwise, false.
  8965. */
  8966. needProjectionMatrixCompute(): boolean;
  8967. /**
  8968. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8969. */
  8970. forceProjectionMatrixCompute(): void;
  8971. /**
  8972. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8973. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8974. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8975. */
  8976. getShadowDirection(faceIndex?: number): Vector3;
  8977. /**
  8978. * Gets the minZ used for shadow according to both the scene and the light.
  8979. * @param activeCamera The camera we are returning the min for
  8980. * @returns the depth min z
  8981. */
  8982. getDepthMinZ(activeCamera: Camera): number;
  8983. /**
  8984. * Gets the maxZ used for shadow according to both the scene and the light.
  8985. * @param activeCamera The camera we are returning the max for
  8986. * @returns the depth max z
  8987. */
  8988. getDepthMaxZ(activeCamera: Camera): number;
  8989. }
  8990. /**
  8991. * Base implementation IShadowLight
  8992. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8993. */
  8994. export abstract class ShadowLight extends Light implements IShadowLight {
  8995. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8996. protected _position: Vector3;
  8997. protected _setPosition(value: Vector3): void;
  8998. /**
  8999. * Sets the position the shadow will be casted from. Also use as the light position for both
  9000. * point and spot lights.
  9001. */
  9002. /**
  9003. * Sets the position the shadow will be casted from. Also use as the light position for both
  9004. * point and spot lights.
  9005. */
  9006. position: Vector3;
  9007. protected _direction: Vector3;
  9008. protected _setDirection(value: Vector3): void;
  9009. /**
  9010. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9011. * Also use as the light direction on spot and directional lights.
  9012. */
  9013. /**
  9014. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9015. * Also use as the light direction on spot and directional lights.
  9016. */
  9017. direction: Vector3;
  9018. private _shadowMinZ;
  9019. /**
  9020. * Gets the shadow projection clipping minimum z value.
  9021. */
  9022. /**
  9023. * Sets the shadow projection clipping minimum z value.
  9024. */
  9025. shadowMinZ: number;
  9026. private _shadowMaxZ;
  9027. /**
  9028. * Sets the shadow projection clipping maximum z value.
  9029. */
  9030. /**
  9031. * Gets the shadow projection clipping maximum z value.
  9032. */
  9033. shadowMaxZ: number;
  9034. /**
  9035. * Callback defining a custom Projection Matrix Builder.
  9036. * This can be used to override the default projection matrix computation.
  9037. */
  9038. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9039. /**
  9040. * The transformed position. Position of the light in world space taking parenting in account.
  9041. */
  9042. transformedPosition: Vector3;
  9043. /**
  9044. * The transformed direction. Direction of the light in world space taking parenting in account.
  9045. */
  9046. transformedDirection: Vector3;
  9047. private _needProjectionMatrixCompute;
  9048. /**
  9049. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9050. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9051. */
  9052. computeTransformedInformation(): boolean;
  9053. /**
  9054. * Return the depth scale used for the shadow map.
  9055. * @returns the depth scale.
  9056. */
  9057. getDepthScale(): number;
  9058. /**
  9059. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9060. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9061. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9062. */
  9063. getShadowDirection(faceIndex?: number): Vector3;
  9064. /**
  9065. * Returns the ShadowLight absolute position in the World.
  9066. * @returns the position vector in world space
  9067. */
  9068. getAbsolutePosition(): Vector3;
  9069. /**
  9070. * Sets the ShadowLight direction toward the passed target.
  9071. * @param target The point to target in local space
  9072. * @returns the updated ShadowLight direction
  9073. */
  9074. setDirectionToTarget(target: Vector3): Vector3;
  9075. /**
  9076. * Returns the light rotation in euler definition.
  9077. * @returns the x y z rotation in local space.
  9078. */
  9079. getRotation(): Vector3;
  9080. /**
  9081. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9082. * @returns true if a cube texture needs to be use
  9083. */
  9084. needCube(): boolean;
  9085. /**
  9086. * Detects if the projection matrix requires to be recomputed this frame.
  9087. * @returns true if it requires to be recomputed otherwise, false.
  9088. */
  9089. needProjectionMatrixCompute(): boolean;
  9090. /**
  9091. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9092. */
  9093. forceProjectionMatrixCompute(): void;
  9094. /** @hidden */ initCache(): void;
  9095. /** @hidden */ isSynchronized(): boolean;
  9096. /**
  9097. * Computes the world matrix of the node
  9098. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9099. * @returns the world matrix
  9100. */
  9101. computeWorldMatrix(force?: boolean): Matrix;
  9102. /**
  9103. * Gets the minZ used for shadow according to both the scene and the light.
  9104. * @param activeCamera The camera we are returning the min for
  9105. * @returns the depth min z
  9106. */
  9107. getDepthMinZ(activeCamera: Camera): number;
  9108. /**
  9109. * Gets the maxZ used for shadow according to both the scene and the light.
  9110. * @param activeCamera The camera we are returning the max for
  9111. * @returns the depth max z
  9112. */
  9113. getDepthMaxZ(activeCamera: Camera): number;
  9114. /**
  9115. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9116. * @param matrix The materix to updated with the projection information
  9117. * @param viewMatrix The transform matrix of the light
  9118. * @param renderList The list of mesh to render in the map
  9119. * @returns The current light
  9120. */
  9121. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9122. }
  9123. }
  9124. declare module BABYLON {
  9125. /**
  9126. * "Static Class" containing the most commonly used helper while dealing with material for
  9127. * rendering purpose.
  9128. *
  9129. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9130. *
  9131. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9132. */
  9133. export class MaterialHelper {
  9134. /**
  9135. * Bind the current view position to an effect.
  9136. * @param effect The effect to be bound
  9137. * @param scene The scene the eyes position is used from
  9138. */
  9139. static BindEyePosition(effect: Effect, scene: Scene): void;
  9140. /**
  9141. * Helps preparing the defines values about the UVs in used in the effect.
  9142. * UVs are shared as much as we can accross channels in the shaders.
  9143. * @param texture The texture we are preparing the UVs for
  9144. * @param defines The defines to update
  9145. * @param key The channel key "diffuse", "specular"... used in the shader
  9146. */
  9147. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9148. /**
  9149. * Binds a texture matrix value to its corrsponding uniform
  9150. * @param texture The texture to bind the matrix for
  9151. * @param uniformBuffer The uniform buffer receivin the data
  9152. * @param key The channel key "diffuse", "specular"... used in the shader
  9153. */
  9154. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9155. /**
  9156. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9157. * @param mesh defines the current mesh
  9158. * @param scene defines the current scene
  9159. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9160. * @param pointsCloud defines if point cloud rendering has to be turned on
  9161. * @param fogEnabled defines if fog has to be turned on
  9162. * @param alphaTest defines if alpha testing has to be turned on
  9163. * @param defines defines the current list of defines
  9164. */
  9165. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9166. /**
  9167. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9168. * @param scene defines the current scene
  9169. * @param engine defines the current engine
  9170. * @param defines specifies the list of active defines
  9171. * @param useInstances defines if instances have to be turned on
  9172. * @param useClipPlane defines if clip plane have to be turned on
  9173. */
  9174. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9175. /**
  9176. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9177. * @param mesh The mesh containing the geometry data we will draw
  9178. * @param defines The defines to update
  9179. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9180. * @param useBones Precise whether bones should be used or not (override mesh info)
  9181. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9182. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9183. * @returns false if defines are considered not dirty and have not been checked
  9184. */
  9185. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9186. /**
  9187. * Prepares the defines related to multiview
  9188. * @param scene The scene we are intending to draw
  9189. * @param defines The defines to update
  9190. */
  9191. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9192. /**
  9193. * Prepares the defines related to the light information passed in parameter
  9194. * @param scene The scene we are intending to draw
  9195. * @param mesh The mesh the effect is compiling for
  9196. * @param defines The defines to update
  9197. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9198. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9199. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9200. * @returns true if normals will be required for the rest of the effect
  9201. */
  9202. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9203. /**
  9204. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9205. * that won t be acctive due to defines being turned off.
  9206. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9207. * @param samplersList The samplers list
  9208. * @param defines The defines helping in the list generation
  9209. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9210. */
  9211. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9212. /**
  9213. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9214. * @param defines The defines to update while falling back
  9215. * @param fallbacks The authorized effect fallbacks
  9216. * @param maxSimultaneousLights The maximum number of lights allowed
  9217. * @param rank the current rank of the Effect
  9218. * @returns The newly affected rank
  9219. */
  9220. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9221. /**
  9222. * Prepares the list of attributes required for morph targets according to the effect defines.
  9223. * @param attribs The current list of supported attribs
  9224. * @param mesh The mesh to prepare the morph targets attributes for
  9225. * @param defines The current Defines of the effect
  9226. */
  9227. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9228. /**
  9229. * Prepares the list of attributes required for bones according to the effect defines.
  9230. * @param attribs The current list of supported attribs
  9231. * @param mesh The mesh to prepare the bones attributes for
  9232. * @param defines The current Defines of the effect
  9233. * @param fallbacks The current efffect fallback strategy
  9234. */
  9235. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9236. /**
  9237. * Prepares the list of attributes required for instances according to the effect defines.
  9238. * @param attribs The current list of supported attribs
  9239. * @param defines The current Defines of the effect
  9240. */
  9241. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9242. /**
  9243. * Binds the light shadow information to the effect for the given mesh.
  9244. * @param light The light containing the generator
  9245. * @param scene The scene the lights belongs to
  9246. * @param mesh The mesh we are binding the information to render
  9247. * @param lightIndex The light index in the effect used to render the mesh
  9248. * @param effect The effect we are binding the data to
  9249. */
  9250. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9251. /**
  9252. * Binds the light information to the effect.
  9253. * @param light The light containing the generator
  9254. * @param effect The effect we are binding the data to
  9255. * @param lightIndex The light index in the effect used to render
  9256. */
  9257. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9258. /**
  9259. * Binds the lights information from the scene to the effect for the given mesh.
  9260. * @param scene The scene the lights belongs to
  9261. * @param mesh The mesh we are binding the information to render
  9262. * @param effect The effect we are binding the data to
  9263. * @param defines The generated defines for the effect
  9264. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9265. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9266. */
  9267. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9268. private static _tempFogColor;
  9269. /**
  9270. * Binds the fog information from the scene to the effect for the given mesh.
  9271. * @param scene The scene the lights belongs to
  9272. * @param mesh The mesh we are binding the information to render
  9273. * @param effect The effect we are binding the data to
  9274. * @param linearSpace Defines if the fog effect is applied in linear space
  9275. */
  9276. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9277. /**
  9278. * Binds the bones information from the mesh to the effect.
  9279. * @param mesh The mesh we are binding the information to render
  9280. * @param effect The effect we are binding the data to
  9281. */
  9282. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9283. /**
  9284. * Binds the morph targets information from the mesh to the effect.
  9285. * @param abstractMesh The mesh we are binding the information to render
  9286. * @param effect The effect we are binding the data to
  9287. */
  9288. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9289. /**
  9290. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9291. * @param defines The generated defines used in the effect
  9292. * @param effect The effect we are binding the data to
  9293. * @param scene The scene we are willing to render with logarithmic scale for
  9294. */
  9295. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9296. /**
  9297. * Binds the clip plane information from the scene to the effect.
  9298. * @param scene The scene the clip plane information are extracted from
  9299. * @param effect The effect we are binding the data to
  9300. */
  9301. static BindClipPlane(effect: Effect, scene: Scene): void;
  9302. }
  9303. }
  9304. declare module BABYLON {
  9305. /** @hidden */
  9306. export var kernelBlurVaryingDeclaration: {
  9307. name: string;
  9308. shader: string;
  9309. };
  9310. }
  9311. declare module BABYLON {
  9312. /** @hidden */
  9313. export var kernelBlurFragment: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module BABYLON {
  9319. /** @hidden */
  9320. export var kernelBlurFragment2: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module BABYLON {
  9326. /** @hidden */
  9327. export var kernelBlurPixelShader: {
  9328. name: string;
  9329. shader: string;
  9330. };
  9331. }
  9332. declare module BABYLON {
  9333. /** @hidden */
  9334. export var kernelBlurVertex: {
  9335. name: string;
  9336. shader: string;
  9337. };
  9338. }
  9339. declare module BABYLON {
  9340. /** @hidden */
  9341. export var kernelBlurVertexShader: {
  9342. name: string;
  9343. shader: string;
  9344. };
  9345. }
  9346. declare module BABYLON {
  9347. /**
  9348. * The Blur Post Process which blurs an image based on a kernel and direction.
  9349. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9350. */
  9351. export class BlurPostProcess extends PostProcess {
  9352. /** The direction in which to blur the image. */
  9353. direction: Vector2;
  9354. private blockCompilation;
  9355. protected _kernel: number;
  9356. protected _idealKernel: number;
  9357. protected _packedFloat: boolean;
  9358. private _staticDefines;
  9359. /**
  9360. * Sets the length in pixels of the blur sample region
  9361. */
  9362. /**
  9363. * Gets the length in pixels of the blur sample region
  9364. */
  9365. kernel: number;
  9366. /**
  9367. * Sets wether or not the blur needs to unpack/repack floats
  9368. */
  9369. /**
  9370. * Gets wether or not the blur is unpacking/repacking floats
  9371. */
  9372. packedFloat: boolean;
  9373. /**
  9374. * Creates a new instance BlurPostProcess
  9375. * @param name The name of the effect.
  9376. * @param direction The direction in which to blur the image.
  9377. * @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.
  9378. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9379. * @param camera The camera to apply the render pass to.
  9380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9381. * @param engine The engine which the post process will be applied. (default: current engine)
  9382. * @param reusable If the post process can be reused on the same frame. (default: false)
  9383. * @param textureType Type of textures used when performing the post process. (default: 0)
  9384. * @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)
  9385. */
  9386. constructor(name: string,
  9387. /** The direction in which to blur the image. */
  9388. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9389. /**
  9390. * Updates the effect with the current post process compile time values and recompiles the shader.
  9391. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9392. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9393. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9394. * @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
  9395. * @param onCompiled Called when the shader has been compiled.
  9396. * @param onError Called if there is an error when compiling a shader.
  9397. */
  9398. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9399. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9400. /**
  9401. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9402. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9403. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9404. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9405. * The gaps between physical kernels are compensated for in the weighting of the samples
  9406. * @param idealKernel Ideal blur kernel.
  9407. * @return Nearest best kernel.
  9408. */
  9409. protected _nearestBestKernel(idealKernel: number): number;
  9410. /**
  9411. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9412. * @param x The point on the Gaussian distribution to sample.
  9413. * @return the value of the Gaussian function at x.
  9414. */
  9415. protected _gaussianWeight(x: number): number;
  9416. /**
  9417. * Generates a string that can be used as a floating point number in GLSL.
  9418. * @param x Value to print.
  9419. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9420. * @return GLSL float string.
  9421. */
  9422. protected _glslFloat(x: number, decimalFigures?: number): string;
  9423. }
  9424. }
  9425. declare module BABYLON {
  9426. /** @hidden */
  9427. export var shadowMapPixelShader: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module BABYLON {
  9433. /** @hidden */
  9434. export var bonesDeclaration: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module BABYLON {
  9440. /** @hidden */
  9441. export var morphTargetsVertexGlobalDeclaration: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module BABYLON {
  9447. /** @hidden */
  9448. export var morphTargetsVertexDeclaration: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module BABYLON {
  9454. /** @hidden */
  9455. export var instancesDeclaration: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module BABYLON {
  9461. /** @hidden */
  9462. export var helperFunctions: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module BABYLON {
  9468. /** @hidden */
  9469. export var morphTargetsVertex: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module BABYLON {
  9475. /** @hidden */
  9476. export var instancesVertex: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module BABYLON {
  9482. /** @hidden */
  9483. export var bonesVertex: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module BABYLON {
  9489. /** @hidden */
  9490. export var shadowMapVertexShader: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module BABYLON {
  9496. /** @hidden */
  9497. export var depthBoxBlurPixelShader: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module BABYLON {
  9503. /**
  9504. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9505. */
  9506. export interface ICustomShaderOptions {
  9507. /**
  9508. * Gets or sets the custom shader name to use
  9509. */
  9510. shaderName: string;
  9511. /**
  9512. * The list of attribute names used in the shader
  9513. */
  9514. attributes?: string[];
  9515. /**
  9516. * The list of unifrom names used in the shader
  9517. */
  9518. uniforms?: string[];
  9519. /**
  9520. * The list of sampler names used in the shader
  9521. */
  9522. samplers?: string[];
  9523. /**
  9524. * The list of defines used in the shader
  9525. */
  9526. defines?: string[];
  9527. }
  9528. /**
  9529. * Interface to implement to create a shadow generator compatible with BJS.
  9530. */
  9531. export interface IShadowGenerator {
  9532. /**
  9533. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9534. * @returns The render target texture if present otherwise, null
  9535. */
  9536. getShadowMap(): Nullable<RenderTargetTexture>;
  9537. /**
  9538. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9539. * @returns The render target texture if the shadow map is present otherwise, null
  9540. */
  9541. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9542. /**
  9543. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9544. * @param subMesh The submesh we want to render in the shadow map
  9545. * @param useInstances Defines wether will draw in the map using instances
  9546. * @returns true if ready otherwise, false
  9547. */
  9548. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9549. /**
  9550. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9551. * @param defines Defines of the material we want to update
  9552. * @param lightIndex Index of the light in the enabled light list of the material
  9553. */
  9554. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9555. /**
  9556. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9557. * defined in the generator but impacting the effect).
  9558. * It implies the unifroms available on the materials are the standard BJS ones.
  9559. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9560. * @param effect The effect we are binfing the information for
  9561. */
  9562. bindShadowLight(lightIndex: string, effect: Effect): void;
  9563. /**
  9564. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9565. * (eq to shadow prjection matrix * light transform matrix)
  9566. * @returns The transform matrix used to create the shadow map
  9567. */
  9568. getTransformMatrix(): Matrix;
  9569. /**
  9570. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9571. * Cube and 2D textures for instance.
  9572. */
  9573. recreateShadowMap(): void;
  9574. /**
  9575. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9576. * @param onCompiled Callback triggered at the and of the effects compilation
  9577. * @param options Sets of optional options forcing the compilation with different modes
  9578. */
  9579. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9580. useInstances: boolean;
  9581. }>): void;
  9582. /**
  9583. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9584. * @param options Sets of optional options forcing the compilation with different modes
  9585. * @returns A promise that resolves when the compilation completes
  9586. */
  9587. forceCompilationAsync(options?: Partial<{
  9588. useInstances: boolean;
  9589. }>): Promise<void>;
  9590. /**
  9591. * Serializes the shadow generator setup to a json object.
  9592. * @returns The serialized JSON object
  9593. */
  9594. serialize(): any;
  9595. /**
  9596. * Disposes the Shadow map and related Textures and effects.
  9597. */
  9598. dispose(): void;
  9599. }
  9600. /**
  9601. * Default implementation IShadowGenerator.
  9602. * This is the main object responsible of generating shadows in the framework.
  9603. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9604. */
  9605. export class ShadowGenerator implements IShadowGenerator {
  9606. /**
  9607. * Shadow generator mode None: no filtering applied.
  9608. */
  9609. static readonly FILTER_NONE: number;
  9610. /**
  9611. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9612. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9613. */
  9614. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9615. /**
  9616. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9617. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9618. */
  9619. static readonly FILTER_POISSONSAMPLING: number;
  9620. /**
  9621. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9622. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9623. */
  9624. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9625. /**
  9626. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9627. * edge artifacts on steep falloff.
  9628. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9629. */
  9630. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9631. /**
  9632. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9633. * edge artifacts on steep falloff.
  9634. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9635. */
  9636. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9637. /**
  9638. * Shadow generator mode PCF: Percentage Closer Filtering
  9639. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9640. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9641. */
  9642. static readonly FILTER_PCF: number;
  9643. /**
  9644. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9645. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9646. * Contact Hardening
  9647. */
  9648. static readonly FILTER_PCSS: number;
  9649. /**
  9650. * Reserved for PCF and PCSS
  9651. * Highest Quality.
  9652. *
  9653. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9654. *
  9655. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9656. */
  9657. static readonly QUALITY_HIGH: number;
  9658. /**
  9659. * Reserved for PCF and PCSS
  9660. * Good tradeoff for quality/perf cross devices
  9661. *
  9662. * Execute PCF on a 3*3 kernel.
  9663. *
  9664. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9665. */
  9666. static readonly QUALITY_MEDIUM: number;
  9667. /**
  9668. * Reserved for PCF and PCSS
  9669. * The lowest quality but the fastest.
  9670. *
  9671. * Execute PCF on a 1*1 kernel.
  9672. *
  9673. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9674. */
  9675. static readonly QUALITY_LOW: number;
  9676. /** Gets or sets the custom shader name to use */
  9677. customShaderOptions: ICustomShaderOptions;
  9678. /**
  9679. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9680. */
  9681. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9682. /**
  9683. * Observable triggered before a mesh is rendered in the shadow map.
  9684. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9685. */
  9686. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9687. private _bias;
  9688. /**
  9689. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9690. */
  9691. /**
  9692. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9693. */
  9694. bias: number;
  9695. private _normalBias;
  9696. /**
  9697. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9698. */
  9699. /**
  9700. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9701. */
  9702. normalBias: number;
  9703. private _blurBoxOffset;
  9704. /**
  9705. * Gets the blur box offset: offset applied during the blur pass.
  9706. * Only useful if useKernelBlur = false
  9707. */
  9708. /**
  9709. * Sets the blur box offset: offset applied during the blur pass.
  9710. * Only useful if useKernelBlur = false
  9711. */
  9712. blurBoxOffset: number;
  9713. private _blurScale;
  9714. /**
  9715. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9716. * 2 means half of the size.
  9717. */
  9718. /**
  9719. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9720. * 2 means half of the size.
  9721. */
  9722. blurScale: number;
  9723. private _blurKernel;
  9724. /**
  9725. * Gets the blur kernel: kernel size of the blur pass.
  9726. * Only useful if useKernelBlur = true
  9727. */
  9728. /**
  9729. * Sets the blur kernel: kernel size of the blur pass.
  9730. * Only useful if useKernelBlur = true
  9731. */
  9732. blurKernel: number;
  9733. private _useKernelBlur;
  9734. /**
  9735. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9736. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9737. */
  9738. /**
  9739. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9740. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9741. */
  9742. useKernelBlur: boolean;
  9743. private _depthScale;
  9744. /**
  9745. * Gets the depth scale used in ESM mode.
  9746. */
  9747. /**
  9748. * Sets the depth scale used in ESM mode.
  9749. * This can override the scale stored on the light.
  9750. */
  9751. depthScale: number;
  9752. private _filter;
  9753. /**
  9754. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9755. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9756. */
  9757. /**
  9758. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9759. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9760. */
  9761. filter: number;
  9762. /**
  9763. * Gets if the current filter is set to Poisson Sampling.
  9764. */
  9765. /**
  9766. * Sets the current filter to Poisson Sampling.
  9767. */
  9768. usePoissonSampling: boolean;
  9769. /**
  9770. * Gets if the current filter is set to ESM.
  9771. */
  9772. /**
  9773. * Sets the current filter is to ESM.
  9774. */
  9775. useExponentialShadowMap: boolean;
  9776. /**
  9777. * Gets if the current filter is set to filtered ESM.
  9778. */
  9779. /**
  9780. * Gets if the current filter is set to filtered ESM.
  9781. */
  9782. useBlurExponentialShadowMap: boolean;
  9783. /**
  9784. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9785. * exponential to prevent steep falloff artifacts).
  9786. */
  9787. /**
  9788. * Sets the current filter to "close ESM" (using the inverse of the
  9789. * exponential to prevent steep falloff artifacts).
  9790. */
  9791. useCloseExponentialShadowMap: boolean;
  9792. /**
  9793. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9794. * exponential to prevent steep falloff artifacts).
  9795. */
  9796. /**
  9797. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9798. * exponential to prevent steep falloff artifacts).
  9799. */
  9800. useBlurCloseExponentialShadowMap: boolean;
  9801. /**
  9802. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9803. */
  9804. /**
  9805. * Sets the current filter to "PCF" (percentage closer filtering).
  9806. */
  9807. usePercentageCloserFiltering: boolean;
  9808. private _filteringQuality;
  9809. /**
  9810. * Gets the PCF or PCSS Quality.
  9811. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9812. */
  9813. /**
  9814. * Sets the PCF or PCSS Quality.
  9815. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9816. */
  9817. filteringQuality: number;
  9818. /**
  9819. * Gets if the current filter is set to "PCSS" (contact hardening).
  9820. */
  9821. /**
  9822. * Sets the current filter to "PCSS" (contact hardening).
  9823. */
  9824. useContactHardeningShadow: boolean;
  9825. private _contactHardeningLightSizeUVRatio;
  9826. /**
  9827. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9828. * Using a ratio helps keeping shape stability independently of the map size.
  9829. *
  9830. * It does not account for the light projection as it was having too much
  9831. * instability during the light setup or during light position changes.
  9832. *
  9833. * Only valid if useContactHardeningShadow is true.
  9834. */
  9835. /**
  9836. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9837. * Using a ratio helps keeping shape stability independently of the map size.
  9838. *
  9839. * It does not account for the light projection as it was having too much
  9840. * instability during the light setup or during light position changes.
  9841. *
  9842. * Only valid if useContactHardeningShadow is true.
  9843. */
  9844. contactHardeningLightSizeUVRatio: number;
  9845. private _darkness;
  9846. /**
  9847. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9848. * 0 means strongest and 1 would means no shadow.
  9849. * @returns the darkness.
  9850. */
  9851. getDarkness(): number;
  9852. /**
  9853. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9854. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9855. * @returns the shadow generator allowing fluent coding.
  9856. */
  9857. setDarkness(darkness: number): ShadowGenerator;
  9858. private _transparencyShadow;
  9859. /**
  9860. * Sets the ability to have transparent shadow (boolean).
  9861. * @param transparent True if transparent else False
  9862. * @returns the shadow generator allowing fluent coding
  9863. */
  9864. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9865. private _shadowMap;
  9866. private _shadowMap2;
  9867. /**
  9868. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9869. * @returns The render target texture if present otherwise, null
  9870. */
  9871. getShadowMap(): Nullable<RenderTargetTexture>;
  9872. /**
  9873. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9874. * @returns The render target texture if the shadow map is present otherwise, null
  9875. */
  9876. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9877. /**
  9878. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9879. * @param mesh Mesh to add
  9880. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9881. * @returns the Shadow Generator itself
  9882. */
  9883. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9884. /**
  9885. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9886. * @param mesh Mesh to remove
  9887. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9888. * @returns the Shadow Generator itself
  9889. */
  9890. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9891. /**
  9892. * Controls the extent to which the shadows fade out at the edge of the frustum
  9893. * Used only by directionals and spots
  9894. */
  9895. frustumEdgeFalloff: number;
  9896. private _light;
  9897. /**
  9898. * Returns the associated light object.
  9899. * @returns the light generating the shadow
  9900. */
  9901. getLight(): IShadowLight;
  9902. /**
  9903. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9904. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9905. * It might on the other hand introduce peter panning.
  9906. */
  9907. forceBackFacesOnly: boolean;
  9908. private _scene;
  9909. private _lightDirection;
  9910. private _effect;
  9911. private _viewMatrix;
  9912. private _projectionMatrix;
  9913. private _transformMatrix;
  9914. private _cachedPosition;
  9915. private _cachedDirection;
  9916. private _cachedDefines;
  9917. private _currentRenderID;
  9918. private _boxBlurPostprocess;
  9919. private _kernelBlurXPostprocess;
  9920. private _kernelBlurYPostprocess;
  9921. private _blurPostProcesses;
  9922. private _mapSize;
  9923. private _currentFaceIndex;
  9924. private _currentFaceIndexCache;
  9925. private _textureType;
  9926. private _defaultTextureMatrix;
  9927. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9928. /**
  9929. * Creates a ShadowGenerator object.
  9930. * A ShadowGenerator is the required tool to use the shadows.
  9931. * Each light casting shadows needs to use its own ShadowGenerator.
  9932. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9933. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9934. * @param light The light object generating the shadows.
  9935. * @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.
  9936. */
  9937. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9938. private _initializeGenerator;
  9939. private _initializeShadowMap;
  9940. private _initializeBlurRTTAndPostProcesses;
  9941. private _renderForShadowMap;
  9942. private _renderSubMeshForShadowMap;
  9943. private _applyFilterValues;
  9944. /**
  9945. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9946. * @param onCompiled Callback triggered at the and of the effects compilation
  9947. * @param options Sets of optional options forcing the compilation with different modes
  9948. */
  9949. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9950. useInstances: boolean;
  9951. }>): void;
  9952. /**
  9953. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9954. * @param options Sets of optional options forcing the compilation with different modes
  9955. * @returns A promise that resolves when the compilation completes
  9956. */
  9957. forceCompilationAsync(options?: Partial<{
  9958. useInstances: boolean;
  9959. }>): Promise<void>;
  9960. /**
  9961. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9962. * @param subMesh The submesh we want to render in the shadow map
  9963. * @param useInstances Defines wether will draw in the map using instances
  9964. * @returns true if ready otherwise, false
  9965. */
  9966. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9967. /**
  9968. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9969. * @param defines Defines of the material we want to update
  9970. * @param lightIndex Index of the light in the enabled light list of the material
  9971. */
  9972. prepareDefines(defines: any, lightIndex: number): void;
  9973. /**
  9974. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9975. * defined in the generator but impacting the effect).
  9976. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9977. * @param effect The effect we are binfing the information for
  9978. */
  9979. bindShadowLight(lightIndex: string, effect: Effect): void;
  9980. /**
  9981. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9982. * (eq to shadow prjection matrix * light transform matrix)
  9983. * @returns The transform matrix used to create the shadow map
  9984. */
  9985. getTransformMatrix(): Matrix;
  9986. /**
  9987. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9988. * Cube and 2D textures for instance.
  9989. */
  9990. recreateShadowMap(): void;
  9991. private _disposeBlurPostProcesses;
  9992. private _disposeRTTandPostProcesses;
  9993. /**
  9994. * Disposes the ShadowGenerator.
  9995. * Returns nothing.
  9996. */
  9997. dispose(): void;
  9998. /**
  9999. * Serializes the shadow generator setup to a json object.
  10000. * @returns The serialized JSON object
  10001. */
  10002. serialize(): any;
  10003. /**
  10004. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10005. * @param parsedShadowGenerator The JSON object to parse
  10006. * @param scene The scene to create the shadow map for
  10007. * @returns The parsed shadow generator
  10008. */
  10009. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10010. }
  10011. }
  10012. declare module BABYLON {
  10013. /**
  10014. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10015. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10016. * 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.
  10017. */
  10018. export abstract class Light extends Node {
  10019. /**
  10020. * Falloff Default: light is falling off following the material specification:
  10021. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10022. */
  10023. static readonly FALLOFF_DEFAULT: number;
  10024. /**
  10025. * Falloff Physical: light is falling off following the inverse squared distance law.
  10026. */
  10027. static readonly FALLOFF_PHYSICAL: number;
  10028. /**
  10029. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10030. * to enhance interoperability with other engines.
  10031. */
  10032. static readonly FALLOFF_GLTF: number;
  10033. /**
  10034. * Falloff Standard: light is falling off like in the standard material
  10035. * to enhance interoperability with other materials.
  10036. */
  10037. static readonly FALLOFF_STANDARD: number;
  10038. /**
  10039. * If every light affecting the material is in this lightmapMode,
  10040. * material.lightmapTexture adds or multiplies
  10041. * (depends on material.useLightmapAsShadowmap)
  10042. * after every other light calculations.
  10043. */
  10044. static readonly LIGHTMAP_DEFAULT: number;
  10045. /**
  10046. * material.lightmapTexture as only diffuse lighting from this light
  10047. * adds only specular lighting from this light
  10048. * adds dynamic shadows
  10049. */
  10050. static readonly LIGHTMAP_SPECULAR: number;
  10051. /**
  10052. * material.lightmapTexture as only lighting
  10053. * no light calculation from this light
  10054. * only adds dynamic shadows from this light
  10055. */
  10056. static readonly LIGHTMAP_SHADOWSONLY: number;
  10057. /**
  10058. * Each light type uses the default quantity according to its type:
  10059. * point/spot lights use luminous intensity
  10060. * directional lights use illuminance
  10061. */
  10062. static readonly INTENSITYMODE_AUTOMATIC: number;
  10063. /**
  10064. * lumen (lm)
  10065. */
  10066. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10067. /**
  10068. * candela (lm/sr)
  10069. */
  10070. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10071. /**
  10072. * lux (lm/m^2)
  10073. */
  10074. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10075. /**
  10076. * nit (cd/m^2)
  10077. */
  10078. static readonly INTENSITYMODE_LUMINANCE: number;
  10079. /**
  10080. * Light type const id of the point light.
  10081. */
  10082. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10083. /**
  10084. * Light type const id of the directional light.
  10085. */
  10086. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10087. /**
  10088. * Light type const id of the spot light.
  10089. */
  10090. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10091. /**
  10092. * Light type const id of the hemispheric light.
  10093. */
  10094. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10095. /**
  10096. * Diffuse gives the basic color to an object.
  10097. */
  10098. diffuse: Color3;
  10099. /**
  10100. * Specular produces a highlight color on an object.
  10101. * Note: This is note affecting PBR materials.
  10102. */
  10103. specular: Color3;
  10104. /**
  10105. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10106. * falling off base on range or angle.
  10107. * This can be set to any values in Light.FALLOFF_x.
  10108. *
  10109. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10110. * other types of materials.
  10111. */
  10112. falloffType: number;
  10113. /**
  10114. * Strength of the light.
  10115. * Note: By default it is define in the framework own unit.
  10116. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10117. */
  10118. intensity: number;
  10119. private _range;
  10120. protected _inverseSquaredRange: number;
  10121. /**
  10122. * Defines how far from the source the light is impacting in scene units.
  10123. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10124. */
  10125. /**
  10126. * Defines how far from the source the light is impacting in scene units.
  10127. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10128. */
  10129. range: number;
  10130. /**
  10131. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10132. * of light.
  10133. */
  10134. private _photometricScale;
  10135. private _intensityMode;
  10136. /**
  10137. * Gets the photometric scale used to interpret the intensity.
  10138. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10139. */
  10140. /**
  10141. * Sets the photometric scale used to interpret the intensity.
  10142. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10143. */
  10144. intensityMode: number;
  10145. private _radius;
  10146. /**
  10147. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10148. */
  10149. /**
  10150. * sets the light radius used by PBR Materials to simulate soft area lights.
  10151. */
  10152. radius: number;
  10153. private _renderPriority;
  10154. /**
  10155. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10156. * exceeding the number allowed of the materials.
  10157. */
  10158. renderPriority: number;
  10159. private _shadowEnabled;
  10160. /**
  10161. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10162. * the current shadow generator.
  10163. */
  10164. /**
  10165. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10166. * the current shadow generator.
  10167. */
  10168. shadowEnabled: boolean;
  10169. private _includedOnlyMeshes;
  10170. /**
  10171. * Gets the only meshes impacted by this light.
  10172. */
  10173. /**
  10174. * Sets the only meshes impacted by this light.
  10175. */
  10176. includedOnlyMeshes: AbstractMesh[];
  10177. private _excludedMeshes;
  10178. /**
  10179. * Gets the meshes not impacted by this light.
  10180. */
  10181. /**
  10182. * Sets the meshes not impacted by this light.
  10183. */
  10184. excludedMeshes: AbstractMesh[];
  10185. private _excludeWithLayerMask;
  10186. /**
  10187. * Gets the layer id use to find what meshes are not impacted by the light.
  10188. * Inactive if 0
  10189. */
  10190. /**
  10191. * Sets the layer id use to find what meshes are not impacted by the light.
  10192. * Inactive if 0
  10193. */
  10194. excludeWithLayerMask: number;
  10195. private _includeOnlyWithLayerMask;
  10196. /**
  10197. * Gets the layer id use to find what meshes are impacted by the light.
  10198. * Inactive if 0
  10199. */
  10200. /**
  10201. * Sets the layer id use to find what meshes are impacted by the light.
  10202. * Inactive if 0
  10203. */
  10204. includeOnlyWithLayerMask: number;
  10205. private _lightmapMode;
  10206. /**
  10207. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10208. */
  10209. /**
  10210. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10211. */
  10212. lightmapMode: number;
  10213. /**
  10214. * Shadow generator associted to the light.
  10215. * @hidden Internal use only.
  10216. */ shadowGenerator: Nullable<IShadowGenerator>;
  10217. /**
  10218. * @hidden Internal use only.
  10219. */ excludedMeshesIds: string[];
  10220. /**
  10221. * @hidden Internal use only.
  10222. */ includedOnlyMeshesIds: string[];
  10223. /**
  10224. * The current light unifom buffer.
  10225. * @hidden Internal use only.
  10226. */ uniformBuffer: UniformBuffer;
  10227. /**
  10228. * Creates a Light object in the scene.
  10229. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10230. * @param name The firendly name of the light
  10231. * @param scene The scene the light belongs too
  10232. */
  10233. constructor(name: string, scene: Scene);
  10234. protected abstract _buildUniformLayout(): void;
  10235. /**
  10236. * Sets the passed Effect "effect" with the Light information.
  10237. * @param effect The effect to update
  10238. * @param lightIndex The index of the light in the effect to update
  10239. * @returns The light
  10240. */
  10241. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10242. /**
  10243. * Returns the string "Light".
  10244. * @returns the class name
  10245. */
  10246. getClassName(): string;
  10247. /** @hidden */ protected readonly _isLight: boolean;
  10248. /**
  10249. * Converts the light information to a readable string for debug purpose.
  10250. * @param fullDetails Supports for multiple levels of logging within scene loading
  10251. * @returns the human readable light info
  10252. */
  10253. toString(fullDetails?: boolean): string;
  10254. /** @hidden */
  10255. protected _syncParentEnabledState(): void;
  10256. /**
  10257. * Set the enabled state of this node.
  10258. * @param value - the new enabled state
  10259. */
  10260. setEnabled(value: boolean): void;
  10261. /**
  10262. * Returns the Light associated shadow generator if any.
  10263. * @return the associated shadow generator.
  10264. */
  10265. getShadowGenerator(): Nullable<IShadowGenerator>;
  10266. /**
  10267. * Returns a Vector3, the absolute light position in the World.
  10268. * @returns the world space position of the light
  10269. */
  10270. getAbsolutePosition(): Vector3;
  10271. /**
  10272. * Specifies if the light will affect the passed mesh.
  10273. * @param mesh The mesh to test against the light
  10274. * @return true the mesh is affected otherwise, false.
  10275. */
  10276. canAffectMesh(mesh: AbstractMesh): boolean;
  10277. /**
  10278. * Sort function to order lights for rendering.
  10279. * @param a First Light object to compare to second.
  10280. * @param b Second Light object to compare first.
  10281. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10282. */
  10283. static CompareLightsPriority(a: Light, b: Light): number;
  10284. /**
  10285. * Releases resources associated with this node.
  10286. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10287. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10288. */
  10289. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10290. /**
  10291. * Returns the light type ID (integer).
  10292. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10293. */
  10294. getTypeID(): number;
  10295. /**
  10296. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10297. * @returns the scaled intensity in intensity mode unit
  10298. */
  10299. getScaledIntensity(): number;
  10300. /**
  10301. * Returns a new Light object, named "name", from the current one.
  10302. * @param name The name of the cloned light
  10303. * @returns the new created light
  10304. */
  10305. clone(name: string): Nullable<Light>;
  10306. /**
  10307. * Serializes the current light into a Serialization object.
  10308. * @returns the serialized object.
  10309. */
  10310. serialize(): any;
  10311. /**
  10312. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10313. * This new light is named "name" and added to the passed scene.
  10314. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10315. * @param name The friendly name of the light
  10316. * @param scene The scene the new light will belong to
  10317. * @returns the constructor function
  10318. */
  10319. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10320. /**
  10321. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10322. * @param parsedLight The JSON representation of the light
  10323. * @param scene The scene to create the parsed light in
  10324. * @returns the created light after parsing
  10325. */
  10326. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10327. private _hookArrayForExcluded;
  10328. private _hookArrayForIncludedOnly;
  10329. private _resyncMeshes;
  10330. /**
  10331. * Forces the meshes to update their light related information in their rendering used effects
  10332. * @hidden Internal Use Only
  10333. */ markMeshesAsLightDirty(): void;
  10334. /**
  10335. * Recomputes the cached photometric scale if needed.
  10336. */
  10337. private _computePhotometricScale;
  10338. /**
  10339. * Returns the Photometric Scale according to the light type and intensity mode.
  10340. */
  10341. private _getPhotometricScale;
  10342. /**
  10343. * Reorder the light in the scene according to their defined priority.
  10344. * @hidden Internal Use Only
  10345. */ reorderLightsInScene(): void;
  10346. /**
  10347. * Prepares the list of defines specific to the light type.
  10348. * @param defines the list of defines
  10349. * @param lightIndex defines the index of the light for the effect
  10350. */
  10351. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10352. }
  10353. }
  10354. declare module BABYLON {
  10355. /**
  10356. * Interface used to define Action
  10357. */
  10358. export interface IAction {
  10359. /**
  10360. * Trigger for the action
  10361. */
  10362. trigger: number;
  10363. /** Options of the trigger */
  10364. triggerOptions: any;
  10365. /**
  10366. * Gets the trigger parameters
  10367. * @returns the trigger parameters
  10368. */
  10369. getTriggerParameter(): any;
  10370. /**
  10371. * Internal only - executes current action event
  10372. * @hidden
  10373. */ executeCurrent(evt?: ActionEvent): void;
  10374. /**
  10375. * Serialize placeholder for child classes
  10376. * @param parent of child
  10377. * @returns the serialized object
  10378. */
  10379. serialize(parent: any): any;
  10380. /**
  10381. * Internal only
  10382. * @hidden
  10383. */ prepare(): void;
  10384. /**
  10385. * Internal only - manager for action
  10386. * @hidden
  10387. */ actionManager: AbstractActionManager;
  10388. }
  10389. /**
  10390. * The action to be carried out following a trigger
  10391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10392. */
  10393. export class Action implements IAction {
  10394. /** the trigger, with or without parameters, for the action */
  10395. triggerOptions: any;
  10396. /**
  10397. * Trigger for the action
  10398. */
  10399. trigger: number;
  10400. /**
  10401. * Internal only - manager for action
  10402. * @hidden
  10403. */ actionManager: ActionManager;
  10404. private _nextActiveAction;
  10405. private _child;
  10406. private _condition?;
  10407. private _triggerParameter;
  10408. /**
  10409. * An event triggered prior to action being executed.
  10410. */
  10411. onBeforeExecuteObservable: Observable<Action>;
  10412. /**
  10413. * Creates a new Action
  10414. * @param triggerOptions the trigger, with or without parameters, for the action
  10415. * @param condition an optional determinant of action
  10416. */
  10417. constructor(
  10418. /** the trigger, with or without parameters, for the action */
  10419. triggerOptions: any, condition?: Condition);
  10420. /**
  10421. * Internal only
  10422. * @hidden
  10423. */ prepare(): void;
  10424. /**
  10425. * Gets the trigger parameters
  10426. * @returns the trigger parameters
  10427. */
  10428. getTriggerParameter(): any;
  10429. /**
  10430. * Internal only - executes current action event
  10431. * @hidden
  10432. */ executeCurrent(evt?: ActionEvent): void;
  10433. /**
  10434. * Execute placeholder for child classes
  10435. * @param evt optional action event
  10436. */
  10437. execute(evt?: ActionEvent): void;
  10438. /**
  10439. * Skips to next active action
  10440. */
  10441. skipToNextActiveAction(): void;
  10442. /**
  10443. * Adds action to chain of actions, may be a DoNothingAction
  10444. * @param action defines the next action to execute
  10445. * @returns The action passed in
  10446. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10447. */
  10448. then(action: Action): Action;
  10449. /**
  10450. * Internal only
  10451. * @hidden
  10452. */ getProperty(propertyPath: string): string;
  10453. /**
  10454. * Internal only
  10455. * @hidden
  10456. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10457. /**
  10458. * Serialize placeholder for child classes
  10459. * @param parent of child
  10460. * @returns the serialized object
  10461. */
  10462. serialize(parent: any): any;
  10463. /**
  10464. * Internal only called by serialize
  10465. * @hidden
  10466. */
  10467. protected _serialize(serializedAction: any, parent?: any): any;
  10468. /**
  10469. * Internal only
  10470. * @hidden
  10471. */ private static _SerializeValueAsString: (value: any) => string;
  10472. /**
  10473. * Internal only
  10474. * @hidden
  10475. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10476. name: string;
  10477. targetType: string;
  10478. value: string;
  10479. };
  10480. }
  10481. }
  10482. declare module BABYLON {
  10483. /**
  10484. * A Condition applied to an Action
  10485. */
  10486. export class Condition {
  10487. /**
  10488. * Internal only - manager for action
  10489. * @hidden
  10490. */ actionManager: ActionManager;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */ evaluationId: number;
  10495. /**
  10496. * Internal only
  10497. * @hidden
  10498. */ currentResult: boolean;
  10499. /**
  10500. * Creates a new Condition
  10501. * @param actionManager the manager of the action the condition is applied to
  10502. */
  10503. constructor(actionManager: ActionManager);
  10504. /**
  10505. * Check if the current condition is valid
  10506. * @returns a boolean
  10507. */
  10508. isValid(): boolean;
  10509. /**
  10510. * Internal only
  10511. * @hidden
  10512. */ getProperty(propertyPath: string): string;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10517. /**
  10518. * Serialize placeholder for child classes
  10519. * @returns the serialized object
  10520. */
  10521. serialize(): any;
  10522. /**
  10523. * Internal only
  10524. * @hidden
  10525. */
  10526. protected _serialize(serializedCondition: any): any;
  10527. }
  10528. /**
  10529. * Defines specific conditional operators as extensions of Condition
  10530. */
  10531. export class ValueCondition extends Condition {
  10532. /** path to specify the property of the target the conditional operator uses */
  10533. propertyPath: string;
  10534. /** the value compared by the conditional operator against the current value of the property */
  10535. value: any;
  10536. /** the conditional operator, default ValueCondition.IsEqual */
  10537. operator: number;
  10538. /**
  10539. * Internal only
  10540. * @hidden
  10541. */
  10542. private static _IsEqual;
  10543. /**
  10544. * Internal only
  10545. * @hidden
  10546. */
  10547. private static _IsDifferent;
  10548. /**
  10549. * Internal only
  10550. * @hidden
  10551. */
  10552. private static _IsGreater;
  10553. /**
  10554. * Internal only
  10555. * @hidden
  10556. */
  10557. private static _IsLesser;
  10558. /**
  10559. * returns the number for IsEqual
  10560. */
  10561. static readonly IsEqual: number;
  10562. /**
  10563. * Returns the number for IsDifferent
  10564. */
  10565. static readonly IsDifferent: number;
  10566. /**
  10567. * Returns the number for IsGreater
  10568. */
  10569. static readonly IsGreater: number;
  10570. /**
  10571. * Returns the number for IsLesser
  10572. */
  10573. static readonly IsLesser: number;
  10574. /**
  10575. * Internal only The action manager for the condition
  10576. * @hidden
  10577. */ actionManager: ActionManager;
  10578. /**
  10579. * Internal only
  10580. * @hidden
  10581. */
  10582. private _target;
  10583. /**
  10584. * Internal only
  10585. * @hidden
  10586. */
  10587. private _effectiveTarget;
  10588. /**
  10589. * Internal only
  10590. * @hidden
  10591. */
  10592. private _property;
  10593. /**
  10594. * Creates a new ValueCondition
  10595. * @param actionManager manager for the action the condition applies to
  10596. * @param target for the action
  10597. * @param propertyPath path to specify the property of the target the conditional operator uses
  10598. * @param value the value compared by the conditional operator against the current value of the property
  10599. * @param operator the conditional operator, default ValueCondition.IsEqual
  10600. */
  10601. constructor(actionManager: ActionManager, target: any,
  10602. /** path to specify the property of the target the conditional operator uses */
  10603. propertyPath: string,
  10604. /** the value compared by the conditional operator against the current value of the property */
  10605. value: any,
  10606. /** the conditional operator, default ValueCondition.IsEqual */
  10607. operator?: number);
  10608. /**
  10609. * Compares the given value with the property value for the specified conditional operator
  10610. * @returns the result of the comparison
  10611. */
  10612. isValid(): boolean;
  10613. /**
  10614. * Serialize the ValueCondition into a JSON compatible object
  10615. * @returns serialization object
  10616. */
  10617. serialize(): any;
  10618. /**
  10619. * Gets the name of the conditional operator for the ValueCondition
  10620. * @param operator the conditional operator
  10621. * @returns the name
  10622. */
  10623. static GetOperatorName(operator: number): string;
  10624. }
  10625. /**
  10626. * Defines a predicate condition as an extension of Condition
  10627. */
  10628. export class PredicateCondition extends Condition {
  10629. /** defines the predicate function used to validate the condition */
  10630. predicate: () => boolean;
  10631. /**
  10632. * Internal only - manager for action
  10633. * @hidden
  10634. */ actionManager: ActionManager;
  10635. /**
  10636. * Creates a new PredicateCondition
  10637. * @param actionManager manager for the action the condition applies to
  10638. * @param predicate defines the predicate function used to validate the condition
  10639. */
  10640. constructor(actionManager: ActionManager,
  10641. /** defines the predicate function used to validate the condition */
  10642. predicate: () => boolean);
  10643. /**
  10644. * @returns the validity of the predicate condition
  10645. */
  10646. isValid(): boolean;
  10647. }
  10648. /**
  10649. * Defines a state condition as an extension of Condition
  10650. */
  10651. export class StateCondition extends Condition {
  10652. /** Value to compare with target state */
  10653. value: string;
  10654. /**
  10655. * Internal only - manager for action
  10656. * @hidden
  10657. */ actionManager: ActionManager;
  10658. /**
  10659. * Internal only
  10660. * @hidden
  10661. */
  10662. private _target;
  10663. /**
  10664. * Creates a new StateCondition
  10665. * @param actionManager manager for the action the condition applies to
  10666. * @param target of the condition
  10667. * @param value to compare with target state
  10668. */
  10669. constructor(actionManager: ActionManager, target: any,
  10670. /** Value to compare with target state */
  10671. value: string);
  10672. /**
  10673. * Gets a boolean indicating if the current condition is met
  10674. * @returns the validity of the state
  10675. */
  10676. isValid(): boolean;
  10677. /**
  10678. * Serialize the StateCondition into a JSON compatible object
  10679. * @returns serialization object
  10680. */
  10681. serialize(): any;
  10682. }
  10683. }
  10684. declare module BABYLON {
  10685. /**
  10686. * This defines an action responsible to toggle a boolean once triggered.
  10687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10688. */
  10689. export class SwitchBooleanAction extends Action {
  10690. /**
  10691. * The path to the boolean property in the target object
  10692. */
  10693. propertyPath: string;
  10694. private _target;
  10695. private _effectiveTarget;
  10696. private _property;
  10697. /**
  10698. * Instantiate the action
  10699. * @param triggerOptions defines the trigger options
  10700. * @param target defines the object containing the boolean
  10701. * @param propertyPath defines the path to the boolean property in the target object
  10702. * @param condition defines the trigger related conditions
  10703. */
  10704. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10705. /** @hidden */ prepare(): void;
  10706. /**
  10707. * Execute the action toggle the boolean value.
  10708. */
  10709. execute(): void;
  10710. /**
  10711. * Serializes the actions and its related information.
  10712. * @param parent defines the object to serialize in
  10713. * @returns the serialized object
  10714. */
  10715. serialize(parent: any): any;
  10716. }
  10717. /**
  10718. * This defines an action responsible to set a the state field of the target
  10719. * to a desired value once triggered.
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10721. */
  10722. export class SetStateAction extends Action {
  10723. /**
  10724. * The value to store in the state field.
  10725. */
  10726. value: string;
  10727. private _target;
  10728. /**
  10729. * Instantiate the action
  10730. * @param triggerOptions defines the trigger options
  10731. * @param target defines the object containing the state property
  10732. * @param value defines the value to store in the state field
  10733. * @param condition defines the trigger related conditions
  10734. */
  10735. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10736. /**
  10737. * Execute the action and store the value on the target state property.
  10738. */
  10739. execute(): void;
  10740. /**
  10741. * Serializes the actions and its related information.
  10742. * @param parent defines the object to serialize in
  10743. * @returns the serialized object
  10744. */
  10745. serialize(parent: any): any;
  10746. }
  10747. /**
  10748. * This defines an action responsible to set a property of the target
  10749. * to a desired value once triggered.
  10750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10751. */
  10752. export class SetValueAction extends Action {
  10753. /**
  10754. * The path of the property to set in the target.
  10755. */
  10756. propertyPath: string;
  10757. /**
  10758. * The value to set in the property
  10759. */
  10760. value: any;
  10761. private _target;
  10762. private _effectiveTarget;
  10763. private _property;
  10764. /**
  10765. * Instantiate the action
  10766. * @param triggerOptions defines the trigger options
  10767. * @param target defines the object containing the property
  10768. * @param propertyPath defines the path of the property to set in the target
  10769. * @param value defines the value to set in the property
  10770. * @param condition defines the trigger related conditions
  10771. */
  10772. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10773. /** @hidden */ prepare(): void;
  10774. /**
  10775. * Execute the action and set the targetted property to the desired value.
  10776. */
  10777. execute(): void;
  10778. /**
  10779. * Serializes the actions and its related information.
  10780. * @param parent defines the object to serialize in
  10781. * @returns the serialized object
  10782. */
  10783. serialize(parent: any): any;
  10784. }
  10785. /**
  10786. * This defines an action responsible to increment the target value
  10787. * to a desired value once triggered.
  10788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10789. */
  10790. export class IncrementValueAction extends Action {
  10791. /**
  10792. * The path of the property to increment in the target.
  10793. */
  10794. propertyPath: string;
  10795. /**
  10796. * The value we should increment the property by.
  10797. */
  10798. value: any;
  10799. private _target;
  10800. private _effectiveTarget;
  10801. private _property;
  10802. /**
  10803. * Instantiate the action
  10804. * @param triggerOptions defines the trigger options
  10805. * @param target defines the object containing the property
  10806. * @param propertyPath defines the path of the property to increment in the target
  10807. * @param value defines the value value we should increment the property by
  10808. * @param condition defines the trigger related conditions
  10809. */
  10810. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10811. /** @hidden */ prepare(): void;
  10812. /**
  10813. * Execute the action and increment the target of the value amount.
  10814. */
  10815. execute(): void;
  10816. /**
  10817. * Serializes the actions and its related information.
  10818. * @param parent defines the object to serialize in
  10819. * @returns the serialized object
  10820. */
  10821. serialize(parent: any): any;
  10822. }
  10823. /**
  10824. * This defines an action responsible to start an animation once triggered.
  10825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10826. */
  10827. export class PlayAnimationAction extends Action {
  10828. /**
  10829. * Where the animation should start (animation frame)
  10830. */
  10831. from: number;
  10832. /**
  10833. * Where the animation should stop (animation frame)
  10834. */
  10835. to: number;
  10836. /**
  10837. * Define if the animation should loop or stop after the first play.
  10838. */
  10839. loop?: boolean;
  10840. private _target;
  10841. /**
  10842. * Instantiate the action
  10843. * @param triggerOptions defines the trigger options
  10844. * @param target defines the target animation or animation name
  10845. * @param from defines from where the animation should start (animation frame)
  10846. * @param end defines where the animation should stop (animation frame)
  10847. * @param loop defines if the animation should loop or stop after the first play
  10848. * @param condition defines the trigger related conditions
  10849. */
  10850. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10851. /** @hidden */ prepare(): void;
  10852. /**
  10853. * Execute the action and play the animation.
  10854. */
  10855. execute(): void;
  10856. /**
  10857. * Serializes the actions and its related information.
  10858. * @param parent defines the object to serialize in
  10859. * @returns the serialized object
  10860. */
  10861. serialize(parent: any): any;
  10862. }
  10863. /**
  10864. * This defines an action responsible to stop an animation once triggered.
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10866. */
  10867. export class StopAnimationAction extends Action {
  10868. private _target;
  10869. /**
  10870. * Instantiate the action
  10871. * @param triggerOptions defines the trigger options
  10872. * @param target defines the target animation or animation name
  10873. * @param condition defines the trigger related conditions
  10874. */
  10875. constructor(triggerOptions: any, target: any, condition?: Condition);
  10876. /** @hidden */ prepare(): void;
  10877. /**
  10878. * Execute the action and stop the animation.
  10879. */
  10880. execute(): void;
  10881. /**
  10882. * Serializes the actions and its related information.
  10883. * @param parent defines the object to serialize in
  10884. * @returns the serialized object
  10885. */
  10886. serialize(parent: any): any;
  10887. }
  10888. /**
  10889. * This defines an action responsible that does nothing once triggered.
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10891. */
  10892. export class DoNothingAction extends Action {
  10893. /**
  10894. * Instantiate the action
  10895. * @param triggerOptions defines the trigger options
  10896. * @param condition defines the trigger related conditions
  10897. */
  10898. constructor(triggerOptions?: any, condition?: Condition);
  10899. /**
  10900. * Execute the action and do nothing.
  10901. */
  10902. execute(): void;
  10903. /**
  10904. * Serializes the actions and its related information.
  10905. * @param parent defines the object to serialize in
  10906. * @returns the serialized object
  10907. */
  10908. serialize(parent: any): any;
  10909. }
  10910. /**
  10911. * This defines an action responsible to trigger several actions once triggered.
  10912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10913. */
  10914. export class CombineAction extends Action {
  10915. /**
  10916. * The list of aggregated animations to run.
  10917. */
  10918. children: Action[];
  10919. /**
  10920. * Instantiate the action
  10921. * @param triggerOptions defines the trigger options
  10922. * @param children defines the list of aggregated animations to run
  10923. * @param condition defines the trigger related conditions
  10924. */
  10925. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10926. /** @hidden */ prepare(): void;
  10927. /**
  10928. * Execute the action and executes all the aggregated actions.
  10929. */
  10930. execute(evt: ActionEvent): void;
  10931. /**
  10932. * Serializes the actions and its related information.
  10933. * @param parent defines the object to serialize in
  10934. * @returns the serialized object
  10935. */
  10936. serialize(parent: any): any;
  10937. }
  10938. /**
  10939. * This defines an action responsible to run code (external event) once triggered.
  10940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10941. */
  10942. export class ExecuteCodeAction extends Action {
  10943. /**
  10944. * The callback function to run.
  10945. */
  10946. func: (evt: ActionEvent) => void;
  10947. /**
  10948. * Instantiate the action
  10949. * @param triggerOptions defines the trigger options
  10950. * @param func defines the callback function to run
  10951. * @param condition defines the trigger related conditions
  10952. */
  10953. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10954. /**
  10955. * Execute the action and run the attached code.
  10956. */
  10957. execute(evt: ActionEvent): void;
  10958. }
  10959. /**
  10960. * This defines an action responsible to set the parent property of the target once triggered.
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10962. */
  10963. export class SetParentAction extends Action {
  10964. private _parent;
  10965. private _target;
  10966. /**
  10967. * Instantiate the action
  10968. * @param triggerOptions defines the trigger options
  10969. * @param target defines the target containing the parent property
  10970. * @param parent defines from where the animation should start (animation frame)
  10971. * @param condition defines the trigger related conditions
  10972. */
  10973. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10974. /** @hidden */ prepare(): void;
  10975. /**
  10976. * Execute the action and set the parent property.
  10977. */
  10978. execute(): void;
  10979. /**
  10980. * Serializes the actions and its related information.
  10981. * @param parent defines the object to serialize in
  10982. * @returns the serialized object
  10983. */
  10984. serialize(parent: any): any;
  10985. }
  10986. }
  10987. declare module BABYLON {
  10988. /**
  10989. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10990. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10992. */
  10993. export class ActionManager extends AbstractActionManager {
  10994. /**
  10995. * Nothing
  10996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10997. */
  10998. static readonly NothingTrigger: number;
  10999. /**
  11000. * On pick
  11001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11002. */
  11003. static readonly OnPickTrigger: number;
  11004. /**
  11005. * On left pick
  11006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11007. */
  11008. static readonly OnLeftPickTrigger: number;
  11009. /**
  11010. * On right pick
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11012. */
  11013. static readonly OnRightPickTrigger: number;
  11014. /**
  11015. * On center pick
  11016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11017. */
  11018. static readonly OnCenterPickTrigger: number;
  11019. /**
  11020. * On pick down
  11021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11022. */
  11023. static readonly OnPickDownTrigger: number;
  11024. /**
  11025. * On double pick
  11026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11027. */
  11028. static readonly OnDoublePickTrigger: number;
  11029. /**
  11030. * On pick up
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11032. */
  11033. static readonly OnPickUpTrigger: number;
  11034. /**
  11035. * On pick out.
  11036. * This trigger will only be raised if you also declared a OnPickDown
  11037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11038. */
  11039. static readonly OnPickOutTrigger: number;
  11040. /**
  11041. * On long press
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11043. */
  11044. static readonly OnLongPressTrigger: number;
  11045. /**
  11046. * On pointer over
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11048. */
  11049. static readonly OnPointerOverTrigger: number;
  11050. /**
  11051. * On pointer out
  11052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11053. */
  11054. static readonly OnPointerOutTrigger: number;
  11055. /**
  11056. * On every frame
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11058. */
  11059. static readonly OnEveryFrameTrigger: number;
  11060. /**
  11061. * On intersection enter
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11063. */
  11064. static readonly OnIntersectionEnterTrigger: number;
  11065. /**
  11066. * On intersection exit
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11068. */
  11069. static readonly OnIntersectionExitTrigger: number;
  11070. /**
  11071. * On key down
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11073. */
  11074. static readonly OnKeyDownTrigger: number;
  11075. /**
  11076. * On key up
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnKeyUpTrigger: number;
  11080. private _scene;
  11081. /**
  11082. * Creates a new action manager
  11083. * @param scene defines the hosting scene
  11084. */
  11085. constructor(scene: Scene);
  11086. /**
  11087. * Releases all associated resources
  11088. */
  11089. dispose(): void;
  11090. /**
  11091. * Gets hosting scene
  11092. * @returns the hosting scene
  11093. */
  11094. getScene(): Scene;
  11095. /**
  11096. * Does this action manager handles actions of any of the given triggers
  11097. * @param triggers defines the triggers to be tested
  11098. * @return a boolean indicating whether one (or more) of the triggers is handled
  11099. */
  11100. hasSpecificTriggers(triggers: number[]): boolean;
  11101. /**
  11102. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11103. * speed.
  11104. * @param triggerA defines the trigger to be tested
  11105. * @param triggerB defines the trigger to be tested
  11106. * @return a boolean indicating whether one (or more) of the triggers is handled
  11107. */
  11108. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11109. /**
  11110. * Does this action manager handles actions of a given trigger
  11111. * @param trigger defines the trigger to be tested
  11112. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11113. * @return whether the trigger is handled
  11114. */
  11115. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11116. /**
  11117. * Does this action manager has pointer triggers
  11118. */
  11119. readonly hasPointerTriggers: boolean;
  11120. /**
  11121. * Does this action manager has pick triggers
  11122. */
  11123. readonly hasPickTriggers: boolean;
  11124. /**
  11125. * Registers an action to this action manager
  11126. * @param action defines the action to be registered
  11127. * @return the action amended (prepared) after registration
  11128. */
  11129. registerAction(action: IAction): Nullable<IAction>;
  11130. /**
  11131. * Unregisters an action to this action manager
  11132. * @param action defines the action to be unregistered
  11133. * @return a boolean indicating whether the action has been unregistered
  11134. */
  11135. unregisterAction(action: IAction): Boolean;
  11136. /**
  11137. * Process a specific trigger
  11138. * @param trigger defines the trigger to process
  11139. * @param evt defines the event details to be processed
  11140. */
  11141. processTrigger(trigger: number, evt?: IActionEvent): void;
  11142. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  11143. /** @hidden */ getProperty(propertyPath: string): string;
  11144. /**
  11145. * Serialize this manager to a JSON object
  11146. * @param name defines the property name to store this manager
  11147. * @returns a JSON representation of this manager
  11148. */
  11149. serialize(name: string): any;
  11150. /**
  11151. * Creates a new ActionManager from a JSON data
  11152. * @param parsedActions defines the JSON data to read from
  11153. * @param object defines the hosting mesh
  11154. * @param scene defines the hosting scene
  11155. */
  11156. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11157. /**
  11158. * Get a trigger name by index
  11159. * @param trigger defines the trigger index
  11160. * @returns a trigger name
  11161. */
  11162. static GetTriggerName(trigger: number): string;
  11163. }
  11164. }
  11165. declare module BABYLON {
  11166. /**
  11167. * Class representing a ray with position and direction
  11168. */
  11169. export class Ray {
  11170. /** origin point */
  11171. origin: Vector3;
  11172. /** direction */
  11173. direction: Vector3;
  11174. /** length of the ray */
  11175. length: number;
  11176. private static readonly TmpVector3;
  11177. private _tmpRay;
  11178. /**
  11179. * Creates a new ray
  11180. * @param origin origin point
  11181. * @param direction direction
  11182. * @param length length of the ray
  11183. */
  11184. constructor(
  11185. /** origin point */
  11186. origin: Vector3,
  11187. /** direction */
  11188. direction: Vector3,
  11189. /** length of the ray */
  11190. length?: number);
  11191. /**
  11192. * Checks if the ray intersects a box
  11193. * @param minimum bound of the box
  11194. * @param maximum bound of the box
  11195. * @param intersectionTreshold extra extend to be added to the box in all direction
  11196. * @returns if the box was hit
  11197. */
  11198. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11199. /**
  11200. * Checks if the ray intersects a box
  11201. * @param box the bounding box to check
  11202. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11203. * @returns if the box was hit
  11204. */
  11205. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11206. /**
  11207. * If the ray hits a sphere
  11208. * @param sphere the bounding sphere to check
  11209. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11210. * @returns true if it hits the sphere
  11211. */
  11212. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11213. /**
  11214. * If the ray hits a triange
  11215. * @param vertex0 triangle vertex
  11216. * @param vertex1 triangle vertex
  11217. * @param vertex2 triangle vertex
  11218. * @returns intersection information if hit
  11219. */
  11220. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11221. /**
  11222. * Checks if ray intersects a plane
  11223. * @param plane the plane to check
  11224. * @returns the distance away it was hit
  11225. */
  11226. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11227. /**
  11228. * Checks if ray intersects a mesh
  11229. * @param mesh the mesh to check
  11230. * @param fastCheck if only the bounding box should checked
  11231. * @returns picking info of the intersecton
  11232. */
  11233. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11234. /**
  11235. * Checks if ray intersects a mesh
  11236. * @param meshes the meshes to check
  11237. * @param fastCheck if only the bounding box should checked
  11238. * @param results array to store result in
  11239. * @returns Array of picking infos
  11240. */
  11241. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11242. private _comparePickingInfo;
  11243. private static smallnum;
  11244. private static rayl;
  11245. /**
  11246. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11247. * @param sega the first point of the segment to test the intersection against
  11248. * @param segb the second point of the segment to test the intersection against
  11249. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11250. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11251. */
  11252. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11253. /**
  11254. * Update the ray from viewport position
  11255. * @param x position
  11256. * @param y y position
  11257. * @param viewportWidth viewport width
  11258. * @param viewportHeight viewport height
  11259. * @param world world matrix
  11260. * @param view view matrix
  11261. * @param projection projection matrix
  11262. * @returns this ray updated
  11263. */
  11264. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11265. /**
  11266. * Creates a ray with origin and direction of 0,0,0
  11267. * @returns the new ray
  11268. */
  11269. static Zero(): Ray;
  11270. /**
  11271. * Creates a new ray from screen space and viewport
  11272. * @param x position
  11273. * @param y y position
  11274. * @param viewportWidth viewport width
  11275. * @param viewportHeight viewport height
  11276. * @param world world matrix
  11277. * @param view view matrix
  11278. * @param projection projection matrix
  11279. * @returns new ray
  11280. */
  11281. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11282. /**
  11283. * 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
  11284. * transformed to the given world matrix.
  11285. * @param origin The origin point
  11286. * @param end The end point
  11287. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11288. * @returns the new ray
  11289. */
  11290. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11291. /**
  11292. * Transforms a ray by a matrix
  11293. * @param ray ray to transform
  11294. * @param matrix matrix to apply
  11295. * @returns the resulting new ray
  11296. */
  11297. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11298. /**
  11299. * Transforms a ray by a matrix
  11300. * @param ray ray to transform
  11301. * @param matrix matrix to apply
  11302. * @param result ray to store result in
  11303. */
  11304. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11305. /**
  11306. * Unproject a ray from screen space to object space
  11307. * @param sourceX defines the screen space x coordinate to use
  11308. * @param sourceY defines the screen space y coordinate to use
  11309. * @param viewportWidth defines the current width of the viewport
  11310. * @param viewportHeight defines the current height of the viewport
  11311. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11312. * @param view defines the view matrix to use
  11313. * @param projection defines the projection matrix to use
  11314. */
  11315. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11316. }
  11317. /**
  11318. * Type used to define predicate used to select faces when a mesh intersection is detected
  11319. */
  11320. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11321. interface Scene {
  11322. /** @hidden */ tempPickingRay: Nullable<Ray>;
  11323. /** @hidden */ cachedRayForTransform: Ray;
  11324. /** @hidden */ pickWithRayInverseMatrix: Matrix;
  11325. /** @hidden */ internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11326. /** @hidden */ internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11327. }
  11328. }
  11329. declare module BABYLON {
  11330. /**
  11331. * Groups all the scene component constants in one place to ease maintenance.
  11332. * @hidden
  11333. */
  11334. export class SceneComponentConstants {
  11335. static readonly NAME_EFFECTLAYER: string;
  11336. static readonly NAME_LAYER: string;
  11337. static readonly NAME_LENSFLARESYSTEM: string;
  11338. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11339. static readonly NAME_PARTICLESYSTEM: string;
  11340. static readonly NAME_GAMEPAD: string;
  11341. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11342. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11343. static readonly NAME_DEPTHRENDERER: string;
  11344. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11345. static readonly NAME_SPRITE: string;
  11346. static readonly NAME_OUTLINERENDERER: string;
  11347. static readonly NAME_PROCEDURALTEXTURE: string;
  11348. static readonly NAME_SHADOWGENERATOR: string;
  11349. static readonly NAME_OCTREE: string;
  11350. static readonly NAME_PHYSICSENGINE: string;
  11351. static readonly NAME_AUDIO: string;
  11352. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11353. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11354. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11355. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11356. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11357. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11358. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11359. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11360. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11361. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11362. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11363. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11364. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11365. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11366. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11367. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11368. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11369. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11370. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11371. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11372. static readonly STEP_AFTERRENDER_AUDIO: number;
  11373. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11374. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11375. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11376. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11377. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11378. static readonly STEP_POINTERMOVE_SPRITE: number;
  11379. static readonly STEP_POINTERDOWN_SPRITE: number;
  11380. static readonly STEP_POINTERUP_SPRITE: number;
  11381. }
  11382. /**
  11383. * This represents a scene component.
  11384. *
  11385. * This is used to decouple the dependency the scene is having on the different workloads like
  11386. * layers, post processes...
  11387. */
  11388. export interface ISceneComponent {
  11389. /**
  11390. * The name of the component. Each component must have a unique name.
  11391. */
  11392. name: string;
  11393. /**
  11394. * The scene the component belongs to.
  11395. */
  11396. scene: Scene;
  11397. /**
  11398. * Register the component to one instance of a scene.
  11399. */
  11400. register(): void;
  11401. /**
  11402. * Rebuilds the elements related to this component in case of
  11403. * context lost for instance.
  11404. */
  11405. rebuild(): void;
  11406. /**
  11407. * Disposes the component and the associated ressources.
  11408. */
  11409. dispose(): void;
  11410. }
  11411. /**
  11412. * This represents a SERIALIZABLE scene component.
  11413. *
  11414. * This extends Scene Component to add Serialization methods on top.
  11415. */
  11416. export interface ISceneSerializableComponent extends ISceneComponent {
  11417. /**
  11418. * Adds all the element from the container to the scene
  11419. * @param container the container holding the elements
  11420. */
  11421. addFromContainer(container: AbstractScene): void;
  11422. /**
  11423. * Removes all the elements in the container from the scene
  11424. * @param container contains the elements to remove
  11425. * @param dispose if the removed element should be disposed (default: false)
  11426. */
  11427. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11428. /**
  11429. * Serializes the component data to the specified json object
  11430. * @param serializationObject The object to serialize to
  11431. */
  11432. serialize(serializationObject: any): void;
  11433. }
  11434. /**
  11435. * Strong typing of a Mesh related stage step action
  11436. */
  11437. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11438. /**
  11439. * Strong typing of a Evaluate Sub Mesh related stage step action
  11440. */
  11441. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11442. /**
  11443. * Strong typing of a Active Mesh related stage step action
  11444. */
  11445. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11446. /**
  11447. * Strong typing of a Camera related stage step action
  11448. */
  11449. export type CameraStageAction = (camera: Camera) => void;
  11450. /**
  11451. * Strong typing of a Camera Frame buffer related stage step action
  11452. */
  11453. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11454. /**
  11455. * Strong typing of a Render Target related stage step action
  11456. */
  11457. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11458. /**
  11459. * Strong typing of a RenderingGroup related stage step action
  11460. */
  11461. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11462. /**
  11463. * Strong typing of a Mesh Render related stage step action
  11464. */
  11465. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11466. /**
  11467. * Strong typing of a simple stage step action
  11468. */
  11469. export type SimpleStageAction = () => void;
  11470. /**
  11471. * Strong typing of a render target action.
  11472. */
  11473. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11474. /**
  11475. * Strong typing of a pointer move action.
  11476. */
  11477. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11478. /**
  11479. * Strong typing of a pointer up/down action.
  11480. */
  11481. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11482. /**
  11483. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11484. * @hidden
  11485. */
  11486. export class Stage<T extends Function> extends Array<{
  11487. index: number;
  11488. component: ISceneComponent;
  11489. action: T;
  11490. }> {
  11491. /**
  11492. * Hide ctor from the rest of the world.
  11493. * @param items The items to add.
  11494. */
  11495. private constructor();
  11496. /**
  11497. * Creates a new Stage.
  11498. * @returns A new instance of a Stage
  11499. */
  11500. static Create<T extends Function>(): Stage<T>;
  11501. /**
  11502. * Registers a step in an ordered way in the targeted stage.
  11503. * @param index Defines the position to register the step in
  11504. * @param component Defines the component attached to the step
  11505. * @param action Defines the action to launch during the step
  11506. */
  11507. registerStep(index: number, component: ISceneComponent, action: T): void;
  11508. /**
  11509. * Clears all the steps from the stage.
  11510. */
  11511. clear(): void;
  11512. }
  11513. }
  11514. declare module BABYLON {
  11515. interface Scene {
  11516. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  11517. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  11518. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  11519. /**
  11520. * All of the sprite managers added to this scene
  11521. * @see http://doc.babylonjs.com/babylon101/sprites
  11522. */
  11523. spriteManagers: Array<ISpriteManager>;
  11524. /**
  11525. * An event triggered when sprites rendering is about to start
  11526. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11527. */
  11528. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11529. /**
  11530. * An event triggered when sprites rendering is done
  11531. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11532. */
  11533. onAfterSpritesRenderingObservable: Observable<Scene>;
  11534. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11535. /** Launch a ray to try to pick a sprite in the scene
  11536. * @param x position on screen
  11537. * @param y position on screen
  11538. * @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
  11539. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11540. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11541. * @returns a PickingInfo
  11542. */
  11543. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11544. /** Use the given ray to pick a sprite in the scene
  11545. * @param ray The ray (in world space) to use to pick meshes
  11546. * @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
  11547. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11548. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11549. * @returns a PickingInfo
  11550. */
  11551. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11552. /**
  11553. * Force the sprite under the pointer
  11554. * @param sprite defines the sprite to use
  11555. */
  11556. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11557. /**
  11558. * Gets the sprite under the pointer
  11559. * @returns a Sprite or null if no sprite is under the pointer
  11560. */
  11561. getPointerOverSprite(): Nullable<Sprite>;
  11562. }
  11563. /**
  11564. * Defines the sprite scene component responsible to manage sprites
  11565. * in a given scene.
  11566. */
  11567. export class SpriteSceneComponent implements ISceneComponent {
  11568. /**
  11569. * The component name helpfull to identify the component in the list of scene components.
  11570. */
  11571. readonly name: string;
  11572. /**
  11573. * The scene the component belongs to.
  11574. */
  11575. scene: Scene;
  11576. /** @hidden */
  11577. private _spritePredicate;
  11578. /**
  11579. * Creates a new instance of the component for the given scene
  11580. * @param scene Defines the scene to register the component in
  11581. */
  11582. constructor(scene: Scene);
  11583. /**
  11584. * Registers the component in a given scene
  11585. */
  11586. register(): void;
  11587. /**
  11588. * Rebuilds the elements related to this component in case of
  11589. * context lost for instance.
  11590. */
  11591. rebuild(): void;
  11592. /**
  11593. * Disposes the component and the associated ressources.
  11594. */
  11595. dispose(): void;
  11596. private _pickSpriteButKeepRay;
  11597. private _pointerMove;
  11598. private _pointerDown;
  11599. private _pointerUp;
  11600. }
  11601. }
  11602. declare module BABYLON {
  11603. /** @hidden */
  11604. export var fogFragmentDeclaration: {
  11605. name: string;
  11606. shader: string;
  11607. };
  11608. }
  11609. declare module BABYLON {
  11610. /** @hidden */
  11611. export var fogFragment: {
  11612. name: string;
  11613. shader: string;
  11614. };
  11615. }
  11616. declare module BABYLON {
  11617. /** @hidden */
  11618. export var spritesPixelShader: {
  11619. name: string;
  11620. shader: string;
  11621. };
  11622. }
  11623. declare module BABYLON {
  11624. /** @hidden */
  11625. export var fogVertexDeclaration: {
  11626. name: string;
  11627. shader: string;
  11628. };
  11629. }
  11630. declare module BABYLON {
  11631. /** @hidden */
  11632. export var spritesVertexShader: {
  11633. name: string;
  11634. shader: string;
  11635. };
  11636. }
  11637. declare module BABYLON {
  11638. /**
  11639. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11640. */
  11641. export interface ISpriteManager extends IDisposable {
  11642. /**
  11643. * Restricts the camera to viewing objects with the same layerMask.
  11644. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11645. */
  11646. layerMask: number;
  11647. /**
  11648. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11649. */
  11650. isPickable: boolean;
  11651. /**
  11652. * Specifies the rendering group id for this mesh (0 by default)
  11653. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11654. */
  11655. renderingGroupId: number;
  11656. /**
  11657. * Defines the list of sprites managed by the manager.
  11658. */
  11659. sprites: Array<Sprite>;
  11660. /**
  11661. * Tests the intersection of a sprite with a specific ray.
  11662. * @param ray The ray we are sending to test the collision
  11663. * @param camera The camera space we are sending rays in
  11664. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11665. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11666. * @returns picking info or null.
  11667. */
  11668. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11669. /**
  11670. * Renders the list of sprites on screen.
  11671. */
  11672. render(): void;
  11673. }
  11674. /**
  11675. * Class used to manage multiple sprites on the same spritesheet
  11676. * @see http://doc.babylonjs.com/babylon101/sprites
  11677. */
  11678. export class SpriteManager implements ISpriteManager {
  11679. /** defines the manager's name */
  11680. name: string;
  11681. /** Gets the list of sprites */
  11682. sprites: Sprite[];
  11683. /** Gets or sets the rendering group id (0 by default) */
  11684. renderingGroupId: number;
  11685. /** Gets or sets camera layer mask */
  11686. layerMask: number;
  11687. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11688. fogEnabled: boolean;
  11689. /** Gets or sets a boolean indicating if the sprites are pickable */
  11690. isPickable: boolean;
  11691. /** Defines the default width of a cell in the spritesheet */
  11692. cellWidth: number;
  11693. /** Defines the default height of a cell in the spritesheet */
  11694. cellHeight: number;
  11695. /**
  11696. * An event triggered when the manager is disposed.
  11697. */
  11698. onDisposeObservable: Observable<SpriteManager>;
  11699. private _onDisposeObserver;
  11700. /**
  11701. * Callback called when the manager is disposed
  11702. */
  11703. onDispose: () => void;
  11704. private _capacity;
  11705. private _spriteTexture;
  11706. private _epsilon;
  11707. private _scene;
  11708. private _vertexData;
  11709. private _buffer;
  11710. private _vertexBuffers;
  11711. private _indexBuffer;
  11712. private _effectBase;
  11713. private _effectFog;
  11714. /**
  11715. * Gets or sets the spritesheet texture
  11716. */
  11717. texture: Texture;
  11718. /**
  11719. * Creates a new sprite manager
  11720. * @param name defines the manager's name
  11721. * @param imgUrl defines the sprite sheet url
  11722. * @param capacity defines the maximum allowed number of sprites
  11723. * @param cellSize defines the size of a sprite cell
  11724. * @param scene defines the hosting scene
  11725. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11726. * @param samplingMode defines the smapling mode to use with spritesheet
  11727. */
  11728. constructor(
  11729. /** defines the manager's name */
  11730. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11731. private _appendSpriteVertex;
  11732. /**
  11733. * Intersects the sprites with a ray
  11734. * @param ray defines the ray to intersect with
  11735. * @param camera defines the current active camera
  11736. * @param predicate defines a predicate used to select candidate sprites
  11737. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11738. * @returns null if no hit or a PickingInfo
  11739. */
  11740. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11741. /**
  11742. * Render all child sprites
  11743. */
  11744. render(): void;
  11745. /**
  11746. * Release associated resources
  11747. */
  11748. dispose(): void;
  11749. }
  11750. }
  11751. declare module BABYLON {
  11752. /**
  11753. * Class used to represent a sprite
  11754. * @see http://doc.babylonjs.com/babylon101/sprites
  11755. */
  11756. export class Sprite {
  11757. /** defines the name */
  11758. name: string;
  11759. /** Gets or sets the current world position */
  11760. position: Vector3;
  11761. /** Gets or sets the main color */
  11762. color: Color4;
  11763. /** Gets or sets the width */
  11764. width: number;
  11765. /** Gets or sets the height */
  11766. height: number;
  11767. /** Gets or sets rotation angle */
  11768. angle: number;
  11769. /** Gets or sets the cell index in the sprite sheet */
  11770. cellIndex: number;
  11771. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11772. invertU: number;
  11773. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11774. invertV: number;
  11775. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11776. disposeWhenFinishedAnimating: boolean;
  11777. /** Gets the list of attached animations */
  11778. animations: Animation[];
  11779. /** Gets or sets a boolean indicating if the sprite can be picked */
  11780. isPickable: boolean;
  11781. /**
  11782. * Gets or sets the associated action manager
  11783. */
  11784. actionManager: Nullable<ActionManager>;
  11785. private _animationStarted;
  11786. private _loopAnimation;
  11787. private _fromIndex;
  11788. private _toIndex;
  11789. private _delay;
  11790. private _direction;
  11791. private _manager;
  11792. private _time;
  11793. private _onAnimationEnd;
  11794. /**
  11795. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11796. */
  11797. isVisible: boolean;
  11798. /**
  11799. * Gets or sets the sprite size
  11800. */
  11801. size: number;
  11802. /**
  11803. * Creates a new Sprite
  11804. * @param name defines the name
  11805. * @param manager defines the manager
  11806. */
  11807. constructor(
  11808. /** defines the name */
  11809. name: string, manager: ISpriteManager);
  11810. /**
  11811. * Starts an animation
  11812. * @param from defines the initial key
  11813. * @param to defines the end key
  11814. * @param loop defines if the animation must loop
  11815. * @param delay defines the start delay (in ms)
  11816. * @param onAnimationEnd defines a callback to call when animation ends
  11817. */
  11818. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11819. /** Stops current animation (if any) */
  11820. stopAnimation(): void;
  11821. /** @hidden */ animate(deltaTime: number): void;
  11822. /** Release associated resources */
  11823. dispose(): void;
  11824. }
  11825. }
  11826. declare module BABYLON {
  11827. /**
  11828. * Information about the result of picking within a scene
  11829. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11830. */
  11831. export class PickingInfo {
  11832. /** @hidden */ pickingUnavailable: boolean;
  11833. /**
  11834. * If the pick collided with an object
  11835. */
  11836. hit: boolean;
  11837. /**
  11838. * Distance away where the pick collided
  11839. */
  11840. distance: number;
  11841. /**
  11842. * The location of pick collision
  11843. */
  11844. pickedPoint: Nullable<Vector3>;
  11845. /**
  11846. * The mesh corresponding the the pick collision
  11847. */
  11848. pickedMesh: Nullable<AbstractMesh>;
  11849. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11850. bu: number;
  11851. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11852. bv: number;
  11853. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11854. faceId: number;
  11855. /** Id of the the submesh that was picked */
  11856. subMeshId: number;
  11857. /** If a sprite was picked, this will be the sprite the pick collided with */
  11858. pickedSprite: Nullable<Sprite>;
  11859. /**
  11860. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11861. */
  11862. originMesh: Nullable<AbstractMesh>;
  11863. /**
  11864. * The ray that was used to perform the picking.
  11865. */
  11866. ray: Nullable<Ray>;
  11867. /**
  11868. * Gets the normal correspodning to the face the pick collided with
  11869. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11870. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11871. * @returns The normal correspodning to the face the pick collided with
  11872. */
  11873. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11874. /**
  11875. * Gets the texture coordinates of where the pick occured
  11876. * @returns the vector containing the coordnates of the texture
  11877. */
  11878. getTextureCoordinates(): Nullable<Vector2>;
  11879. }
  11880. }
  11881. declare module BABYLON {
  11882. /**
  11883. * Gather the list of pointer event types as constants.
  11884. */
  11885. export class PointerEventTypes {
  11886. /**
  11887. * 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.
  11888. */
  11889. static readonly POINTERDOWN: number;
  11890. /**
  11891. * The pointerup event is fired when a pointer is no longer active.
  11892. */
  11893. static readonly POINTERUP: number;
  11894. /**
  11895. * The pointermove event is fired when a pointer changes coordinates.
  11896. */
  11897. static readonly POINTERMOVE: number;
  11898. /**
  11899. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11900. */
  11901. static readonly POINTERWHEEL: number;
  11902. /**
  11903. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11904. */
  11905. static readonly POINTERPICK: number;
  11906. /**
  11907. * The pointertap event is fired when a the object has been touched and released without drag.
  11908. */
  11909. static readonly POINTERTAP: number;
  11910. /**
  11911. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11912. */
  11913. static readonly POINTERDOUBLETAP: number;
  11914. }
  11915. /**
  11916. * Base class of pointer info types.
  11917. */
  11918. export class PointerInfoBase {
  11919. /**
  11920. * Defines the type of event (PointerEventTypes)
  11921. */
  11922. type: number;
  11923. /**
  11924. * Defines the related dom event
  11925. */
  11926. event: PointerEvent | MouseWheelEvent;
  11927. /**
  11928. * Instantiates the base class of pointers info.
  11929. * @param type Defines the type of event (PointerEventTypes)
  11930. * @param event Defines the related dom event
  11931. */
  11932. constructor(
  11933. /**
  11934. * Defines the type of event (PointerEventTypes)
  11935. */
  11936. type: number,
  11937. /**
  11938. * Defines the related dom event
  11939. */
  11940. event: PointerEvent | MouseWheelEvent);
  11941. }
  11942. /**
  11943. * This class is used to store pointer related info for the onPrePointerObservable event.
  11944. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11945. */
  11946. export class PointerInfoPre extends PointerInfoBase {
  11947. /**
  11948. * Ray from a pointer if availible (eg. 6dof controller)
  11949. */
  11950. ray: Nullable<Ray>;
  11951. /**
  11952. * Defines the local position of the pointer on the canvas.
  11953. */
  11954. localPosition: Vector2;
  11955. /**
  11956. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11957. */
  11958. skipOnPointerObservable: boolean;
  11959. /**
  11960. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11961. * @param type Defines the type of event (PointerEventTypes)
  11962. * @param event Defines the related dom event
  11963. * @param localX Defines the local x coordinates of the pointer when the event occured
  11964. * @param localY Defines the local y coordinates of the pointer when the event occured
  11965. */
  11966. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11967. }
  11968. /**
  11969. * This type contains all the data related to a pointer event in Babylon.js.
  11970. * 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.
  11971. */
  11972. export class PointerInfo extends PointerInfoBase {
  11973. /**
  11974. * Defines the picking info associated to the info (if any)\
  11975. */
  11976. pickInfo: Nullable<PickingInfo>;
  11977. /**
  11978. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11979. * @param type Defines the type of event (PointerEventTypes)
  11980. * @param event Defines the related dom event
  11981. * @param pickInfo Defines the picking info associated to the info (if any)\
  11982. */
  11983. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11984. /**
  11985. * Defines the picking info associated to the info (if any)\
  11986. */
  11987. pickInfo: Nullable<PickingInfo>);
  11988. }
  11989. /**
  11990. * Data relating to a touch event on the screen.
  11991. */
  11992. export interface PointerTouch {
  11993. /**
  11994. * X coordinate of touch.
  11995. */
  11996. x: number;
  11997. /**
  11998. * Y coordinate of touch.
  11999. */
  12000. y: number;
  12001. /**
  12002. * Id of touch. Unique for each finger.
  12003. */
  12004. pointerId: number;
  12005. /**
  12006. * Event type passed from DOM.
  12007. */
  12008. type: any;
  12009. }
  12010. }
  12011. declare module BABYLON {
  12012. /**
  12013. * Manage the mouse inputs to control the movement of a free camera.
  12014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12015. */
  12016. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12017. /**
  12018. * Define if touch is enabled in the mouse input
  12019. */
  12020. touchEnabled: boolean;
  12021. /**
  12022. * Defines the camera the input is attached to.
  12023. */
  12024. camera: FreeCamera;
  12025. /**
  12026. * Defines the buttons associated with the input to handle camera move.
  12027. */
  12028. buttons: number[];
  12029. /**
  12030. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12031. */
  12032. angularSensibility: number;
  12033. private _pointerInput;
  12034. private _onMouseMove;
  12035. private _observer;
  12036. private previousPosition;
  12037. /**
  12038. * Observable for when a pointer move event occurs containing the move offset
  12039. */
  12040. onPointerMovedObservable: Observable<{
  12041. offsetX: number;
  12042. offsetY: number;
  12043. }>;
  12044. /**
  12045. * @hidden
  12046. * If the camera should be rotated automatically based on pointer movement
  12047. */ allowCameraRotation: boolean;
  12048. /**
  12049. * Manage the mouse inputs to control the movement of a free camera.
  12050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12051. * @param touchEnabled Defines if touch is enabled or not
  12052. */
  12053. constructor(
  12054. /**
  12055. * Define if touch is enabled in the mouse input
  12056. */
  12057. touchEnabled?: boolean);
  12058. /**
  12059. * Attach the input controls to a specific dom element to get the input from.
  12060. * @param element Defines the element the controls should be listened from
  12061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12062. */
  12063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12064. /**
  12065. * Called on JS contextmenu event.
  12066. * Override this method to provide functionality.
  12067. */
  12068. protected onContextMenu(evt: PointerEvent): void;
  12069. /**
  12070. * Detach the current controls from the specified dom element.
  12071. * @param element Defines the element to stop listening the inputs from
  12072. */
  12073. detachControl(element: Nullable<HTMLElement>): void;
  12074. /**
  12075. * Gets the class name of the current intput.
  12076. * @returns the class name
  12077. */
  12078. getClassName(): string;
  12079. /**
  12080. * Get the friendly name associated with the input class.
  12081. * @returns the input friendly name
  12082. */
  12083. getSimpleName(): string;
  12084. }
  12085. }
  12086. declare module BABYLON {
  12087. /**
  12088. * Manage the touch inputs to control the movement of a free camera.
  12089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12090. */
  12091. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12092. /**
  12093. * Defines the camera the input is attached to.
  12094. */
  12095. camera: FreeCamera;
  12096. /**
  12097. * Defines the touch sensibility for rotation.
  12098. * The higher the faster.
  12099. */
  12100. touchAngularSensibility: number;
  12101. /**
  12102. * Defines the touch sensibility for move.
  12103. * The higher the faster.
  12104. */
  12105. touchMoveSensibility: number;
  12106. private _offsetX;
  12107. private _offsetY;
  12108. private _pointerPressed;
  12109. private _pointerInput;
  12110. private _observer;
  12111. private _onLostFocus;
  12112. /**
  12113. * Attach the input controls to a specific dom element to get the input from.
  12114. * @param element Defines the element the controls should be listened from
  12115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12116. */
  12117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12118. /**
  12119. * Detach the current controls from the specified dom element.
  12120. * @param element Defines the element to stop listening the inputs from
  12121. */
  12122. detachControl(element: Nullable<HTMLElement>): void;
  12123. /**
  12124. * Update the current camera state depending on the inputs that have been used this frame.
  12125. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12126. */
  12127. checkInputs(): void;
  12128. /**
  12129. * Gets the class name of the current intput.
  12130. * @returns the class name
  12131. */
  12132. getClassName(): string;
  12133. /**
  12134. * Get the friendly name associated with the input class.
  12135. * @returns the input friendly name
  12136. */
  12137. getSimpleName(): string;
  12138. }
  12139. }
  12140. declare module BABYLON {
  12141. /**
  12142. * Default Inputs manager for the FreeCamera.
  12143. * It groups all the default supported inputs for ease of use.
  12144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12145. */
  12146. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12147. /**
  12148. * @hidden
  12149. */ keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12150. /**
  12151. * @hidden
  12152. */ mouseInput: Nullable<FreeCameraMouseInput>;
  12153. /**
  12154. * Instantiates a new FreeCameraInputsManager.
  12155. * @param camera Defines the camera the inputs belong to
  12156. */
  12157. constructor(camera: FreeCamera);
  12158. /**
  12159. * Add keyboard input support to the input manager.
  12160. * @returns the current input manager
  12161. */
  12162. addKeyboard(): FreeCameraInputsManager;
  12163. /**
  12164. * Add mouse input support to the input manager.
  12165. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12166. * @returns the current input manager
  12167. */
  12168. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12169. /**
  12170. * Removes the mouse input support from the manager
  12171. * @returns the current input manager
  12172. */
  12173. removeMouse(): FreeCameraInputsManager;
  12174. /**
  12175. * Add touch input support to the input manager.
  12176. * @returns the current input manager
  12177. */
  12178. addTouch(): FreeCameraInputsManager;
  12179. }
  12180. }
  12181. declare module BABYLON {
  12182. /**
  12183. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12184. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12185. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12186. */
  12187. export class FreeCamera extends TargetCamera {
  12188. /**
  12189. * Define the collision ellipsoid of the camera.
  12190. * This is helpful to simulate a camera body like the player body around the camera
  12191. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12192. */
  12193. ellipsoid: Vector3;
  12194. /**
  12195. * Define an offset for the position of the ellipsoid around the camera.
  12196. * This can be helpful to determine the center of the body near the gravity center of the body
  12197. * instead of its head.
  12198. */
  12199. ellipsoidOffset: Vector3;
  12200. /**
  12201. * Enable or disable collisions of the camera with the rest of the scene objects.
  12202. */
  12203. checkCollisions: boolean;
  12204. /**
  12205. * Enable or disable gravity on the camera.
  12206. */
  12207. applyGravity: boolean;
  12208. /**
  12209. * Define the input manager associated to the camera.
  12210. */
  12211. inputs: FreeCameraInputsManager;
  12212. /**
  12213. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12214. * Higher values reduce sensitivity.
  12215. */
  12216. /**
  12217. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12218. * Higher values reduce sensitivity.
  12219. */
  12220. angularSensibility: number;
  12221. /**
  12222. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12223. */
  12224. keysUp: number[];
  12225. /**
  12226. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12227. */
  12228. keysDown: number[];
  12229. /**
  12230. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12231. */
  12232. keysLeft: number[];
  12233. /**
  12234. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12235. */
  12236. keysRight: number[];
  12237. /**
  12238. * Event raised when the camera collide with a mesh in the scene.
  12239. */
  12240. onCollide: (collidedMesh: AbstractMesh) => void;
  12241. private _collider;
  12242. private _needMoveForGravity;
  12243. private _oldPosition;
  12244. private _diffPosition;
  12245. private _newPosition;
  12246. /** @hidden */ localDirection: Vector3;
  12247. /** @hidden */ transformedDirection: Vector3;
  12248. /**
  12249. * Instantiates a Free Camera.
  12250. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12251. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12253. * @param name Define the name of the camera in the scene
  12254. * @param position Define the start position of the camera in the scene
  12255. * @param scene Define the scene the camera belongs to
  12256. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12257. */
  12258. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12259. /**
  12260. * Attached controls to the current camera.
  12261. * @param element Defines the element the controls should be listened from
  12262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12263. */
  12264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12265. /**
  12266. * Detach the current controls from the camera.
  12267. * The camera will stop reacting to inputs.
  12268. * @param element Defines the element to stop listening the inputs from
  12269. */
  12270. detachControl(element: HTMLElement): void;
  12271. private _collisionMask;
  12272. /**
  12273. * Define a collision mask to limit the list of object the camera can collide with
  12274. */
  12275. collisionMask: number;
  12276. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  12277. private _onCollisionPositionChange;
  12278. /** @hidden */ checkInputs(): void;
  12279. /** @hidden */ decideIfNeedsToMove(): boolean;
  12280. /** @hidden */ updatePosition(): void;
  12281. /**
  12282. * Destroy the camera and release the current resources hold by it.
  12283. */
  12284. dispose(): void;
  12285. /**
  12286. * Gets the current object class name.
  12287. * @return the class name
  12288. */
  12289. getClassName(): string;
  12290. }
  12291. }
  12292. declare module BABYLON {
  12293. /**
  12294. * Represents a gamepad control stick position
  12295. */
  12296. export class StickValues {
  12297. /**
  12298. * The x component of the control stick
  12299. */
  12300. x: number;
  12301. /**
  12302. * The y component of the control stick
  12303. */
  12304. y: number;
  12305. /**
  12306. * Initializes the gamepad x and y control stick values
  12307. * @param x The x component of the gamepad control stick value
  12308. * @param y The y component of the gamepad control stick value
  12309. */
  12310. constructor(
  12311. /**
  12312. * The x component of the control stick
  12313. */
  12314. x: number,
  12315. /**
  12316. * The y component of the control stick
  12317. */
  12318. y: number);
  12319. }
  12320. /**
  12321. * An interface which manages callbacks for gamepad button changes
  12322. */
  12323. export interface GamepadButtonChanges {
  12324. /**
  12325. * Called when a gamepad has been changed
  12326. */
  12327. changed: boolean;
  12328. /**
  12329. * Called when a gamepad press event has been triggered
  12330. */
  12331. pressChanged: boolean;
  12332. /**
  12333. * Called when a touch event has been triggered
  12334. */
  12335. touchChanged: boolean;
  12336. /**
  12337. * Called when a value has changed
  12338. */
  12339. valueChanged: boolean;
  12340. }
  12341. /**
  12342. * Represents a gamepad
  12343. */
  12344. export class Gamepad {
  12345. /**
  12346. * The id of the gamepad
  12347. */
  12348. id: string;
  12349. /**
  12350. * The index of the gamepad
  12351. */
  12352. index: number;
  12353. /**
  12354. * The browser gamepad
  12355. */
  12356. browserGamepad: any;
  12357. /**
  12358. * Specifies what type of gamepad this represents
  12359. */
  12360. type: number;
  12361. private _leftStick;
  12362. private _rightStick;
  12363. /** @hidden */ isConnected: boolean;
  12364. private _leftStickAxisX;
  12365. private _leftStickAxisY;
  12366. private _rightStickAxisX;
  12367. private _rightStickAxisY;
  12368. /**
  12369. * Triggered when the left control stick has been changed
  12370. */
  12371. private _onleftstickchanged;
  12372. /**
  12373. * Triggered when the right control stick has been changed
  12374. */
  12375. private _onrightstickchanged;
  12376. /**
  12377. * Represents a gamepad controller
  12378. */
  12379. static GAMEPAD: number;
  12380. /**
  12381. * Represents a generic controller
  12382. */
  12383. static GENERIC: number;
  12384. /**
  12385. * Represents an XBox controller
  12386. */
  12387. static XBOX: number;
  12388. /**
  12389. * Represents a pose-enabled controller
  12390. */
  12391. static POSE_ENABLED: number;
  12392. /**
  12393. * Specifies whether the left control stick should be Y-inverted
  12394. */
  12395. protected _invertLeftStickY: boolean;
  12396. /**
  12397. * Specifies if the gamepad has been connected
  12398. */
  12399. readonly isConnected: boolean;
  12400. /**
  12401. * Initializes the gamepad
  12402. * @param id The id of the gamepad
  12403. * @param index The index of the gamepad
  12404. * @param browserGamepad The browser gamepad
  12405. * @param leftStickX The x component of the left joystick
  12406. * @param leftStickY The y component of the left joystick
  12407. * @param rightStickX The x component of the right joystick
  12408. * @param rightStickY The y component of the right joystick
  12409. */
  12410. constructor(
  12411. /**
  12412. * The id of the gamepad
  12413. */
  12414. id: string,
  12415. /**
  12416. * The index of the gamepad
  12417. */
  12418. index: number,
  12419. /**
  12420. * The browser gamepad
  12421. */
  12422. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12423. /**
  12424. * Callback triggered when the left joystick has changed
  12425. * @param callback
  12426. */
  12427. onleftstickchanged(callback: (values: StickValues) => void): void;
  12428. /**
  12429. * Callback triggered when the right joystick has changed
  12430. * @param callback
  12431. */
  12432. onrightstickchanged(callback: (values: StickValues) => void): void;
  12433. /**
  12434. * Gets the left joystick
  12435. */
  12436. /**
  12437. * Sets the left joystick values
  12438. */
  12439. leftStick: StickValues;
  12440. /**
  12441. * Gets the right joystick
  12442. */
  12443. /**
  12444. * Sets the right joystick value
  12445. */
  12446. rightStick: StickValues;
  12447. /**
  12448. * Updates the gamepad joystick positions
  12449. */
  12450. update(): void;
  12451. /**
  12452. * Disposes the gamepad
  12453. */
  12454. dispose(): void;
  12455. }
  12456. /**
  12457. * Represents a generic gamepad
  12458. */
  12459. export class GenericPad extends Gamepad {
  12460. private _buttons;
  12461. private _onbuttondown;
  12462. private _onbuttonup;
  12463. /**
  12464. * Observable triggered when a button has been pressed
  12465. */
  12466. onButtonDownObservable: Observable<number>;
  12467. /**
  12468. * Observable triggered when a button has been released
  12469. */
  12470. onButtonUpObservable: Observable<number>;
  12471. /**
  12472. * Callback triggered when a button has been pressed
  12473. * @param callback Called when a button has been pressed
  12474. */
  12475. onbuttondown(callback: (buttonPressed: number) => void): void;
  12476. /**
  12477. * Callback triggered when a button has been released
  12478. * @param callback Called when a button has been released
  12479. */
  12480. onbuttonup(callback: (buttonReleased: number) => void): void;
  12481. /**
  12482. * Initializes the generic gamepad
  12483. * @param id The id of the generic gamepad
  12484. * @param index The index of the generic gamepad
  12485. * @param browserGamepad The browser gamepad
  12486. */
  12487. constructor(id: string, index: number, browserGamepad: any);
  12488. private _setButtonValue;
  12489. /**
  12490. * Updates the generic gamepad
  12491. */
  12492. update(): void;
  12493. /**
  12494. * Disposes the generic gamepad
  12495. */
  12496. dispose(): void;
  12497. }
  12498. }
  12499. declare module BABYLON {
  12500. /**
  12501. * Defines the types of pose enabled controllers that are supported
  12502. */
  12503. export enum PoseEnabledControllerType {
  12504. /**
  12505. * HTC Vive
  12506. */
  12507. VIVE = 0,
  12508. /**
  12509. * Oculus Rift
  12510. */
  12511. OCULUS = 1,
  12512. /**
  12513. * Windows mixed reality
  12514. */
  12515. WINDOWS = 2,
  12516. /**
  12517. * Samsung gear VR
  12518. */
  12519. GEAR_VR = 3,
  12520. /**
  12521. * Google Daydream
  12522. */
  12523. DAYDREAM = 4,
  12524. /**
  12525. * Generic
  12526. */
  12527. GENERIC = 5
  12528. }
  12529. /**
  12530. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12531. */
  12532. export interface MutableGamepadButton {
  12533. /**
  12534. * Value of the button/trigger
  12535. */
  12536. value: number;
  12537. /**
  12538. * If the button/trigger is currently touched
  12539. */
  12540. touched: boolean;
  12541. /**
  12542. * If the button/trigger is currently pressed
  12543. */
  12544. pressed: boolean;
  12545. }
  12546. /**
  12547. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12548. * @hidden
  12549. */
  12550. export interface ExtendedGamepadButton extends GamepadButton {
  12551. /**
  12552. * If the button/trigger is currently pressed
  12553. */
  12554. readonly pressed: boolean;
  12555. /**
  12556. * If the button/trigger is currently touched
  12557. */
  12558. readonly touched: boolean;
  12559. /**
  12560. * Value of the button/trigger
  12561. */
  12562. readonly value: number;
  12563. }
  12564. /** @hidden */
  12565. export interface _GamePadFactory {
  12566. /**
  12567. * Returns wether or not the current gamepad can be created for this type of controller.
  12568. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12569. * @returns true if it can be created, otherwise false
  12570. */
  12571. canCreate(gamepadInfo: any): boolean;
  12572. /**
  12573. * Creates a new instance of the Gamepad.
  12574. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12575. * @returns the new gamepad instance
  12576. */
  12577. create(gamepadInfo: any): Gamepad;
  12578. }
  12579. /**
  12580. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12581. */
  12582. export class PoseEnabledControllerHelper {
  12583. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12584. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12585. /**
  12586. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12587. * @param vrGamepad the gamepad to initialized
  12588. * @returns a vr controller of the type the gamepad identified as
  12589. */
  12590. static InitiateController(vrGamepad: any): Gamepad;
  12591. }
  12592. /**
  12593. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12594. */
  12595. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12596. private _deviceRoomPosition;
  12597. private _deviceRoomRotationQuaternion;
  12598. /**
  12599. * The device position in babylon space
  12600. */
  12601. devicePosition: Vector3;
  12602. /**
  12603. * The device rotation in babylon space
  12604. */
  12605. deviceRotationQuaternion: Quaternion;
  12606. /**
  12607. * The scale factor of the device in babylon space
  12608. */
  12609. deviceScaleFactor: number;
  12610. /**
  12611. * (Likely devicePosition should be used instead) The device position in its room space
  12612. */
  12613. position: Vector3;
  12614. /**
  12615. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12616. */
  12617. rotationQuaternion: Quaternion;
  12618. /**
  12619. * The type of controller (Eg. Windows mixed reality)
  12620. */
  12621. controllerType: PoseEnabledControllerType;
  12622. protected _calculatedPosition: Vector3;
  12623. private _calculatedRotation;
  12624. /**
  12625. * The raw pose from the device
  12626. */
  12627. rawPose: DevicePose;
  12628. private _trackPosition;
  12629. private _maxRotationDistFromHeadset;
  12630. private _draggedRoomRotation;
  12631. /**
  12632. * @hidden
  12633. */ disableTrackPosition(fixedPosition: Vector3): void;
  12634. /**
  12635. * Internal, the mesh attached to the controller
  12636. * @hidden
  12637. */ mesh: Nullable<AbstractMesh>;
  12638. private _poseControlledCamera;
  12639. private _leftHandSystemQuaternion;
  12640. /**
  12641. * Internal, matrix used to convert room space to babylon space
  12642. * @hidden
  12643. */ deviceToWorld: Matrix;
  12644. /**
  12645. * Node to be used when casting a ray from the controller
  12646. * @hidden
  12647. */ pointingPoseNode: Nullable<TransformNode>;
  12648. /**
  12649. * Name of the child mesh that can be used to cast a ray from the controller
  12650. */
  12651. static readonly POINTING_POSE: string;
  12652. /**
  12653. * Creates a new PoseEnabledController from a gamepad
  12654. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12655. */
  12656. constructor(browserGamepad: any);
  12657. private _workingMatrix;
  12658. /**
  12659. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12660. */
  12661. update(): void;
  12662. /**
  12663. * Updates only the pose device and mesh without doing any button event checking
  12664. */
  12665. protected _updatePoseAndMesh(): void;
  12666. /**
  12667. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12668. * @param poseData raw pose fromthe device
  12669. */
  12670. updateFromDevice(poseData: DevicePose): void;
  12671. /**
  12672. * @hidden
  12673. */ meshAttachedObservable: Observable<AbstractMesh>;
  12674. /**
  12675. * Attaches a mesh to the controller
  12676. * @param mesh the mesh to be attached
  12677. */
  12678. attachToMesh(mesh: AbstractMesh): void;
  12679. /**
  12680. * Attaches the controllers mesh to a camera
  12681. * @param camera the camera the mesh should be attached to
  12682. */
  12683. attachToPoseControlledCamera(camera: TargetCamera): void;
  12684. /**
  12685. * Disposes of the controller
  12686. */
  12687. dispose(): void;
  12688. /**
  12689. * The mesh that is attached to the controller
  12690. */
  12691. readonly mesh: Nullable<AbstractMesh>;
  12692. /**
  12693. * Gets the ray of the controller in the direction the controller is pointing
  12694. * @param length the length the resulting ray should be
  12695. * @returns a ray in the direction the controller is pointing
  12696. */
  12697. getForwardRay(length?: number): Ray;
  12698. }
  12699. }
  12700. declare module BABYLON {
  12701. /**
  12702. * Defines the WebVRController object that represents controllers tracked in 3D space
  12703. */
  12704. export abstract class WebVRController extends PoseEnabledController {
  12705. /**
  12706. * Internal, the default controller model for the controller
  12707. */
  12708. protected _defaultModel: AbstractMesh;
  12709. /**
  12710. * Fired when the trigger state has changed
  12711. */
  12712. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12713. /**
  12714. * Fired when the main button state has changed
  12715. */
  12716. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12717. /**
  12718. * Fired when the secondary button state has changed
  12719. */
  12720. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12721. /**
  12722. * Fired when the pad state has changed
  12723. */
  12724. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12725. /**
  12726. * Fired when controllers stick values have changed
  12727. */
  12728. onPadValuesChangedObservable: Observable<StickValues>;
  12729. /**
  12730. * Array of button availible on the controller
  12731. */
  12732. protected _buttons: Array<MutableGamepadButton>;
  12733. private _onButtonStateChange;
  12734. /**
  12735. * Fired when a controller button's state has changed
  12736. * @param callback the callback containing the button that was modified
  12737. */
  12738. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12739. /**
  12740. * X and Y axis corrisponding to the controllers joystick
  12741. */
  12742. pad: StickValues;
  12743. /**
  12744. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12745. */
  12746. hand: string;
  12747. /**
  12748. * The default controller model for the controller
  12749. */
  12750. readonly defaultModel: AbstractMesh;
  12751. /**
  12752. * Creates a new WebVRController from a gamepad
  12753. * @param vrGamepad the gamepad that the WebVRController should be created from
  12754. */
  12755. constructor(vrGamepad: any);
  12756. /**
  12757. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12758. */
  12759. update(): void;
  12760. /**
  12761. * Function to be called when a button is modified
  12762. */
  12763. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12764. /**
  12765. * Loads a mesh and attaches it to the controller
  12766. * @param scene the scene the mesh should be added to
  12767. * @param meshLoaded callback for when the mesh has been loaded
  12768. */
  12769. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12770. private _setButtonValue;
  12771. private _changes;
  12772. private _checkChanges;
  12773. /**
  12774. * Disposes of th webVRCOntroller
  12775. */
  12776. dispose(): void;
  12777. }
  12778. }
  12779. declare module BABYLON {
  12780. /**
  12781. * The HemisphericLight simulates the ambient environment light,
  12782. * so the passed direction is the light reflection direction, not the incoming direction.
  12783. */
  12784. export class HemisphericLight extends Light {
  12785. /**
  12786. * The groundColor is the light in the opposite direction to the one specified during creation.
  12787. * 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.
  12788. */
  12789. groundColor: Color3;
  12790. /**
  12791. * The light reflection direction, not the incoming direction.
  12792. */
  12793. direction: Vector3;
  12794. /**
  12795. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12796. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12797. * The HemisphericLight can't cast shadows.
  12798. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12799. * @param name The friendly name of the light
  12800. * @param direction The direction of the light reflection
  12801. * @param scene The scene the light belongs to
  12802. */
  12803. constructor(name: string, direction: Vector3, scene: Scene);
  12804. protected _buildUniformLayout(): void;
  12805. /**
  12806. * Returns the string "HemisphericLight".
  12807. * @return The class name
  12808. */
  12809. getClassName(): string;
  12810. /**
  12811. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12812. * Returns the updated direction.
  12813. * @param target The target the direction should point to
  12814. * @return The computed direction
  12815. */
  12816. setDirectionToTarget(target: Vector3): Vector3;
  12817. /**
  12818. * Returns the shadow generator associated to the light.
  12819. * @returns Always null for hemispheric lights because it does not support shadows.
  12820. */
  12821. getShadowGenerator(): Nullable<IShadowGenerator>;
  12822. /**
  12823. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12824. * @param effect The effect to update
  12825. * @param lightIndex The index of the light in the effect to update
  12826. * @returns The hemispheric light
  12827. */
  12828. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12829. /**
  12830. * Computes the world matrix of the node
  12831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12832. * @param useWasUpdatedFlag defines a reserved property
  12833. * @returns the world matrix
  12834. */
  12835. computeWorldMatrix(): Matrix;
  12836. /**
  12837. * Returns the integer 3.
  12838. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12839. */
  12840. getTypeID(): number;
  12841. /**
  12842. * Prepares the list of defines specific to the light type.
  12843. * @param defines the list of defines
  12844. * @param lightIndex defines the index of the light for the effect
  12845. */
  12846. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12847. }
  12848. }
  12849. declare module BABYLON {
  12850. /** @hidden */
  12851. export var vrMultiviewToSingleviewPixelShader: {
  12852. name: string;
  12853. shader: string;
  12854. };
  12855. }
  12856. declare module BABYLON {
  12857. /**
  12858. * Renders to multiple views with a single draw call
  12859. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12860. */
  12861. export class MultiviewRenderTarget extends RenderTargetTexture {
  12862. /**
  12863. * Creates a multiview render target
  12864. * @param scene scene used with the render target
  12865. * @param size the size of the render target (used for each view)
  12866. */
  12867. constructor(scene: Scene, size?: number | {
  12868. width: number;
  12869. height: number;
  12870. } | {
  12871. ratio: number;
  12872. });
  12873. /**
  12874. * @hidden
  12875. * @param faceIndex the face index, if its a cube texture
  12876. */ bindFrameBuffer(faceIndex?: number): void;
  12877. /**
  12878. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12879. * @returns the view count
  12880. */
  12881. getViewCount(): number;
  12882. }
  12883. }
  12884. declare module BABYLON {
  12885. interface Engine {
  12886. /**
  12887. * Creates a new multiview render target
  12888. * @param width defines the width of the texture
  12889. * @param height defines the height of the texture
  12890. * @returns the created multiview texture
  12891. */
  12892. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12893. /**
  12894. * Binds a multiview framebuffer to be drawn to
  12895. * @param multiviewTexture texture to bind
  12896. */
  12897. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12898. }
  12899. interface Camera {
  12900. /**
  12901. * @hidden
  12902. * 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)
  12903. */ useMultiviewToSingleView: boolean;
  12904. /**
  12905. * @hidden
  12906. * 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)
  12907. */ multiviewTexture: Nullable<RenderTargetTexture>;
  12908. /**
  12909. * @hidden
  12910. * ensures the multiview texture of the camera exists and has the specified width/height
  12911. * @param width height to set on the multiview texture
  12912. * @param height width to set on the multiview texture
  12913. */ resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12914. }
  12915. interface Scene {
  12916. /** @hidden */ transformMatrixR: Matrix;
  12917. /** @hidden */ multiviewSceneUbo: Nullable<UniformBuffer>;
  12918. /** @hidden */ createMultiviewUbo(): void;
  12919. /** @hidden */ updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12920. /** @hidden */ renderMultiviewToSingleView(camera: Camera): void;
  12921. }
  12922. }
  12923. declare module BABYLON {
  12924. /**
  12925. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  12926. * This will not be used for webXR as it supports displaying texture arrays directly
  12927. */
  12928. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  12929. /**
  12930. * Initializes a VRMultiviewToSingleview
  12931. * @param name name of the post process
  12932. * @param camera camera to be applied to
  12933. * @param scaleFactor scaling factor to the size of the output texture
  12934. */
  12935. constructor(name: string, camera: Camera, scaleFactor: number);
  12936. }
  12937. }
  12938. declare module BABYLON {
  12939. /**
  12940. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12941. * IMPORTANT!! The data is right-hand data.
  12942. * @export
  12943. * @interface DevicePose
  12944. */
  12945. export interface DevicePose {
  12946. /**
  12947. * The position of the device, values in array are [x,y,z].
  12948. */
  12949. readonly position: Nullable<Float32Array>;
  12950. /**
  12951. * The linearVelocity of the device, values in array are [x,y,z].
  12952. */
  12953. readonly linearVelocity: Nullable<Float32Array>;
  12954. /**
  12955. * The linearAcceleration of the device, values in array are [x,y,z].
  12956. */
  12957. readonly linearAcceleration: Nullable<Float32Array>;
  12958. /**
  12959. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12960. */
  12961. readonly orientation: Nullable<Float32Array>;
  12962. /**
  12963. * The angularVelocity of the device, values in array are [x,y,z].
  12964. */
  12965. readonly angularVelocity: Nullable<Float32Array>;
  12966. /**
  12967. * The angularAcceleration of the device, values in array are [x,y,z].
  12968. */
  12969. readonly angularAcceleration: Nullable<Float32Array>;
  12970. }
  12971. /**
  12972. * Interface representing a pose controlled object in Babylon.
  12973. * A pose controlled object has both regular pose values as well as pose values
  12974. * from an external device such as a VR head mounted display
  12975. */
  12976. export interface PoseControlled {
  12977. /**
  12978. * The position of the object in babylon space.
  12979. */
  12980. position: Vector3;
  12981. /**
  12982. * The rotation quaternion of the object in babylon space.
  12983. */
  12984. rotationQuaternion: Quaternion;
  12985. /**
  12986. * The position of the device in babylon space.
  12987. */
  12988. devicePosition?: Vector3;
  12989. /**
  12990. * The rotation quaternion of the device in babylon space.
  12991. */
  12992. deviceRotationQuaternion: Quaternion;
  12993. /**
  12994. * The raw pose coming from the device.
  12995. */
  12996. rawPose: Nullable<DevicePose>;
  12997. /**
  12998. * The scale of the device to be used when translating from device space to babylon space.
  12999. */
  13000. deviceScaleFactor: number;
  13001. /**
  13002. * Updates the poseControlled values based on the input device pose.
  13003. * @param poseData the pose data to update the object with
  13004. */
  13005. updateFromDevice(poseData: DevicePose): void;
  13006. }
  13007. /**
  13008. * Set of options to customize the webVRCamera
  13009. */
  13010. export interface WebVROptions {
  13011. /**
  13012. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13013. */
  13014. trackPosition?: boolean;
  13015. /**
  13016. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13017. */
  13018. positionScale?: number;
  13019. /**
  13020. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13021. */
  13022. displayName?: string;
  13023. /**
  13024. * Should the native controller meshes be initialized. (default: true)
  13025. */
  13026. controllerMeshes?: boolean;
  13027. /**
  13028. * Creating a default HemiLight only on controllers. (default: true)
  13029. */
  13030. defaultLightingOnControllers?: boolean;
  13031. /**
  13032. * If you don't want to use the default VR button of the helper. (default: false)
  13033. */
  13034. useCustomVRButton?: boolean;
  13035. /**
  13036. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13037. */
  13038. customVRButton?: HTMLButtonElement;
  13039. /**
  13040. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13041. */
  13042. rayLength?: number;
  13043. /**
  13044. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13045. */
  13046. defaultHeight?: number;
  13047. /**
  13048. * If multiview should be used if availible (default: false)
  13049. */
  13050. useMultiview?: boolean;
  13051. }
  13052. /**
  13053. * This represents a WebVR camera.
  13054. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13055. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13056. */
  13057. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13058. private webVROptions;
  13059. /**
  13060. * @hidden
  13061. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13062. */ vrDevice: any;
  13063. /**
  13064. * The rawPose of the vrDevice.
  13065. */
  13066. rawPose: Nullable<DevicePose>;
  13067. private _onVREnabled;
  13068. private _specsVersion;
  13069. private _attached;
  13070. private _frameData;
  13071. protected _descendants: Array<Node>;
  13072. private _deviceRoomPosition;
  13073. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  13074. private _standingMatrix;
  13075. /**
  13076. * Represents device position in babylon space.
  13077. */
  13078. devicePosition: Vector3;
  13079. /**
  13080. * Represents device rotation in babylon space.
  13081. */
  13082. deviceRotationQuaternion: Quaternion;
  13083. /**
  13084. * The scale of the device to be used when translating from device space to babylon space.
  13085. */
  13086. deviceScaleFactor: number;
  13087. private _deviceToWorld;
  13088. private _worldToDevice;
  13089. /**
  13090. * References to the webVR controllers for the vrDevice.
  13091. */
  13092. controllers: Array<WebVRController>;
  13093. /**
  13094. * Emits an event when a controller is attached.
  13095. */
  13096. onControllersAttachedObservable: Observable<WebVRController[]>;
  13097. /**
  13098. * Emits an event when a controller's mesh has been loaded;
  13099. */
  13100. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13101. /**
  13102. * Emits an event when the HMD's pose has been updated.
  13103. */
  13104. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13105. private _poseSet;
  13106. /**
  13107. * If the rig cameras be used as parent instead of this camera.
  13108. */
  13109. rigParenting: boolean;
  13110. private _lightOnControllers;
  13111. private _defaultHeight?;
  13112. /**
  13113. * Instantiates a WebVRFreeCamera.
  13114. * @param name The name of the WebVRFreeCamera
  13115. * @param position The starting anchor position for the camera
  13116. * @param scene The scene the camera belongs to
  13117. * @param webVROptions a set of customizable options for the webVRCamera
  13118. */
  13119. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13120. /**
  13121. * Gets the device distance from the ground in meters.
  13122. * @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.
  13123. */
  13124. deviceDistanceToRoomGround(): number;
  13125. /**
  13126. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13127. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13128. */
  13129. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13130. /**
  13131. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13132. * @returns A promise with a boolean set to if the standing matrix is supported.
  13133. */
  13134. useStandingMatrixAsync(): Promise<boolean>;
  13135. /**
  13136. * Disposes the camera
  13137. */
  13138. dispose(): void;
  13139. /**
  13140. * Gets a vrController by name.
  13141. * @param name The name of the controller to retreive
  13142. * @returns the controller matching the name specified or null if not found
  13143. */
  13144. getControllerByName(name: string): Nullable<WebVRController>;
  13145. private _leftController;
  13146. /**
  13147. * The controller corrisponding to the users left hand.
  13148. */
  13149. readonly leftController: Nullable<WebVRController>;
  13150. private _rightController;
  13151. /**
  13152. * The controller corrisponding to the users right hand.
  13153. */
  13154. readonly rightController: Nullable<WebVRController>;
  13155. /**
  13156. * Casts a ray forward from the vrCamera's gaze.
  13157. * @param length Length of the ray (default: 100)
  13158. * @returns the ray corrisponding to the gaze
  13159. */
  13160. getForwardRay(length?: number): Ray;
  13161. /**
  13162. * @hidden
  13163. * Updates the camera based on device's frame data
  13164. */ checkInputs(): void;
  13165. /**
  13166. * Updates the poseControlled values based on the input device pose.
  13167. * @param poseData Pose coming from the device
  13168. */
  13169. updateFromDevice(poseData: DevicePose): void;
  13170. private _htmlElementAttached;
  13171. private _detachIfAttached;
  13172. /**
  13173. * WebVR's attach control will start broadcasting frames to the device.
  13174. * Note that in certain browsers (chrome for example) this function must be called
  13175. * within a user-interaction callback. Example:
  13176. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13177. *
  13178. * @param element html element to attach the vrDevice to
  13179. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13180. */
  13181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13182. /**
  13183. * Detaches the camera from the html element and disables VR
  13184. *
  13185. * @param element html element to detach from
  13186. */
  13187. detachControl(element: HTMLElement): void;
  13188. /**
  13189. * @returns the name of this class
  13190. */
  13191. getClassName(): string;
  13192. /**
  13193. * Calls resetPose on the vrDisplay
  13194. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13195. */
  13196. resetToCurrentRotation(): void;
  13197. /**
  13198. * @hidden
  13199. * Updates the rig cameras (left and right eye)
  13200. */ updateRigCameras(): void;
  13201. private _workingVector;
  13202. private _oneVector;
  13203. private _workingMatrix;
  13204. private updateCacheCalled;
  13205. private _correctPositionIfNotTrackPosition;
  13206. /**
  13207. * @hidden
  13208. * Updates the cached values of the camera
  13209. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13210. */ updateCache(ignoreParentClass?: boolean): void;
  13211. /**
  13212. * @hidden
  13213. * Get current device position in babylon world
  13214. */ computeDevicePosition(): void;
  13215. /**
  13216. * Updates the current device position and rotation in the babylon world
  13217. */
  13218. update(): void;
  13219. /**
  13220. * @hidden
  13221. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13222. * @returns an identity matrix
  13223. */ getViewMatrix(): Matrix;
  13224. private _tmpMatrix;
  13225. /**
  13226. * This function is called by the two RIG cameras.
  13227. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13228. * @hidden
  13229. */ getWebVRViewMatrix(): Matrix;
  13230. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  13231. private _onGamepadConnectedObserver;
  13232. private _onGamepadDisconnectedObserver;
  13233. private _updateCacheWhenTrackingDisabledObserver;
  13234. /**
  13235. * Initializes the controllers and their meshes
  13236. */
  13237. initControllers(): void;
  13238. }
  13239. }
  13240. declare module BABYLON {
  13241. /**
  13242. * Size options for a post process
  13243. */
  13244. export type PostProcessOptions = {
  13245. width: number;
  13246. height: number;
  13247. };
  13248. /**
  13249. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13250. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13251. */
  13252. export class PostProcess {
  13253. /** Name of the PostProcess. */
  13254. name: string;
  13255. /**
  13256. * Gets or sets the unique id of the post process
  13257. */
  13258. uniqueId: number;
  13259. /**
  13260. * Width of the texture to apply the post process on
  13261. */
  13262. width: number;
  13263. /**
  13264. * Height of the texture to apply the post process on
  13265. */
  13266. height: number;
  13267. /**
  13268. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13269. * @hidden
  13270. */ outputTexture: Nullable<InternalTexture>;
  13271. /**
  13272. * Sampling mode used by the shader
  13273. * See https://doc.babylonjs.com/classes/3.1/texture
  13274. */
  13275. renderTargetSamplingMode: number;
  13276. /**
  13277. * Clear color to use when screen clearing
  13278. */
  13279. clearColor: Color4;
  13280. /**
  13281. * If the buffer needs to be cleared before applying the post process. (default: true)
  13282. * Should be set to false if shader will overwrite all previous pixels.
  13283. */
  13284. autoClear: boolean;
  13285. /**
  13286. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13287. */
  13288. alphaMode: number;
  13289. /**
  13290. * Sets the setAlphaBlendConstants of the babylon engine
  13291. */
  13292. alphaConstants: Color4;
  13293. /**
  13294. * Animations to be used for the post processing
  13295. */
  13296. animations: Animation[];
  13297. /**
  13298. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13299. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13300. */
  13301. enablePixelPerfectMode: boolean;
  13302. /**
  13303. * Force the postprocess to be applied without taking in account viewport
  13304. */
  13305. forceFullscreenViewport: boolean;
  13306. /**
  13307. * List of inspectable custom properties (used by the Inspector)
  13308. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13309. */
  13310. inspectableCustomProperties: IInspectable[];
  13311. /**
  13312. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13313. *
  13314. * | Value | Type | Description |
  13315. * | ----- | ----------------------------------- | ----------- |
  13316. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13317. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13318. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13319. *
  13320. */
  13321. scaleMode: number;
  13322. /**
  13323. * Force textures to be a power of two (default: false)
  13324. */
  13325. alwaysForcePOT: boolean;
  13326. private _samples;
  13327. /**
  13328. * Number of sample textures (default: 1)
  13329. */
  13330. samples: number;
  13331. /**
  13332. * Modify the scale of the post process to be the same as the viewport (default: false)
  13333. */
  13334. adaptScaleToCurrentViewport: boolean;
  13335. private _camera;
  13336. private _scene;
  13337. private _engine;
  13338. private _options;
  13339. private _reusable;
  13340. private _textureType;
  13341. /**
  13342. * Smart array of input and output textures for the post process.
  13343. * @hidden
  13344. */ textures: SmartArray<InternalTexture>;
  13345. /**
  13346. * The index in _textures that corresponds to the output texture.
  13347. * @hidden
  13348. */ currentRenderTextureInd: number;
  13349. private _effect;
  13350. private _samplers;
  13351. private _fragmentUrl;
  13352. private _vertexUrl;
  13353. private _parameters;
  13354. private _scaleRatio;
  13355. protected _indexParameters: any;
  13356. private _shareOutputWithPostProcess;
  13357. private _texelSize;
  13358. private _forcedOutputTexture;
  13359. /**
  13360. * Returns the fragment url or shader name used in the post process.
  13361. * @returns the fragment url or name in the shader store.
  13362. */
  13363. getEffectName(): string;
  13364. /**
  13365. * An event triggered when the postprocess is activated.
  13366. */
  13367. onActivateObservable: Observable<Camera>;
  13368. private _onActivateObserver;
  13369. /**
  13370. * A function that is added to the onActivateObservable
  13371. */
  13372. onActivate: Nullable<(camera: Camera) => void>;
  13373. /**
  13374. * An event triggered when the postprocess changes its size.
  13375. */
  13376. onSizeChangedObservable: Observable<PostProcess>;
  13377. private _onSizeChangedObserver;
  13378. /**
  13379. * A function that is added to the onSizeChangedObservable
  13380. */
  13381. onSizeChanged: (postProcess: PostProcess) => void;
  13382. /**
  13383. * An event triggered when the postprocess applies its effect.
  13384. */
  13385. onApplyObservable: Observable<Effect>;
  13386. private _onApplyObserver;
  13387. /**
  13388. * A function that is added to the onApplyObservable
  13389. */
  13390. onApply: (effect: Effect) => void;
  13391. /**
  13392. * An event triggered before rendering the postprocess
  13393. */
  13394. onBeforeRenderObservable: Observable<Effect>;
  13395. private _onBeforeRenderObserver;
  13396. /**
  13397. * A function that is added to the onBeforeRenderObservable
  13398. */
  13399. onBeforeRender: (effect: Effect) => void;
  13400. /**
  13401. * An event triggered after rendering the postprocess
  13402. */
  13403. onAfterRenderObservable: Observable<Effect>;
  13404. private _onAfterRenderObserver;
  13405. /**
  13406. * A function that is added to the onAfterRenderObservable
  13407. */
  13408. onAfterRender: (efect: Effect) => void;
  13409. /**
  13410. * 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
  13411. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13412. */
  13413. inputTexture: InternalTexture;
  13414. /**
  13415. * Gets the camera which post process is applied to.
  13416. * @returns The camera the post process is applied to.
  13417. */
  13418. getCamera(): Camera;
  13419. /**
  13420. * Gets the texel size of the postprocess.
  13421. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13422. */
  13423. readonly texelSize: Vector2;
  13424. /**
  13425. * Creates a new instance PostProcess
  13426. * @param name The name of the PostProcess.
  13427. * @param fragmentUrl The url of the fragment shader to be used.
  13428. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13429. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13430. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13431. * @param camera The camera to apply the render pass to.
  13432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13433. * @param engine The engine which the post process will be applied. (default: current engine)
  13434. * @param reusable If the post process can be reused on the same frame. (default: false)
  13435. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13436. * @param textureType Type of textures used when performing the post process. (default: 0)
  13437. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13438. * @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
  13439. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13440. */
  13441. constructor(
  13442. /** Name of the PostProcess. */
  13443. 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);
  13444. /**
  13445. * Gets a string idenfifying the name of the class
  13446. * @returns "PostProcess" string
  13447. */
  13448. getClassName(): string;
  13449. /**
  13450. * Gets the engine which this post process belongs to.
  13451. * @returns The engine the post process was enabled with.
  13452. */
  13453. getEngine(): Engine;
  13454. /**
  13455. * The effect that is created when initializing the post process.
  13456. * @returns The created effect corrisponding the the postprocess.
  13457. */
  13458. getEffect(): Effect;
  13459. /**
  13460. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13461. * @param postProcess The post process to share the output with.
  13462. * @returns This post process.
  13463. */
  13464. shareOutputWith(postProcess: PostProcess): PostProcess;
  13465. /**
  13466. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13467. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13468. */
  13469. useOwnOutput(): void;
  13470. /**
  13471. * Updates the effect with the current post process compile time values and recompiles the shader.
  13472. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13473. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13474. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13475. * @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
  13476. * @param onCompiled Called when the shader has been compiled.
  13477. * @param onError Called if there is an error when compiling a shader.
  13478. */
  13479. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13480. /**
  13481. * The post process is reusable if it can be used multiple times within one frame.
  13482. * @returns If the post process is reusable
  13483. */
  13484. isReusable(): boolean;
  13485. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13486. markTextureDirty(): void;
  13487. /**
  13488. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13489. * 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.
  13490. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13491. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13492. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13493. * @returns The target texture that was bound to be written to.
  13494. */
  13495. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13496. /**
  13497. * If the post process is supported.
  13498. */
  13499. readonly isSupported: boolean;
  13500. /**
  13501. * The aspect ratio of the output texture.
  13502. */
  13503. readonly aspectRatio: number;
  13504. /**
  13505. * Get a value indicating if the post-process is ready to be used
  13506. * @returns true if the post-process is ready (shader is compiled)
  13507. */
  13508. isReady(): boolean;
  13509. /**
  13510. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13511. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13512. */
  13513. apply(): Nullable<Effect>;
  13514. private _disposeTextures;
  13515. /**
  13516. * Disposes the post process.
  13517. * @param camera The camera to dispose the post process on.
  13518. */
  13519. dispose(camera?: Camera): void;
  13520. }
  13521. }
  13522. declare module BABYLON {
  13523. /**
  13524. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13525. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13526. */
  13527. export class PostProcessManager {
  13528. private _scene;
  13529. private _indexBuffer;
  13530. private _vertexBuffers;
  13531. /**
  13532. * Creates a new instance PostProcess
  13533. * @param scene The scene that the post process is associated with.
  13534. */
  13535. constructor(scene: Scene);
  13536. private _prepareBuffers;
  13537. private _buildIndexBuffer;
  13538. /**
  13539. * Rebuilds the vertex buffers of the manager.
  13540. * @hidden
  13541. */ rebuild(): void;
  13542. /**
  13543. * Prepares a frame to be run through a post process.
  13544. * @param sourceTexture The input texture to the post procesess. (default: null)
  13545. * @param postProcesses An array of post processes to be run. (default: null)
  13546. * @returns True if the post processes were able to be run.
  13547. * @hidden
  13548. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13549. /**
  13550. * Manually render a set of post processes to a texture.
  13551. * @param postProcesses An array of post processes to be run.
  13552. * @param targetTexture The target texture to render to.
  13553. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13554. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13555. * @param lodLevel defines which lod of the texture to render to
  13556. */
  13557. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13558. /**
  13559. * Finalize the result of the output of the postprocesses.
  13560. * @param doNotPresent If true the result will not be displayed to the screen.
  13561. * @param targetTexture The target texture to render to.
  13562. * @param faceIndex The index of the face to bind the target texture to.
  13563. * @param postProcesses The array of post processes to render.
  13564. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13565. * @hidden
  13566. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13567. /**
  13568. * Disposes of the post process manager.
  13569. */
  13570. dispose(): void;
  13571. }
  13572. }
  13573. declare module BABYLON {
  13574. interface AbstractScene {
  13575. /**
  13576. * The list of layers (background and foreground) of the scene
  13577. */
  13578. layers: Array<Layer>;
  13579. }
  13580. /**
  13581. * Defines the layer scene component responsible to manage any layers
  13582. * in a given scene.
  13583. */
  13584. export class LayerSceneComponent implements ISceneComponent {
  13585. /**
  13586. * The component name helpfull to identify the component in the list of scene components.
  13587. */
  13588. readonly name: string;
  13589. /**
  13590. * The scene the component belongs to.
  13591. */
  13592. scene: Scene;
  13593. private _engine;
  13594. /**
  13595. * Creates a new instance of the component for the given scene
  13596. * @param scene Defines the scene to register the component in
  13597. */
  13598. constructor(scene: Scene);
  13599. /**
  13600. * Registers the component in a given scene
  13601. */
  13602. register(): void;
  13603. /**
  13604. * Rebuilds the elements related to this component in case of
  13605. * context lost for instance.
  13606. */
  13607. rebuild(): void;
  13608. /**
  13609. * Disposes the component and the associated ressources.
  13610. */
  13611. dispose(): void;
  13612. private _draw;
  13613. private _drawCameraPredicate;
  13614. private _drawCameraBackground;
  13615. private _drawCameraForeground;
  13616. private _drawRenderTargetPredicate;
  13617. private _drawRenderTargetBackground;
  13618. private _drawRenderTargetForeground;
  13619. }
  13620. }
  13621. declare module BABYLON {
  13622. /** @hidden */
  13623. export var layerPixelShader: {
  13624. name: string;
  13625. shader: string;
  13626. };
  13627. }
  13628. declare module BABYLON {
  13629. /** @hidden */
  13630. export var layerVertexShader: {
  13631. name: string;
  13632. shader: string;
  13633. };
  13634. }
  13635. declare module BABYLON {
  13636. /**
  13637. * This represents a full screen 2d layer.
  13638. * This can be useful to display a picture in the background of your scene for instance.
  13639. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13640. */
  13641. export class Layer {
  13642. /**
  13643. * Define the name of the layer.
  13644. */
  13645. name: string;
  13646. /**
  13647. * Define the texture the layer should display.
  13648. */
  13649. texture: Nullable<Texture>;
  13650. /**
  13651. * Is the layer in background or foreground.
  13652. */
  13653. isBackground: boolean;
  13654. /**
  13655. * Define the color of the layer (instead of texture).
  13656. */
  13657. color: Color4;
  13658. /**
  13659. * Define the scale of the layer in order to zoom in out of the texture.
  13660. */
  13661. scale: Vector2;
  13662. /**
  13663. * Define an offset for the layer in order to shift the texture.
  13664. */
  13665. offset: Vector2;
  13666. /**
  13667. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13668. */
  13669. alphaBlendingMode: number;
  13670. /**
  13671. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13672. * Alpha test will not mix with the background color in case of transparency.
  13673. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13674. */
  13675. alphaTest: boolean;
  13676. /**
  13677. * Define a mask to restrict the layer to only some of the scene cameras.
  13678. */
  13679. layerMask: number;
  13680. /**
  13681. * Define the list of render target the layer is visible into.
  13682. */
  13683. renderTargetTextures: RenderTargetTexture[];
  13684. /**
  13685. * Define if the layer is only used in renderTarget or if it also
  13686. * renders in the main frame buffer of the canvas.
  13687. */
  13688. renderOnlyInRenderTargetTextures: boolean;
  13689. private _scene;
  13690. private _vertexBuffers;
  13691. private _indexBuffer;
  13692. private _effect;
  13693. private _alphaTestEffect;
  13694. /**
  13695. * An event triggered when the layer is disposed.
  13696. */
  13697. onDisposeObservable: Observable<Layer>;
  13698. private _onDisposeObserver;
  13699. /**
  13700. * Back compatibility with callback before the onDisposeObservable existed.
  13701. * The set callback will be triggered when the layer has been disposed.
  13702. */
  13703. onDispose: () => void;
  13704. /**
  13705. * An event triggered before rendering the scene
  13706. */
  13707. onBeforeRenderObservable: Observable<Layer>;
  13708. private _onBeforeRenderObserver;
  13709. /**
  13710. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13711. * The set callback will be triggered just before rendering the layer.
  13712. */
  13713. onBeforeRender: () => void;
  13714. /**
  13715. * An event triggered after rendering the scene
  13716. */
  13717. onAfterRenderObservable: Observable<Layer>;
  13718. private _onAfterRenderObserver;
  13719. /**
  13720. * Back compatibility with callback before the onAfterRenderObservable existed.
  13721. * The set callback will be triggered just after rendering the layer.
  13722. */
  13723. onAfterRender: () => void;
  13724. /**
  13725. * Instantiates a new layer.
  13726. * This represents a full screen 2d layer.
  13727. * This can be useful to display a picture in the background of your scene for instance.
  13728. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13729. * @param name Define the name of the layer in the scene
  13730. * @param imgUrl Define the url of the texture to display in the layer
  13731. * @param scene Define the scene the layer belongs to
  13732. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13733. * @param color Defines a color for the layer
  13734. */
  13735. constructor(
  13736. /**
  13737. * Define the name of the layer.
  13738. */
  13739. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13740. private _createIndexBuffer;
  13741. /** @hidden */ rebuild(): void;
  13742. /**
  13743. * Renders the layer in the scene.
  13744. */
  13745. render(): void;
  13746. /**
  13747. * Disposes and releases the associated ressources.
  13748. */
  13749. dispose(): void;
  13750. }
  13751. }
  13752. declare module BABYLON {
  13753. interface AbstractScene {
  13754. /**
  13755. * The list of procedural textures added to the scene
  13756. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13757. */
  13758. proceduralTextures: Array<ProceduralTexture>;
  13759. }
  13760. /**
  13761. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13762. * in a given scene.
  13763. */
  13764. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13765. /**
  13766. * The component name helpfull to identify the component in the list of scene components.
  13767. */
  13768. readonly name: string;
  13769. /**
  13770. * The scene the component belongs to.
  13771. */
  13772. scene: Scene;
  13773. /**
  13774. * Creates a new instance of the component for the given scene
  13775. * @param scene Defines the scene to register the component in
  13776. */
  13777. constructor(scene: Scene);
  13778. /**
  13779. * Registers the component in a given scene
  13780. */
  13781. register(): void;
  13782. /**
  13783. * Rebuilds the elements related to this component in case of
  13784. * context lost for instance.
  13785. */
  13786. rebuild(): void;
  13787. /**
  13788. * Disposes the component and the associated ressources.
  13789. */
  13790. dispose(): void;
  13791. private _beforeClear;
  13792. }
  13793. }
  13794. declare module BABYLON {
  13795. interface Engine {
  13796. /**
  13797. * Creates a new render target cube texture
  13798. * @param size defines the size of the texture
  13799. * @param options defines the options used to create the texture
  13800. * @returns a new render target cube texture stored in an InternalTexture
  13801. */
  13802. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  13803. }
  13804. }
  13805. declare module BABYLON {
  13806. /** @hidden */
  13807. export var proceduralVertexShader: {
  13808. name: string;
  13809. shader: string;
  13810. };
  13811. }
  13812. declare module BABYLON {
  13813. /**
  13814. * 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.
  13815. * This is the base class of any Procedural texture and contains most of the shareable code.
  13816. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13817. */
  13818. export class ProceduralTexture extends Texture {
  13819. isCube: boolean;
  13820. /**
  13821. * Define if the texture is enabled or not (disabled texture will not render)
  13822. */
  13823. isEnabled: boolean;
  13824. /**
  13825. * Define if the texture must be cleared before rendering (default is true)
  13826. */
  13827. autoClear: boolean;
  13828. /**
  13829. * Callback called when the texture is generated
  13830. */
  13831. onGenerated: () => void;
  13832. /**
  13833. * Event raised when the texture is generated
  13834. */
  13835. onGeneratedObservable: Observable<ProceduralTexture>;
  13836. /** @hidden */ generateMipMaps: boolean;
  13837. /** @hidden **/ effect: Effect;
  13838. /** @hidden */ textures: {
  13839. [key: string]: Texture;
  13840. };
  13841. private _size;
  13842. private _currentRefreshId;
  13843. private _refreshRate;
  13844. private _vertexBuffers;
  13845. private _indexBuffer;
  13846. private _uniforms;
  13847. private _samplers;
  13848. private _fragment;
  13849. private _floats;
  13850. private _ints;
  13851. private _floatsArrays;
  13852. private _colors3;
  13853. private _colors4;
  13854. private _vectors2;
  13855. private _vectors3;
  13856. private _matrices;
  13857. private _fallbackTexture;
  13858. private _fallbackTextureUsed;
  13859. private _engine;
  13860. private _cachedDefines;
  13861. private _contentUpdateId;
  13862. private _contentData;
  13863. /**
  13864. * Instantiates a new procedural texture.
  13865. * 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.
  13866. * This is the base class of any Procedural texture and contains most of the shareable code.
  13867. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13868. * @param name Define the name of the texture
  13869. * @param size Define the size of the texture to create
  13870. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13871. * @param scene Define the scene the texture belongs to
  13872. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13873. * @param generateMipMaps Define if the texture should creates mip maps or not
  13874. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13875. */
  13876. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13877. /**
  13878. * The effect that is created when initializing the post process.
  13879. * @returns The created effect corrisponding the the postprocess.
  13880. */
  13881. getEffect(): Effect;
  13882. /**
  13883. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13884. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13885. */
  13886. getContent(): Nullable<ArrayBufferView>;
  13887. private _createIndexBuffer;
  13888. /** @hidden */ rebuild(): void;
  13889. /**
  13890. * Resets the texture in order to recreate its associated resources.
  13891. * This can be called in case of context loss
  13892. */
  13893. reset(): void;
  13894. protected _getDefines(): string;
  13895. /**
  13896. * Is the texture ready to be used ? (rendered at least once)
  13897. * @returns true if ready, otherwise, false.
  13898. */
  13899. isReady(): boolean;
  13900. /**
  13901. * Resets the refresh counter of the texture and start bak from scratch.
  13902. * Could be useful to regenerate the texture if it is setup to render only once.
  13903. */
  13904. resetRefreshCounter(): void;
  13905. /**
  13906. * Set the fragment shader to use in order to render the texture.
  13907. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13908. */
  13909. setFragment(fragment: any): void;
  13910. /**
  13911. * Define the refresh rate of the texture or the rendering frequency.
  13912. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13913. */
  13914. refreshRate: number;
  13915. /** @hidden */ shouldRender(): boolean;
  13916. /**
  13917. * Get the size the texture is rendering at.
  13918. * @returns the size (texture is always squared)
  13919. */
  13920. getRenderSize(): number;
  13921. /**
  13922. * Resize the texture to new value.
  13923. * @param size Define the new size the texture should have
  13924. * @param generateMipMaps Define whether the new texture should create mip maps
  13925. */
  13926. resize(size: number, generateMipMaps: boolean): void;
  13927. private _checkUniform;
  13928. /**
  13929. * Set a texture in the shader program used to render.
  13930. * @param name Define the name of the uniform samplers as defined in the shader
  13931. * @param texture Define the texture to bind to this sampler
  13932. * @return the texture itself allowing "fluent" like uniform updates
  13933. */
  13934. setTexture(name: string, texture: Texture): ProceduralTexture;
  13935. /**
  13936. * Set a float in the shader.
  13937. * @param name Define the name of the uniform as defined in the shader
  13938. * @param value Define the value to give to the uniform
  13939. * @return the texture itself allowing "fluent" like uniform updates
  13940. */
  13941. setFloat(name: string, value: number): ProceduralTexture;
  13942. /**
  13943. * Set a int in the shader.
  13944. * @param name Define the name of the uniform as defined in the shader
  13945. * @param value Define the value to give to the uniform
  13946. * @return the texture itself allowing "fluent" like uniform updates
  13947. */
  13948. setInt(name: string, value: number): ProceduralTexture;
  13949. /**
  13950. * Set an array of floats in the shader.
  13951. * @param name Define the name of the uniform as defined in the shader
  13952. * @param value Define the value to give to the uniform
  13953. * @return the texture itself allowing "fluent" like uniform updates
  13954. */
  13955. setFloats(name: string, value: number[]): ProceduralTexture;
  13956. /**
  13957. * Set a vec3 in the shader from a Color3.
  13958. * @param name Define the name of the uniform as defined in the shader
  13959. * @param value Define the value to give to the uniform
  13960. * @return the texture itself allowing "fluent" like uniform updates
  13961. */
  13962. setColor3(name: string, value: Color3): ProceduralTexture;
  13963. /**
  13964. * Set a vec4 in the shader from a Color4.
  13965. * @param name Define the name of the uniform as defined in the shader
  13966. * @param value Define the value to give to the uniform
  13967. * @return the texture itself allowing "fluent" like uniform updates
  13968. */
  13969. setColor4(name: string, value: Color4): ProceduralTexture;
  13970. /**
  13971. * Set a vec2 in the shader from a Vector2.
  13972. * @param name Define the name of the uniform as defined in the shader
  13973. * @param value Define the value to give to the uniform
  13974. * @return the texture itself allowing "fluent" like uniform updates
  13975. */
  13976. setVector2(name: string, value: Vector2): ProceduralTexture;
  13977. /**
  13978. * Set a vec3 in the shader from a Vector3.
  13979. * @param name Define the name of the uniform as defined in the shader
  13980. * @param value Define the value to give to the uniform
  13981. * @return the texture itself allowing "fluent" like uniform updates
  13982. */
  13983. setVector3(name: string, value: Vector3): ProceduralTexture;
  13984. /**
  13985. * Set a mat4 in the shader from a MAtrix.
  13986. * @param name Define the name of the uniform as defined in the shader
  13987. * @param value Define the value to give to the uniform
  13988. * @return the texture itself allowing "fluent" like uniform updates
  13989. */
  13990. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13991. /**
  13992. * Render the texture to its associated render target.
  13993. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13994. */
  13995. render(useCameraPostProcess?: boolean): void;
  13996. /**
  13997. * Clone the texture.
  13998. * @returns the cloned texture
  13999. */
  14000. clone(): ProceduralTexture;
  14001. /**
  14002. * Dispose the texture and release its asoociated resources.
  14003. */
  14004. dispose(): void;
  14005. }
  14006. }
  14007. declare module BABYLON {
  14008. /**
  14009. * This represents the base class for particle system in Babylon.
  14010. * 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.
  14011. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14012. * @example https://doc.babylonjs.com/babylon101/particles
  14013. */
  14014. export class BaseParticleSystem {
  14015. /**
  14016. * Source color is added to the destination color without alpha affecting the result
  14017. */
  14018. static BLENDMODE_ONEONE: number;
  14019. /**
  14020. * Blend current color and particle color using particle’s alpha
  14021. */
  14022. static BLENDMODE_STANDARD: number;
  14023. /**
  14024. * Add current color and particle color multiplied by particle’s alpha
  14025. */
  14026. static BLENDMODE_ADD: number;
  14027. /**
  14028. * Multiply current color with particle color
  14029. */
  14030. static BLENDMODE_MULTIPLY: number;
  14031. /**
  14032. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14033. */
  14034. static BLENDMODE_MULTIPLYADD: number;
  14035. /**
  14036. * List of animations used by the particle system.
  14037. */
  14038. animations: Animation[];
  14039. /**
  14040. * The id of the Particle system.
  14041. */
  14042. id: string;
  14043. /**
  14044. * The friendly name of the Particle system.
  14045. */
  14046. name: string;
  14047. /**
  14048. * The rendering group used by the Particle system to chose when to render.
  14049. */
  14050. renderingGroupId: number;
  14051. /**
  14052. * The emitter represents the Mesh or position we are attaching the particle system to.
  14053. */
  14054. emitter: Nullable<AbstractMesh | Vector3>;
  14055. /**
  14056. * The maximum number of particles to emit per frame
  14057. */
  14058. emitRate: number;
  14059. /**
  14060. * If you want to launch only a few particles at once, that can be done, as well.
  14061. */
  14062. manualEmitCount: number;
  14063. /**
  14064. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14065. */
  14066. updateSpeed: number;
  14067. /**
  14068. * The amount of time the particle system is running (depends of the overall update speed).
  14069. */
  14070. targetStopDuration: number;
  14071. /**
  14072. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14073. */
  14074. disposeOnStop: boolean;
  14075. /**
  14076. * Minimum power of emitting particles.
  14077. */
  14078. minEmitPower: number;
  14079. /**
  14080. * Maximum power of emitting particles.
  14081. */
  14082. maxEmitPower: number;
  14083. /**
  14084. * Minimum life time of emitting particles.
  14085. */
  14086. minLifeTime: number;
  14087. /**
  14088. * Maximum life time of emitting particles.
  14089. */
  14090. maxLifeTime: number;
  14091. /**
  14092. * Minimum Size of emitting particles.
  14093. */
  14094. minSize: number;
  14095. /**
  14096. * Maximum Size of emitting particles.
  14097. */
  14098. maxSize: number;
  14099. /**
  14100. * Minimum scale of emitting particles on X axis.
  14101. */
  14102. minScaleX: number;
  14103. /**
  14104. * Maximum scale of emitting particles on X axis.
  14105. */
  14106. maxScaleX: number;
  14107. /**
  14108. * Minimum scale of emitting particles on Y axis.
  14109. */
  14110. minScaleY: number;
  14111. /**
  14112. * Maximum scale of emitting particles on Y axis.
  14113. */
  14114. maxScaleY: number;
  14115. /**
  14116. * Gets or sets the minimal initial rotation in radians.
  14117. */
  14118. minInitialRotation: number;
  14119. /**
  14120. * Gets or sets the maximal initial rotation in radians.
  14121. */
  14122. maxInitialRotation: number;
  14123. /**
  14124. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14125. */
  14126. minAngularSpeed: number;
  14127. /**
  14128. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14129. */
  14130. maxAngularSpeed: number;
  14131. /**
  14132. * The texture used to render each particle. (this can be a spritesheet)
  14133. */
  14134. particleTexture: Nullable<Texture>;
  14135. /**
  14136. * The layer mask we are rendering the particles through.
  14137. */
  14138. layerMask: number;
  14139. /**
  14140. * This can help using your own shader to render the particle system.
  14141. * The according effect will be created
  14142. */
  14143. customShader: any;
  14144. /**
  14145. * By default particle system starts as soon as they are created. This prevents the
  14146. * automatic start to happen and let you decide when to start emitting particles.
  14147. */
  14148. preventAutoStart: boolean;
  14149. private _noiseTexture;
  14150. /**
  14151. * Gets or sets a texture used to add random noise to particle positions
  14152. */
  14153. noiseTexture: Nullable<ProceduralTexture>;
  14154. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14155. noiseStrength: Vector3;
  14156. /**
  14157. * Callback triggered when the particle animation is ending.
  14158. */
  14159. onAnimationEnd: Nullable<() => void>;
  14160. /**
  14161. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14162. */
  14163. blendMode: number;
  14164. /**
  14165. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14166. * to override the particles.
  14167. */
  14168. forceDepthWrite: boolean;
  14169. /** 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 */
  14170. preWarmCycles: number;
  14171. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14172. preWarmStepOffset: number;
  14173. /**
  14174. * 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)
  14175. */
  14176. spriteCellChangeSpeed: number;
  14177. /**
  14178. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14179. */
  14180. startSpriteCellID: number;
  14181. /**
  14182. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14183. */
  14184. endSpriteCellID: number;
  14185. /**
  14186. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14187. */
  14188. spriteCellWidth: number;
  14189. /**
  14190. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14191. */
  14192. spriteCellHeight: number;
  14193. /**
  14194. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14195. */
  14196. spriteRandomStartCell: boolean;
  14197. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14198. translationPivot: Vector2;
  14199. /** @hidden */
  14200. protected _isAnimationSheetEnabled: boolean;
  14201. /**
  14202. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14203. */
  14204. beginAnimationOnStart: boolean;
  14205. /**
  14206. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14207. */
  14208. beginAnimationFrom: number;
  14209. /**
  14210. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14211. */
  14212. beginAnimationTo: number;
  14213. /**
  14214. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14215. */
  14216. beginAnimationLoop: boolean;
  14217. /**
  14218. * Gets or sets a world offset applied to all particles
  14219. */
  14220. worldOffset: Vector3;
  14221. /**
  14222. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14223. */
  14224. isAnimationSheetEnabled: boolean;
  14225. /**
  14226. * Get hosting scene
  14227. * @returns the scene
  14228. */
  14229. getScene(): Scene;
  14230. /**
  14231. * You can use gravity if you want to give an orientation to your particles.
  14232. */
  14233. gravity: Vector3;
  14234. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14235. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14236. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14237. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14238. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14239. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14240. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14241. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14242. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14243. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14244. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14245. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14246. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14247. /**
  14248. * Defines the delay in milliseconds before starting the system (0 by default)
  14249. */
  14250. startDelay: number;
  14251. /**
  14252. * Gets the current list of drag gradients.
  14253. * You must use addDragGradient and removeDragGradient to udpate this list
  14254. * @returns the list of drag gradients
  14255. */
  14256. getDragGradients(): Nullable<Array<FactorGradient>>;
  14257. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14258. limitVelocityDamping: number;
  14259. /**
  14260. * Gets the current list of limit velocity gradients.
  14261. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14262. * @returns the list of limit velocity gradients
  14263. */
  14264. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14265. /**
  14266. * Gets the current list of color gradients.
  14267. * You must use addColorGradient and removeColorGradient to udpate this list
  14268. * @returns the list of color gradients
  14269. */
  14270. getColorGradients(): Nullable<Array<ColorGradient>>;
  14271. /**
  14272. * Gets the current list of size gradients.
  14273. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14274. * @returns the list of size gradients
  14275. */
  14276. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14277. /**
  14278. * Gets the current list of color remap gradients.
  14279. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14280. * @returns the list of color remap gradients
  14281. */
  14282. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14283. /**
  14284. * Gets the current list of alpha remap gradients.
  14285. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14286. * @returns the list of alpha remap gradients
  14287. */
  14288. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14289. /**
  14290. * Gets the current list of life time gradients.
  14291. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14292. * @returns the list of life time gradients
  14293. */
  14294. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14295. /**
  14296. * Gets the current list of angular speed gradients.
  14297. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14298. * @returns the list of angular speed gradients
  14299. */
  14300. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14301. /**
  14302. * Gets the current list of velocity gradients.
  14303. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14304. * @returns the list of velocity gradients
  14305. */
  14306. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14307. /**
  14308. * Gets the current list of start size gradients.
  14309. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14310. * @returns the list of start size gradients
  14311. */
  14312. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14313. /**
  14314. * Gets the current list of emit rate gradients.
  14315. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14316. * @returns the list of emit rate gradients
  14317. */
  14318. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14319. /**
  14320. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14321. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14322. */
  14323. direction1: Vector3;
  14324. /**
  14325. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14326. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14327. */
  14328. direction2: Vector3;
  14329. /**
  14330. * 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.
  14331. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14332. */
  14333. minEmitBox: Vector3;
  14334. /**
  14335. * 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.
  14336. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14337. */
  14338. maxEmitBox: Vector3;
  14339. /**
  14340. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14341. */
  14342. color1: Color4;
  14343. /**
  14344. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14345. */
  14346. color2: Color4;
  14347. /**
  14348. * Color the particle will have at the end of its lifetime
  14349. */
  14350. colorDead: Color4;
  14351. /**
  14352. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14353. */
  14354. textureMask: Color4;
  14355. /**
  14356. * The particle emitter type defines the emitter used by the particle system.
  14357. * It can be for example box, sphere, or cone...
  14358. */
  14359. particleEmitterType: IParticleEmitterType;
  14360. /** @hidden */ isSubEmitter: boolean;
  14361. /**
  14362. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14363. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14364. */
  14365. billboardMode: number;
  14366. protected _isBillboardBased: boolean;
  14367. /**
  14368. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14369. */
  14370. isBillboardBased: boolean;
  14371. /**
  14372. * The scene the particle system belongs to.
  14373. */
  14374. protected _scene: Scene;
  14375. /**
  14376. * Local cache of defines for image processing.
  14377. */
  14378. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14379. /**
  14380. * Default configuration related to image processing available in the standard Material.
  14381. */
  14382. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14383. /**
  14384. * Gets the image processing configuration used either in this material.
  14385. */
  14386. /**
  14387. * Sets the Default image processing configuration used either in the this material.
  14388. *
  14389. * If sets to null, the scene one is in use.
  14390. */
  14391. imageProcessingConfiguration: ImageProcessingConfiguration;
  14392. /**
  14393. * Attaches a new image processing configuration to the Standard Material.
  14394. * @param configuration
  14395. */
  14396. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14397. /** @hidden */
  14398. protected _reset(): void;
  14399. /** @hidden */
  14400. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14401. /**
  14402. * Instantiates a particle system.
  14403. * 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.
  14404. * @param name The name of the particle system
  14405. */
  14406. constructor(name: string);
  14407. /**
  14408. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14409. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14410. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14411. * @returns the emitter
  14412. */
  14413. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14414. /**
  14415. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14416. * @param radius The radius of the hemisphere to emit from
  14417. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14418. * @returns the emitter
  14419. */
  14420. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14421. /**
  14422. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14423. * @param radius The radius of the sphere to emit from
  14424. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14425. * @returns the emitter
  14426. */
  14427. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14428. /**
  14429. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14430. * @param radius The radius of the sphere to emit from
  14431. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14432. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14433. * @returns the emitter
  14434. */
  14435. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14436. /**
  14437. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14438. * @param radius The radius of the emission cylinder
  14439. * @param height The height of the emission cylinder
  14440. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14441. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14442. * @returns the emitter
  14443. */
  14444. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14445. /**
  14446. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14447. * @param radius The radius of the cylinder to emit from
  14448. * @param height The height of the emission cylinder
  14449. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14450. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14451. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14452. * @returns the emitter
  14453. */
  14454. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14455. /**
  14456. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14457. * @param radius The radius of the cone to emit from
  14458. * @param angle The base angle of the cone
  14459. * @returns the emitter
  14460. */
  14461. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14462. /**
  14463. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14464. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14465. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14466. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14467. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14468. * @returns the emitter
  14469. */
  14470. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14471. }
  14472. }
  14473. declare module BABYLON {
  14474. /**
  14475. * Type of sub emitter
  14476. */
  14477. export enum SubEmitterType {
  14478. /**
  14479. * Attached to the particle over it's lifetime
  14480. */
  14481. ATTACHED = 0,
  14482. /**
  14483. * Created when the particle dies
  14484. */
  14485. END = 1
  14486. }
  14487. /**
  14488. * Sub emitter class used to emit particles from an existing particle
  14489. */
  14490. export class SubEmitter {
  14491. /**
  14492. * the particle system to be used by the sub emitter
  14493. */
  14494. particleSystem: ParticleSystem;
  14495. /**
  14496. * Type of the submitter (Default: END)
  14497. */
  14498. type: SubEmitterType;
  14499. /**
  14500. * 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)
  14501. * Note: This only is supported when using an emitter of type Mesh
  14502. */
  14503. inheritDirection: boolean;
  14504. /**
  14505. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14506. */
  14507. inheritedVelocityAmount: number;
  14508. /**
  14509. * Creates a sub emitter
  14510. * @param particleSystem the particle system to be used by the sub emitter
  14511. */
  14512. constructor(
  14513. /**
  14514. * the particle system to be used by the sub emitter
  14515. */
  14516. particleSystem: ParticleSystem);
  14517. /**
  14518. * Clones the sub emitter
  14519. * @returns the cloned sub emitter
  14520. */
  14521. clone(): SubEmitter;
  14522. /**
  14523. * Serialize current object to a JSON object
  14524. * @returns the serialized object
  14525. */
  14526. serialize(): any;
  14527. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14528. /**
  14529. * Creates a new SubEmitter from a serialized JSON version
  14530. * @param serializationObject defines the JSON object to read from
  14531. * @param scene defines the hosting scene
  14532. * @param rootUrl defines the rootUrl for data loading
  14533. * @returns a new SubEmitter
  14534. */
  14535. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14536. /** Release associated resources */
  14537. dispose(): void;
  14538. }
  14539. }
  14540. declare module BABYLON {
  14541. /** @hidden */
  14542. export var clipPlaneFragmentDeclaration: {
  14543. name: string;
  14544. shader: string;
  14545. };
  14546. }
  14547. declare module BABYLON {
  14548. /** @hidden */
  14549. export var imageProcessingDeclaration: {
  14550. name: string;
  14551. shader: string;
  14552. };
  14553. }
  14554. declare module BABYLON {
  14555. /** @hidden */
  14556. export var imageProcessingFunctions: {
  14557. name: string;
  14558. shader: string;
  14559. };
  14560. }
  14561. declare module BABYLON {
  14562. /** @hidden */
  14563. export var clipPlaneFragment: {
  14564. name: string;
  14565. shader: string;
  14566. };
  14567. }
  14568. declare module BABYLON {
  14569. /** @hidden */
  14570. export var particlesPixelShader: {
  14571. name: string;
  14572. shader: string;
  14573. };
  14574. }
  14575. declare module BABYLON {
  14576. /** @hidden */
  14577. export var clipPlaneVertexDeclaration: {
  14578. name: string;
  14579. shader: string;
  14580. };
  14581. }
  14582. declare module BABYLON {
  14583. /** @hidden */
  14584. export var clipPlaneVertex: {
  14585. name: string;
  14586. shader: string;
  14587. };
  14588. }
  14589. declare module BABYLON {
  14590. /** @hidden */
  14591. export var particlesVertexShader: {
  14592. name: string;
  14593. shader: string;
  14594. };
  14595. }
  14596. declare module BABYLON {
  14597. /**
  14598. * This represents a particle system in Babylon.
  14599. * 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.
  14600. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14601. * @example https://doc.babylonjs.com/babylon101/particles
  14602. */
  14603. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14604. /**
  14605. * Billboard mode will only apply to Y axis
  14606. */
  14607. static readonly BILLBOARDMODE_Y: number;
  14608. /**
  14609. * Billboard mode will apply to all axes
  14610. */
  14611. static readonly BILLBOARDMODE_ALL: number;
  14612. /**
  14613. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14614. */
  14615. static readonly BILLBOARDMODE_STRETCHED: number;
  14616. /**
  14617. * This function can be defined to provide custom update for active particles.
  14618. * This function will be called instead of regular update (age, position, color, etc.).
  14619. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14620. */
  14621. updateFunction: (particles: Particle[]) => void;
  14622. private _emitterWorldMatrix;
  14623. /**
  14624. * This function can be defined to specify initial direction for every new particle.
  14625. * It by default use the emitterType defined function
  14626. */
  14627. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14628. /**
  14629. * This function can be defined to specify initial position for every new particle.
  14630. * It by default use the emitterType defined function
  14631. */
  14632. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14633. /**
  14634. * @hidden
  14635. */ inheritedVelocityOffset: Vector3;
  14636. /**
  14637. * An event triggered when the system is disposed
  14638. */
  14639. onDisposeObservable: Observable<ParticleSystem>;
  14640. private _onDisposeObserver;
  14641. /**
  14642. * Sets a callback that will be triggered when the system is disposed
  14643. */
  14644. onDispose: () => void;
  14645. private _particles;
  14646. private _epsilon;
  14647. private _capacity;
  14648. private _stockParticles;
  14649. private _newPartsExcess;
  14650. private _vertexData;
  14651. private _vertexBuffer;
  14652. private _vertexBuffers;
  14653. private _spriteBuffer;
  14654. private _indexBuffer;
  14655. private _effect;
  14656. private _customEffect;
  14657. private _cachedDefines;
  14658. private _scaledColorStep;
  14659. private _colorDiff;
  14660. private _scaledDirection;
  14661. private _scaledGravity;
  14662. private _currentRenderId;
  14663. private _alive;
  14664. private _useInstancing;
  14665. private _started;
  14666. private _stopped;
  14667. private _actualFrame;
  14668. private _scaledUpdateSpeed;
  14669. private _vertexBufferSize;
  14670. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14671. /** @hidden */ currentEmitRate1: number;
  14672. /** @hidden */ currentEmitRate2: number;
  14673. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14674. /** @hidden */ currentStartSize1: number;
  14675. /** @hidden */ currentStartSize2: number;
  14676. private readonly _rawTextureWidth;
  14677. private _rampGradientsTexture;
  14678. private _useRampGradients;
  14679. /** Gets or sets a boolean indicating that ramp gradients must be used
  14680. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14681. */
  14682. useRampGradients: boolean;
  14683. /**
  14684. * 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.
  14685. * 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: [])
  14686. */
  14687. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14688. private _subEmitters;
  14689. /**
  14690. * @hidden
  14691. * If the particle systems emitter should be disposed when the particle system is disposed
  14692. */ disposeEmitterOnDispose: boolean;
  14693. /**
  14694. * The current active Sub-systems, this property is used by the root particle system only.
  14695. */
  14696. activeSubSystems: Array<ParticleSystem>;
  14697. private _rootParticleSystem;
  14698. /**
  14699. * Gets the current list of active particles
  14700. */
  14701. readonly particles: Particle[];
  14702. /**
  14703. * Returns the string "ParticleSystem"
  14704. * @returns a string containing the class name
  14705. */
  14706. getClassName(): string;
  14707. /**
  14708. * Instantiates a particle system.
  14709. * 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.
  14710. * @param name The name of the particle system
  14711. * @param capacity The max number of particles alive at the same time
  14712. * @param scene The scene the particle system belongs to
  14713. * @param customEffect a custom effect used to change the way particles are rendered by default
  14714. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14715. * @param epsilon Offset used to render the particles
  14716. */
  14717. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14718. private _addFactorGradient;
  14719. private _removeFactorGradient;
  14720. /**
  14721. * Adds a new life time gradient
  14722. * @param gradient defines the gradient to use (between 0 and 1)
  14723. * @param factor defines the life time factor to affect to the specified gradient
  14724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14725. * @returns the current particle system
  14726. */
  14727. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14728. /**
  14729. * Remove a specific life time gradient
  14730. * @param gradient defines the gradient to remove
  14731. * @returns the current particle system
  14732. */
  14733. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14734. /**
  14735. * Adds a new size gradient
  14736. * @param gradient defines the gradient to use (between 0 and 1)
  14737. * @param factor defines the size factor to affect to the specified gradient
  14738. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14739. * @returns the current particle system
  14740. */
  14741. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14742. /**
  14743. * Remove a specific size gradient
  14744. * @param gradient defines the gradient to remove
  14745. * @returns the current particle system
  14746. */
  14747. removeSizeGradient(gradient: number): IParticleSystem;
  14748. /**
  14749. * Adds a new color remap gradient
  14750. * @param gradient defines the gradient to use (between 0 and 1)
  14751. * @param min defines the color remap minimal range
  14752. * @param max defines the color remap maximal range
  14753. * @returns the current particle system
  14754. */
  14755. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14756. /**
  14757. * Remove a specific color remap gradient
  14758. * @param gradient defines the gradient to remove
  14759. * @returns the current particle system
  14760. */
  14761. removeColorRemapGradient(gradient: number): IParticleSystem;
  14762. /**
  14763. * Adds a new alpha remap gradient
  14764. * @param gradient defines the gradient to use (between 0 and 1)
  14765. * @param min defines the alpha remap minimal range
  14766. * @param max defines the alpha remap maximal range
  14767. * @returns the current particle system
  14768. */
  14769. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14770. /**
  14771. * Remove a specific alpha remap gradient
  14772. * @param gradient defines the gradient to remove
  14773. * @returns the current particle system
  14774. */
  14775. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14776. /**
  14777. * Adds a new angular speed gradient
  14778. * @param gradient defines the gradient to use (between 0 and 1)
  14779. * @param factor defines the angular speed to affect to the specified gradient
  14780. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14781. * @returns the current particle system
  14782. */
  14783. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14784. /**
  14785. * Remove a specific angular speed gradient
  14786. * @param gradient defines the gradient to remove
  14787. * @returns the current particle system
  14788. */
  14789. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14790. /**
  14791. * Adds a new velocity gradient
  14792. * @param gradient defines the gradient to use (between 0 and 1)
  14793. * @param factor defines the velocity to affect to the specified gradient
  14794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14795. * @returns the current particle system
  14796. */
  14797. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14798. /**
  14799. * Remove a specific velocity gradient
  14800. * @param gradient defines the gradient to remove
  14801. * @returns the current particle system
  14802. */
  14803. removeVelocityGradient(gradient: number): IParticleSystem;
  14804. /**
  14805. * Adds a new limit velocity gradient
  14806. * @param gradient defines the gradient to use (between 0 and 1)
  14807. * @param factor defines the limit velocity value to affect to the specified gradient
  14808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14809. * @returns the current particle system
  14810. */
  14811. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14812. /**
  14813. * Remove a specific limit velocity gradient
  14814. * @param gradient defines the gradient to remove
  14815. * @returns the current particle system
  14816. */
  14817. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14818. /**
  14819. * Adds a new drag gradient
  14820. * @param gradient defines the gradient to use (between 0 and 1)
  14821. * @param factor defines the drag value to affect to the specified gradient
  14822. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14823. * @returns the current particle system
  14824. */
  14825. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14826. /**
  14827. * Remove a specific drag gradient
  14828. * @param gradient defines the gradient to remove
  14829. * @returns the current particle system
  14830. */
  14831. removeDragGradient(gradient: number): IParticleSystem;
  14832. /**
  14833. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14834. * @param gradient defines the gradient to use (between 0 and 1)
  14835. * @param factor defines the emit rate value to affect to the specified gradient
  14836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14837. * @returns the current particle system
  14838. */
  14839. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14840. /**
  14841. * Remove a specific emit rate gradient
  14842. * @param gradient defines the gradient to remove
  14843. * @returns the current particle system
  14844. */
  14845. removeEmitRateGradient(gradient: number): IParticleSystem;
  14846. /**
  14847. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14848. * @param gradient defines the gradient to use (between 0 and 1)
  14849. * @param factor defines the start size value to affect to the specified gradient
  14850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14851. * @returns the current particle system
  14852. */
  14853. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14854. /**
  14855. * Remove a specific start size gradient
  14856. * @param gradient defines the gradient to remove
  14857. * @returns the current particle system
  14858. */
  14859. removeStartSizeGradient(gradient: number): IParticleSystem;
  14860. private _createRampGradientTexture;
  14861. /**
  14862. * Gets the current list of ramp gradients.
  14863. * You must use addRampGradient and removeRampGradient to udpate this list
  14864. * @returns the list of ramp gradients
  14865. */
  14866. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14867. /**
  14868. * Adds a new ramp gradient used to remap particle colors
  14869. * @param gradient defines the gradient to use (between 0 and 1)
  14870. * @param color defines the color to affect to the specified gradient
  14871. * @returns the current particle system
  14872. */
  14873. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14874. /**
  14875. * Remove a specific ramp gradient
  14876. * @param gradient defines the gradient to remove
  14877. * @returns the current particle system
  14878. */
  14879. removeRampGradient(gradient: number): ParticleSystem;
  14880. /**
  14881. * Adds a new color gradient
  14882. * @param gradient defines the gradient to use (between 0 and 1)
  14883. * @param color1 defines the color to affect to the specified gradient
  14884. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14885. * @returns this particle system
  14886. */
  14887. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14888. /**
  14889. * Remove a specific color gradient
  14890. * @param gradient defines the gradient to remove
  14891. * @returns this particle system
  14892. */
  14893. removeColorGradient(gradient: number): IParticleSystem;
  14894. private _fetchR;
  14895. protected _reset(): void;
  14896. private _resetEffect;
  14897. private _createVertexBuffers;
  14898. private _createIndexBuffer;
  14899. /**
  14900. * Gets the maximum number of particles active at the same time.
  14901. * @returns The max number of active particles.
  14902. */
  14903. getCapacity(): number;
  14904. /**
  14905. * Gets whether there are still active particles in the system.
  14906. * @returns True if it is alive, otherwise false.
  14907. */
  14908. isAlive(): boolean;
  14909. /**
  14910. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14911. * @returns True if it has been started, otherwise false.
  14912. */
  14913. isStarted(): boolean;
  14914. private _prepareSubEmitterInternalArray;
  14915. /**
  14916. * Starts the particle system and begins to emit
  14917. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14918. */
  14919. start(delay?: number): void;
  14920. /**
  14921. * Stops the particle system.
  14922. * @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.
  14923. */
  14924. stop(stopSubEmitters?: boolean): void;
  14925. /**
  14926. * Remove all active particles
  14927. */
  14928. reset(): void;
  14929. /**
  14930. * @hidden (for internal use only)
  14931. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14932. /**
  14933. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14934. * Its lifetime will start back at 0.
  14935. */
  14936. recycleParticle: (particle: Particle) => void;
  14937. private _stopSubEmitters;
  14938. private _createParticle;
  14939. private _removeFromRoot;
  14940. private _emitFromParticle;
  14941. private _update;
  14942. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14943. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14944. /** @hidden */
  14945. private _getEffect;
  14946. /**
  14947. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14948. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14949. */
  14950. animate(preWarmOnly?: boolean): void;
  14951. private _appendParticleVertices;
  14952. /**
  14953. * Rebuilds the particle system.
  14954. */
  14955. rebuild(): void;
  14956. /**
  14957. * Is this system ready to be used/rendered
  14958. * @return true if the system is ready
  14959. */
  14960. isReady(): boolean;
  14961. private _render;
  14962. /**
  14963. * Renders the particle system in its current state.
  14964. * @returns the current number of particles
  14965. */
  14966. render(): number;
  14967. /**
  14968. * Disposes the particle system and free the associated resources
  14969. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14970. */
  14971. dispose(disposeTexture?: boolean): void;
  14972. /**
  14973. * Clones the particle system.
  14974. * @param name The name of the cloned object
  14975. * @param newEmitter The new emitter to use
  14976. * @returns the cloned particle system
  14977. */
  14978. clone(name: string, newEmitter: any): ParticleSystem;
  14979. /**
  14980. * Serializes the particle system to a JSON object.
  14981. * @returns the JSON object
  14982. */
  14983. serialize(): any;
  14984. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14985. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14986. /**
  14987. * Parses a JSON object to create a particle system.
  14988. * @param parsedParticleSystem The JSON object to parse
  14989. * @param scene The scene to create the particle system in
  14990. * @param rootUrl The root url to use to load external dependencies like texture
  14991. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14992. * @returns the Parsed particle system
  14993. */
  14994. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14995. }
  14996. }
  14997. declare module BABYLON {
  14998. /**
  14999. * A particle represents one of the element emitted by a particle system.
  15000. * This is mainly define by its coordinates, direction, velocity and age.
  15001. */
  15002. export class Particle {
  15003. /**
  15004. * The particle system the particle belongs to.
  15005. */
  15006. particleSystem: ParticleSystem;
  15007. private static _Count;
  15008. /**
  15009. * Unique ID of the particle
  15010. */
  15011. id: number;
  15012. /**
  15013. * The world position of the particle in the scene.
  15014. */
  15015. position: Vector3;
  15016. /**
  15017. * The world direction of the particle in the scene.
  15018. */
  15019. direction: Vector3;
  15020. /**
  15021. * The color of the particle.
  15022. */
  15023. color: Color4;
  15024. /**
  15025. * The color change of the particle per step.
  15026. */
  15027. colorStep: Color4;
  15028. /**
  15029. * Defines how long will the life of the particle be.
  15030. */
  15031. lifeTime: number;
  15032. /**
  15033. * The current age of the particle.
  15034. */
  15035. age: number;
  15036. /**
  15037. * The current size of the particle.
  15038. */
  15039. size: number;
  15040. /**
  15041. * The current scale of the particle.
  15042. */
  15043. scale: Vector2;
  15044. /**
  15045. * The current angle of the particle.
  15046. */
  15047. angle: number;
  15048. /**
  15049. * Defines how fast is the angle changing.
  15050. */
  15051. angularSpeed: number;
  15052. /**
  15053. * Defines the cell index used by the particle to be rendered from a sprite.
  15054. */
  15055. cellIndex: number;
  15056. /**
  15057. * The information required to support color remapping
  15058. */
  15059. remapData: Vector4;
  15060. /** @hidden */ randomCellOffset?: number;
  15061. /** @hidden */ initialDirection: Nullable<Vector3>;
  15062. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15063. /** @hidden */ initialStartSpriteCellID: number;
  15064. /** @hidden */ initialEndSpriteCellID: number;
  15065. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  15066. /** @hidden */ currentColor1: Color4;
  15067. /** @hidden */ currentColor2: Color4;
  15068. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  15069. /** @hidden */ currentSize1: number;
  15070. /** @hidden */ currentSize2: number;
  15071. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  15072. /** @hidden */ currentAngularSpeed1: number;
  15073. /** @hidden */ currentAngularSpeed2: number;
  15074. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  15075. /** @hidden */ currentVelocity1: number;
  15076. /** @hidden */ currentVelocity2: number;
  15077. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  15078. /** @hidden */ currentLimitVelocity1: number;
  15079. /** @hidden */ currentLimitVelocity2: number;
  15080. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  15081. /** @hidden */ currentDrag1: number;
  15082. /** @hidden */ currentDrag2: number;
  15083. /** @hidden */ randomNoiseCoordinates1: Vector3;
  15084. /** @hidden */ randomNoiseCoordinates2: Vector3;
  15085. /**
  15086. * Creates a new instance Particle
  15087. * @param particleSystem the particle system the particle belongs to
  15088. */
  15089. constructor(
  15090. /**
  15091. * The particle system the particle belongs to.
  15092. */
  15093. particleSystem: ParticleSystem);
  15094. private updateCellInfoFromSystem;
  15095. /**
  15096. * Defines how the sprite cell index is updated for the particle
  15097. */
  15098. updateCellIndex(): void;
  15099. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15100. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  15101. /** @hidden */ reset(): void;
  15102. /**
  15103. * Copy the properties of particle to another one.
  15104. * @param other the particle to copy the information to.
  15105. */
  15106. copyTo(other: Particle): void;
  15107. }
  15108. }
  15109. declare module BABYLON {
  15110. /**
  15111. * Particle emitter represents a volume emitting particles.
  15112. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15113. */
  15114. export interface IParticleEmitterType {
  15115. /**
  15116. * Called by the particle System when the direction is computed for the created particle.
  15117. * @param worldMatrix is the world matrix of the particle system
  15118. * @param directionToUpdate is the direction vector to update with the result
  15119. * @param particle is the particle we are computed the direction for
  15120. */
  15121. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15122. /**
  15123. * Called by the particle System when the position is computed for the created particle.
  15124. * @param worldMatrix is the world matrix of the particle system
  15125. * @param positionToUpdate is the position vector to update with the result
  15126. * @param particle is the particle we are computed the position for
  15127. */
  15128. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15129. /**
  15130. * Clones the current emitter and returns a copy of it
  15131. * @returns the new emitter
  15132. */
  15133. clone(): IParticleEmitterType;
  15134. /**
  15135. * Called by the GPUParticleSystem to setup the update shader
  15136. * @param effect defines the update shader
  15137. */
  15138. applyToShader(effect: Effect): void;
  15139. /**
  15140. * Returns a string to use to update the GPU particles update shader
  15141. * @returns the effect defines string
  15142. */
  15143. getEffectDefines(): string;
  15144. /**
  15145. * Returns a string representing the class name
  15146. * @returns a string containing the class name
  15147. */
  15148. getClassName(): string;
  15149. /**
  15150. * Serializes the particle system to a JSON object.
  15151. * @returns the JSON object
  15152. */
  15153. serialize(): any;
  15154. /**
  15155. * Parse properties from a JSON object
  15156. * @param serializationObject defines the JSON object
  15157. */
  15158. parse(serializationObject: any): void;
  15159. }
  15160. }
  15161. declare module BABYLON {
  15162. /**
  15163. * Particle emitter emitting particles from the inside of a box.
  15164. * It emits the particles randomly between 2 given directions.
  15165. */
  15166. export class BoxParticleEmitter implements IParticleEmitterType {
  15167. /**
  15168. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15169. */
  15170. direction1: Vector3;
  15171. /**
  15172. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15173. */
  15174. direction2: Vector3;
  15175. /**
  15176. * 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.
  15177. */
  15178. minEmitBox: Vector3;
  15179. /**
  15180. * 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.
  15181. */
  15182. maxEmitBox: Vector3;
  15183. /**
  15184. * Creates a new instance BoxParticleEmitter
  15185. */
  15186. constructor();
  15187. /**
  15188. * Called by the particle System when the direction is computed for the created particle.
  15189. * @param worldMatrix is the world matrix of the particle system
  15190. * @param directionToUpdate is the direction vector to update with the result
  15191. * @param particle is the particle we are computed the direction for
  15192. */
  15193. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15194. /**
  15195. * Called by the particle System when the position is computed for the created particle.
  15196. * @param worldMatrix is the world matrix of the particle system
  15197. * @param positionToUpdate is the position vector to update with the result
  15198. * @param particle is the particle we are computed the position for
  15199. */
  15200. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15201. /**
  15202. * Clones the current emitter and returns a copy of it
  15203. * @returns the new emitter
  15204. */
  15205. clone(): BoxParticleEmitter;
  15206. /**
  15207. * Called by the GPUParticleSystem to setup the update shader
  15208. * @param effect defines the update shader
  15209. */
  15210. applyToShader(effect: Effect): void;
  15211. /**
  15212. * Returns a string to use to update the GPU particles update shader
  15213. * @returns a string containng the defines string
  15214. */
  15215. getEffectDefines(): string;
  15216. /**
  15217. * Returns the string "BoxParticleEmitter"
  15218. * @returns a string containing the class name
  15219. */
  15220. getClassName(): string;
  15221. /**
  15222. * Serializes the particle system to a JSON object.
  15223. * @returns the JSON object
  15224. */
  15225. serialize(): any;
  15226. /**
  15227. * Parse properties from a JSON object
  15228. * @param serializationObject defines the JSON object
  15229. */
  15230. parse(serializationObject: any): void;
  15231. }
  15232. }
  15233. declare module BABYLON {
  15234. /**
  15235. * Particle emitter emitting particles from the inside of a cone.
  15236. * It emits the particles alongside the cone volume from the base to the particle.
  15237. * The emission direction might be randomized.
  15238. */
  15239. export class ConeParticleEmitter implements IParticleEmitterType {
  15240. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15241. directionRandomizer: number;
  15242. private _radius;
  15243. private _angle;
  15244. private _height;
  15245. /**
  15246. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15247. */
  15248. radiusRange: number;
  15249. /**
  15250. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15251. */
  15252. heightRange: number;
  15253. /**
  15254. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15255. */
  15256. emitFromSpawnPointOnly: boolean;
  15257. /**
  15258. * Gets or sets the radius of the emission cone
  15259. */
  15260. radius: number;
  15261. /**
  15262. * Gets or sets the angle of the emission cone
  15263. */
  15264. angle: number;
  15265. private _buildHeight;
  15266. /**
  15267. * Creates a new instance ConeParticleEmitter
  15268. * @param radius the radius of the emission cone (1 by default)
  15269. * @param angle the cone base angle (PI by default)
  15270. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15271. */
  15272. constructor(radius?: number, angle?: number,
  15273. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15274. directionRandomizer?: number);
  15275. /**
  15276. * Called by the particle System when the direction is computed for the created particle.
  15277. * @param worldMatrix is the world matrix of the particle system
  15278. * @param directionToUpdate is the direction vector to update with the result
  15279. * @param particle is the particle we are computed the direction for
  15280. */
  15281. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15282. /**
  15283. * Called by the particle System when the position is computed for the created particle.
  15284. * @param worldMatrix is the world matrix of the particle system
  15285. * @param positionToUpdate is the position vector to update with the result
  15286. * @param particle is the particle we are computed the position for
  15287. */
  15288. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15289. /**
  15290. * Clones the current emitter and returns a copy of it
  15291. * @returns the new emitter
  15292. */
  15293. clone(): ConeParticleEmitter;
  15294. /**
  15295. * Called by the GPUParticleSystem to setup the update shader
  15296. * @param effect defines the update shader
  15297. */
  15298. applyToShader(effect: Effect): void;
  15299. /**
  15300. * Returns a string to use to update the GPU particles update shader
  15301. * @returns a string containng the defines string
  15302. */
  15303. getEffectDefines(): string;
  15304. /**
  15305. * Returns the string "ConeParticleEmitter"
  15306. * @returns a string containing the class name
  15307. */
  15308. getClassName(): string;
  15309. /**
  15310. * Serializes the particle system to a JSON object.
  15311. * @returns the JSON object
  15312. */
  15313. serialize(): any;
  15314. /**
  15315. * Parse properties from a JSON object
  15316. * @param serializationObject defines the JSON object
  15317. */
  15318. parse(serializationObject: any): void;
  15319. }
  15320. }
  15321. declare module BABYLON {
  15322. /**
  15323. * Particle emitter emitting particles from the inside of a cylinder.
  15324. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15325. */
  15326. export class CylinderParticleEmitter implements IParticleEmitterType {
  15327. /**
  15328. * The radius of the emission cylinder.
  15329. */
  15330. radius: number;
  15331. /**
  15332. * The height of the emission cylinder.
  15333. */
  15334. height: number;
  15335. /**
  15336. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15337. */
  15338. radiusRange: number;
  15339. /**
  15340. * How much to randomize the particle direction [0-1].
  15341. */
  15342. directionRandomizer: number;
  15343. /**
  15344. * Creates a new instance CylinderParticleEmitter
  15345. * @param radius the radius of the emission cylinder (1 by default)
  15346. * @param height the height of the emission cylinder (1 by default)
  15347. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15348. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15349. */
  15350. constructor(
  15351. /**
  15352. * The radius of the emission cylinder.
  15353. */
  15354. radius?: number,
  15355. /**
  15356. * The height of the emission cylinder.
  15357. */
  15358. height?: number,
  15359. /**
  15360. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15361. */
  15362. radiusRange?: number,
  15363. /**
  15364. * How much to randomize the particle direction [0-1].
  15365. */
  15366. directionRandomizer?: number);
  15367. /**
  15368. * Called by the particle System when the direction is computed for the created particle.
  15369. * @param worldMatrix is the world matrix of the particle system
  15370. * @param directionToUpdate is the direction vector to update with the result
  15371. * @param particle is the particle we are computed the direction for
  15372. */
  15373. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15374. /**
  15375. * Called by the particle System when the position is computed for the created particle.
  15376. * @param worldMatrix is the world matrix of the particle system
  15377. * @param positionToUpdate is the position vector to update with the result
  15378. * @param particle is the particle we are computed the position for
  15379. */
  15380. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15381. /**
  15382. * Clones the current emitter and returns a copy of it
  15383. * @returns the new emitter
  15384. */
  15385. clone(): CylinderParticleEmitter;
  15386. /**
  15387. * Called by the GPUParticleSystem to setup the update shader
  15388. * @param effect defines the update shader
  15389. */
  15390. applyToShader(effect: Effect): void;
  15391. /**
  15392. * Returns a string to use to update the GPU particles update shader
  15393. * @returns a string containng the defines string
  15394. */
  15395. getEffectDefines(): string;
  15396. /**
  15397. * Returns the string "CylinderParticleEmitter"
  15398. * @returns a string containing the class name
  15399. */
  15400. getClassName(): string;
  15401. /**
  15402. * Serializes the particle system to a JSON object.
  15403. * @returns the JSON object
  15404. */
  15405. serialize(): any;
  15406. /**
  15407. * Parse properties from a JSON object
  15408. * @param serializationObject defines the JSON object
  15409. */
  15410. parse(serializationObject: any): void;
  15411. }
  15412. /**
  15413. * Particle emitter emitting particles from the inside of a cylinder.
  15414. * It emits the particles randomly between two vectors.
  15415. */
  15416. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15417. /**
  15418. * The min limit of the emission direction.
  15419. */
  15420. direction1: Vector3;
  15421. /**
  15422. * The max limit of the emission direction.
  15423. */
  15424. direction2: Vector3;
  15425. /**
  15426. * Creates a new instance CylinderDirectedParticleEmitter
  15427. * @param radius the radius of the emission cylinder (1 by default)
  15428. * @param height the height of the emission cylinder (1 by default)
  15429. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15430. * @param direction1 the min limit of the emission direction (up vector by default)
  15431. * @param direction2 the max limit of the emission direction (up vector by default)
  15432. */
  15433. constructor(radius?: number, height?: number, radiusRange?: number,
  15434. /**
  15435. * The min limit of the emission direction.
  15436. */
  15437. direction1?: Vector3,
  15438. /**
  15439. * The max limit of the emission direction.
  15440. */
  15441. direction2?: Vector3);
  15442. /**
  15443. * Called by the particle System when the direction is computed for the created particle.
  15444. * @param worldMatrix is the world matrix of the particle system
  15445. * @param directionToUpdate is the direction vector to update with the result
  15446. * @param particle is the particle we are computed the direction for
  15447. */
  15448. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15449. /**
  15450. * Clones the current emitter and returns a copy of it
  15451. * @returns the new emitter
  15452. */
  15453. clone(): CylinderDirectedParticleEmitter;
  15454. /**
  15455. * Called by the GPUParticleSystem to setup the update shader
  15456. * @param effect defines the update shader
  15457. */
  15458. applyToShader(effect: Effect): void;
  15459. /**
  15460. * Returns a string to use to update the GPU particles update shader
  15461. * @returns a string containng the defines string
  15462. */
  15463. getEffectDefines(): string;
  15464. /**
  15465. * Returns the string "CylinderDirectedParticleEmitter"
  15466. * @returns a string containing the class name
  15467. */
  15468. getClassName(): string;
  15469. /**
  15470. * Serializes the particle system to a JSON object.
  15471. * @returns the JSON object
  15472. */
  15473. serialize(): any;
  15474. /**
  15475. * Parse properties from a JSON object
  15476. * @param serializationObject defines the JSON object
  15477. */
  15478. parse(serializationObject: any): void;
  15479. }
  15480. }
  15481. declare module BABYLON {
  15482. /**
  15483. * Particle emitter emitting particles from the inside of a hemisphere.
  15484. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15485. */
  15486. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15487. /**
  15488. * The radius of the emission hemisphere.
  15489. */
  15490. radius: number;
  15491. /**
  15492. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15493. */
  15494. radiusRange: number;
  15495. /**
  15496. * How much to randomize the particle direction [0-1].
  15497. */
  15498. directionRandomizer: number;
  15499. /**
  15500. * Creates a new instance HemisphericParticleEmitter
  15501. * @param radius the radius of the emission hemisphere (1 by default)
  15502. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15503. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15504. */
  15505. constructor(
  15506. /**
  15507. * The radius of the emission hemisphere.
  15508. */
  15509. radius?: number,
  15510. /**
  15511. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15512. */
  15513. radiusRange?: number,
  15514. /**
  15515. * How much to randomize the particle direction [0-1].
  15516. */
  15517. directionRandomizer?: number);
  15518. /**
  15519. * Called by the particle System when the direction is computed for the created particle.
  15520. * @param worldMatrix is the world matrix of the particle system
  15521. * @param directionToUpdate is the direction vector to update with the result
  15522. * @param particle is the particle we are computed the direction for
  15523. */
  15524. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15525. /**
  15526. * Called by the particle System when the position is computed for the created particle.
  15527. * @param worldMatrix is the world matrix of the particle system
  15528. * @param positionToUpdate is the position vector to update with the result
  15529. * @param particle is the particle we are computed the position for
  15530. */
  15531. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15532. /**
  15533. * Clones the current emitter and returns a copy of it
  15534. * @returns the new emitter
  15535. */
  15536. clone(): HemisphericParticleEmitter;
  15537. /**
  15538. * Called by the GPUParticleSystem to setup the update shader
  15539. * @param effect defines the update shader
  15540. */
  15541. applyToShader(effect: Effect): void;
  15542. /**
  15543. * Returns a string to use to update the GPU particles update shader
  15544. * @returns a string containng the defines string
  15545. */
  15546. getEffectDefines(): string;
  15547. /**
  15548. * Returns the string "HemisphericParticleEmitter"
  15549. * @returns a string containing the class name
  15550. */
  15551. getClassName(): string;
  15552. /**
  15553. * Serializes the particle system to a JSON object.
  15554. * @returns the JSON object
  15555. */
  15556. serialize(): any;
  15557. /**
  15558. * Parse properties from a JSON object
  15559. * @param serializationObject defines the JSON object
  15560. */
  15561. parse(serializationObject: any): void;
  15562. }
  15563. }
  15564. declare module BABYLON {
  15565. /**
  15566. * Particle emitter emitting particles from a point.
  15567. * It emits the particles randomly between 2 given directions.
  15568. */
  15569. export class PointParticleEmitter implements IParticleEmitterType {
  15570. /**
  15571. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15572. */
  15573. direction1: Vector3;
  15574. /**
  15575. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15576. */
  15577. direction2: Vector3;
  15578. /**
  15579. * Creates a new instance PointParticleEmitter
  15580. */
  15581. constructor();
  15582. /**
  15583. * Called by the particle System when the direction is computed for the created particle.
  15584. * @param worldMatrix is the world matrix of the particle system
  15585. * @param directionToUpdate is the direction vector to update with the result
  15586. * @param particle is the particle we are computed the direction for
  15587. */
  15588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15589. /**
  15590. * Called by the particle System when the position is computed for the created particle.
  15591. * @param worldMatrix is the world matrix of the particle system
  15592. * @param positionToUpdate is the position vector to update with the result
  15593. * @param particle is the particle we are computed the position for
  15594. */
  15595. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15596. /**
  15597. * Clones the current emitter and returns a copy of it
  15598. * @returns the new emitter
  15599. */
  15600. clone(): PointParticleEmitter;
  15601. /**
  15602. * Called by the GPUParticleSystem to setup the update shader
  15603. * @param effect defines the update shader
  15604. */
  15605. applyToShader(effect: Effect): void;
  15606. /**
  15607. * Returns a string to use to update the GPU particles update shader
  15608. * @returns a string containng the defines string
  15609. */
  15610. getEffectDefines(): string;
  15611. /**
  15612. * Returns the string "PointParticleEmitter"
  15613. * @returns a string containing the class name
  15614. */
  15615. getClassName(): string;
  15616. /**
  15617. * Serializes the particle system to a JSON object.
  15618. * @returns the JSON object
  15619. */
  15620. serialize(): any;
  15621. /**
  15622. * Parse properties from a JSON object
  15623. * @param serializationObject defines the JSON object
  15624. */
  15625. parse(serializationObject: any): void;
  15626. }
  15627. }
  15628. declare module BABYLON {
  15629. /**
  15630. * Particle emitter emitting particles from the inside of a sphere.
  15631. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15632. */
  15633. export class SphereParticleEmitter implements IParticleEmitterType {
  15634. /**
  15635. * The radius of the emission sphere.
  15636. */
  15637. radius: number;
  15638. /**
  15639. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15640. */
  15641. radiusRange: number;
  15642. /**
  15643. * How much to randomize the particle direction [0-1].
  15644. */
  15645. directionRandomizer: number;
  15646. /**
  15647. * Creates a new instance SphereParticleEmitter
  15648. * @param radius the radius of the emission sphere (1 by default)
  15649. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15650. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15651. */
  15652. constructor(
  15653. /**
  15654. * The radius of the emission sphere.
  15655. */
  15656. radius?: number,
  15657. /**
  15658. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15659. */
  15660. radiusRange?: number,
  15661. /**
  15662. * How much to randomize the particle direction [0-1].
  15663. */
  15664. directionRandomizer?: number);
  15665. /**
  15666. * Called by the particle System when the direction is computed for the created particle.
  15667. * @param worldMatrix is the world matrix of the particle system
  15668. * @param directionToUpdate is the direction vector to update with the result
  15669. * @param particle is the particle we are computed the direction for
  15670. */
  15671. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15672. /**
  15673. * Called by the particle System when the position is computed for the created particle.
  15674. * @param worldMatrix is the world matrix of the particle system
  15675. * @param positionToUpdate is the position vector to update with the result
  15676. * @param particle is the particle we are computed the position for
  15677. */
  15678. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15679. /**
  15680. * Clones the current emitter and returns a copy of it
  15681. * @returns the new emitter
  15682. */
  15683. clone(): SphereParticleEmitter;
  15684. /**
  15685. * Called by the GPUParticleSystem to setup the update shader
  15686. * @param effect defines the update shader
  15687. */
  15688. applyToShader(effect: Effect): void;
  15689. /**
  15690. * Returns a string to use to update the GPU particles update shader
  15691. * @returns a string containng the defines string
  15692. */
  15693. getEffectDefines(): string;
  15694. /**
  15695. * Returns the string "SphereParticleEmitter"
  15696. * @returns a string containing the class name
  15697. */
  15698. getClassName(): string;
  15699. /**
  15700. * Serializes the particle system to a JSON object.
  15701. * @returns the JSON object
  15702. */
  15703. serialize(): any;
  15704. /**
  15705. * Parse properties from a JSON object
  15706. * @param serializationObject defines the JSON object
  15707. */
  15708. parse(serializationObject: any): void;
  15709. }
  15710. /**
  15711. * Particle emitter emitting particles from the inside of a sphere.
  15712. * It emits the particles randomly between two vectors.
  15713. */
  15714. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15715. /**
  15716. * The min limit of the emission direction.
  15717. */
  15718. direction1: Vector3;
  15719. /**
  15720. * The max limit of the emission direction.
  15721. */
  15722. direction2: Vector3;
  15723. /**
  15724. * Creates a new instance SphereDirectedParticleEmitter
  15725. * @param radius the radius of the emission sphere (1 by default)
  15726. * @param direction1 the min limit of the emission direction (up vector by default)
  15727. * @param direction2 the max limit of the emission direction (up vector by default)
  15728. */
  15729. constructor(radius?: number,
  15730. /**
  15731. * The min limit of the emission direction.
  15732. */
  15733. direction1?: Vector3,
  15734. /**
  15735. * The max limit of the emission direction.
  15736. */
  15737. direction2?: Vector3);
  15738. /**
  15739. * Called by the particle System when the direction is computed for the created particle.
  15740. * @param worldMatrix is the world matrix of the particle system
  15741. * @param directionToUpdate is the direction vector to update with the result
  15742. * @param particle is the particle we are computed the direction for
  15743. */
  15744. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15745. /**
  15746. * Clones the current emitter and returns a copy of it
  15747. * @returns the new emitter
  15748. */
  15749. clone(): SphereDirectedParticleEmitter;
  15750. /**
  15751. * Called by the GPUParticleSystem to setup the update shader
  15752. * @param effect defines the update shader
  15753. */
  15754. applyToShader(effect: Effect): void;
  15755. /**
  15756. * Returns a string to use to update the GPU particles update shader
  15757. * @returns a string containng the defines string
  15758. */
  15759. getEffectDefines(): string;
  15760. /**
  15761. * Returns the string "SphereDirectedParticleEmitter"
  15762. * @returns a string containing the class name
  15763. */
  15764. getClassName(): string;
  15765. /**
  15766. * Serializes the particle system to a JSON object.
  15767. * @returns the JSON object
  15768. */
  15769. serialize(): any;
  15770. /**
  15771. * Parse properties from a JSON object
  15772. * @param serializationObject defines the JSON object
  15773. */
  15774. parse(serializationObject: any): void;
  15775. }
  15776. }
  15777. declare module BABYLON {
  15778. /**
  15779. * Interface representing a particle system in Babylon.js.
  15780. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15781. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15782. */
  15783. export interface IParticleSystem {
  15784. /**
  15785. * List of animations used by the particle system.
  15786. */
  15787. animations: Animation[];
  15788. /**
  15789. * The id of the Particle system.
  15790. */
  15791. id: string;
  15792. /**
  15793. * The name of the Particle system.
  15794. */
  15795. name: string;
  15796. /**
  15797. * The emitter represents the Mesh or position we are attaching the particle system to.
  15798. */
  15799. emitter: Nullable<AbstractMesh | Vector3>;
  15800. /**
  15801. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15802. */
  15803. isBillboardBased: boolean;
  15804. /**
  15805. * The rendering group used by the Particle system to chose when to render.
  15806. */
  15807. renderingGroupId: number;
  15808. /**
  15809. * The layer mask we are rendering the particles through.
  15810. */
  15811. layerMask: number;
  15812. /**
  15813. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15814. */
  15815. updateSpeed: number;
  15816. /**
  15817. * The amount of time the particle system is running (depends of the overall update speed).
  15818. */
  15819. targetStopDuration: number;
  15820. /**
  15821. * The texture used to render each particle. (this can be a spritesheet)
  15822. */
  15823. particleTexture: Nullable<Texture>;
  15824. /**
  15825. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15826. */
  15827. blendMode: number;
  15828. /**
  15829. * Minimum life time of emitting particles.
  15830. */
  15831. minLifeTime: number;
  15832. /**
  15833. * Maximum life time of emitting particles.
  15834. */
  15835. maxLifeTime: number;
  15836. /**
  15837. * Minimum Size of emitting particles.
  15838. */
  15839. minSize: number;
  15840. /**
  15841. * Maximum Size of emitting particles.
  15842. */
  15843. maxSize: number;
  15844. /**
  15845. * Minimum scale of emitting particles on X axis.
  15846. */
  15847. minScaleX: number;
  15848. /**
  15849. * Maximum scale of emitting particles on X axis.
  15850. */
  15851. maxScaleX: number;
  15852. /**
  15853. * Minimum scale of emitting particles on Y axis.
  15854. */
  15855. minScaleY: number;
  15856. /**
  15857. * Maximum scale of emitting particles on Y axis.
  15858. */
  15859. maxScaleY: number;
  15860. /**
  15861. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15862. */
  15863. color1: Color4;
  15864. /**
  15865. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15866. */
  15867. color2: Color4;
  15868. /**
  15869. * Color the particle will have at the end of its lifetime.
  15870. */
  15871. colorDead: Color4;
  15872. /**
  15873. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15874. */
  15875. emitRate: number;
  15876. /**
  15877. * You can use gravity if you want to give an orientation to your particles.
  15878. */
  15879. gravity: Vector3;
  15880. /**
  15881. * Minimum power of emitting particles.
  15882. */
  15883. minEmitPower: number;
  15884. /**
  15885. * Maximum power of emitting particles.
  15886. */
  15887. maxEmitPower: number;
  15888. /**
  15889. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15890. */
  15891. minAngularSpeed: number;
  15892. /**
  15893. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15894. */
  15895. maxAngularSpeed: number;
  15896. /**
  15897. * Gets or sets the minimal initial rotation in radians.
  15898. */
  15899. minInitialRotation: number;
  15900. /**
  15901. * Gets or sets the maximal initial rotation in radians.
  15902. */
  15903. maxInitialRotation: number;
  15904. /**
  15905. * The particle emitter type defines the emitter used by the particle system.
  15906. * It can be for example box, sphere, or cone...
  15907. */
  15908. particleEmitterType: Nullable<IParticleEmitterType>;
  15909. /**
  15910. * Defines the delay in milliseconds before starting the system (0 by default)
  15911. */
  15912. startDelay: number;
  15913. /**
  15914. * 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
  15915. */
  15916. preWarmCycles: number;
  15917. /**
  15918. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15919. */
  15920. preWarmStepOffset: number;
  15921. /**
  15922. * 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)
  15923. */
  15924. spriteCellChangeSpeed: number;
  15925. /**
  15926. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15927. */
  15928. startSpriteCellID: number;
  15929. /**
  15930. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15931. */
  15932. endSpriteCellID: number;
  15933. /**
  15934. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15935. */
  15936. spriteCellWidth: number;
  15937. /**
  15938. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15939. */
  15940. spriteCellHeight: number;
  15941. /**
  15942. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15943. */
  15944. spriteRandomStartCell: boolean;
  15945. /**
  15946. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15947. */
  15948. isAnimationSheetEnabled: boolean;
  15949. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15950. translationPivot: Vector2;
  15951. /**
  15952. * Gets or sets a texture used to add random noise to particle positions
  15953. */
  15954. noiseTexture: Nullable<BaseTexture>;
  15955. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15956. noiseStrength: Vector3;
  15957. /**
  15958. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15959. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15960. */
  15961. billboardMode: number;
  15962. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15963. limitVelocityDamping: number;
  15964. /**
  15965. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15966. */
  15967. beginAnimationOnStart: boolean;
  15968. /**
  15969. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15970. */
  15971. beginAnimationFrom: number;
  15972. /**
  15973. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15974. */
  15975. beginAnimationTo: number;
  15976. /**
  15977. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15978. */
  15979. beginAnimationLoop: boolean;
  15980. /**
  15981. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15982. */
  15983. disposeOnStop: boolean;
  15984. /**
  15985. * Gets the maximum number of particles active at the same time.
  15986. * @returns The max number of active particles.
  15987. */
  15988. getCapacity(): number;
  15989. /**
  15990. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15991. * @returns True if it has been started, otherwise false.
  15992. */
  15993. isStarted(): boolean;
  15994. /**
  15995. * Animates the particle system for this frame.
  15996. */
  15997. animate(): void;
  15998. /**
  15999. * Renders the particle system in its current state.
  16000. * @returns the current number of particles
  16001. */
  16002. render(): number;
  16003. /**
  16004. * Dispose the particle system and frees its associated resources.
  16005. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16006. */
  16007. dispose(disposeTexture?: boolean): void;
  16008. /**
  16009. * Clones the particle system.
  16010. * @param name The name of the cloned object
  16011. * @param newEmitter The new emitter to use
  16012. * @returns the cloned particle system
  16013. */
  16014. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16015. /**
  16016. * Serializes the particle system to a JSON object.
  16017. * @returns the JSON object
  16018. */
  16019. serialize(): any;
  16020. /**
  16021. * Rebuild the particle system
  16022. */
  16023. rebuild(): void;
  16024. /**
  16025. * Starts the particle system and begins to emit
  16026. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16027. */
  16028. start(delay?: number): void;
  16029. /**
  16030. * Stops the particle system.
  16031. */
  16032. stop(): void;
  16033. /**
  16034. * Remove all active particles
  16035. */
  16036. reset(): void;
  16037. /**
  16038. * Is this system ready to be used/rendered
  16039. * @return true if the system is ready
  16040. */
  16041. isReady(): boolean;
  16042. /**
  16043. * Adds a new color gradient
  16044. * @param gradient defines the gradient to use (between 0 and 1)
  16045. * @param color1 defines the color to affect to the specified gradient
  16046. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16047. * @returns the current particle system
  16048. */
  16049. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16050. /**
  16051. * Remove a specific color gradient
  16052. * @param gradient defines the gradient to remove
  16053. * @returns the current particle system
  16054. */
  16055. removeColorGradient(gradient: number): IParticleSystem;
  16056. /**
  16057. * Adds a new size gradient
  16058. * @param gradient defines the gradient to use (between 0 and 1)
  16059. * @param factor defines the size factor to affect to the specified gradient
  16060. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16061. * @returns the current particle system
  16062. */
  16063. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16064. /**
  16065. * Remove a specific size gradient
  16066. * @param gradient defines the gradient to remove
  16067. * @returns the current particle system
  16068. */
  16069. removeSizeGradient(gradient: number): IParticleSystem;
  16070. /**
  16071. * Gets the current list of color gradients.
  16072. * You must use addColorGradient and removeColorGradient to udpate this list
  16073. * @returns the list of color gradients
  16074. */
  16075. getColorGradients(): Nullable<Array<ColorGradient>>;
  16076. /**
  16077. * Gets the current list of size gradients.
  16078. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16079. * @returns the list of size gradients
  16080. */
  16081. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16082. /**
  16083. * Gets the current list of angular speed gradients.
  16084. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16085. * @returns the list of angular speed gradients
  16086. */
  16087. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16088. /**
  16089. * Adds a new angular speed gradient
  16090. * @param gradient defines the gradient to use (between 0 and 1)
  16091. * @param factor defines the angular speed to affect to the specified gradient
  16092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16093. * @returns the current particle system
  16094. */
  16095. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16096. /**
  16097. * Remove a specific angular speed gradient
  16098. * @param gradient defines the gradient to remove
  16099. * @returns the current particle system
  16100. */
  16101. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16102. /**
  16103. * Gets the current list of velocity gradients.
  16104. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16105. * @returns the list of velocity gradients
  16106. */
  16107. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16108. /**
  16109. * Adds a new velocity gradient
  16110. * @param gradient defines the gradient to use (between 0 and 1)
  16111. * @param factor defines the velocity to affect to the specified gradient
  16112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16113. * @returns the current particle system
  16114. */
  16115. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16116. /**
  16117. * Remove a specific velocity gradient
  16118. * @param gradient defines the gradient to remove
  16119. * @returns the current particle system
  16120. */
  16121. removeVelocityGradient(gradient: number): IParticleSystem;
  16122. /**
  16123. * Gets the current list of limit velocity gradients.
  16124. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16125. * @returns the list of limit velocity gradients
  16126. */
  16127. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16128. /**
  16129. * Adds a new limit velocity gradient
  16130. * @param gradient defines the gradient to use (between 0 and 1)
  16131. * @param factor defines the limit velocity to affect to the specified gradient
  16132. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16133. * @returns the current particle system
  16134. */
  16135. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16136. /**
  16137. * Remove a specific limit velocity gradient
  16138. * @param gradient defines the gradient to remove
  16139. * @returns the current particle system
  16140. */
  16141. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16142. /**
  16143. * Adds a new drag gradient
  16144. * @param gradient defines the gradient to use (between 0 and 1)
  16145. * @param factor defines the drag to affect to the specified gradient
  16146. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16147. * @returns the current particle system
  16148. */
  16149. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16150. /**
  16151. * Remove a specific drag gradient
  16152. * @param gradient defines the gradient to remove
  16153. * @returns the current particle system
  16154. */
  16155. removeDragGradient(gradient: number): IParticleSystem;
  16156. /**
  16157. * Gets the current list of drag gradients.
  16158. * You must use addDragGradient and removeDragGradient to udpate this list
  16159. * @returns the list of drag gradients
  16160. */
  16161. getDragGradients(): Nullable<Array<FactorGradient>>;
  16162. /**
  16163. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16164. * @param gradient defines the gradient to use (between 0 and 1)
  16165. * @param factor defines the emit rate to affect to the specified gradient
  16166. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16167. * @returns the current particle system
  16168. */
  16169. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16170. /**
  16171. * Remove a specific emit rate gradient
  16172. * @param gradient defines the gradient to remove
  16173. * @returns the current particle system
  16174. */
  16175. removeEmitRateGradient(gradient: number): IParticleSystem;
  16176. /**
  16177. * Gets the current list of emit rate gradients.
  16178. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16179. * @returns the list of emit rate gradients
  16180. */
  16181. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16182. /**
  16183. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16184. * @param gradient defines the gradient to use (between 0 and 1)
  16185. * @param factor defines the start size to affect to the specified gradient
  16186. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16187. * @returns the current particle system
  16188. */
  16189. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16190. /**
  16191. * Remove a specific start size gradient
  16192. * @param gradient defines the gradient to remove
  16193. * @returns the current particle system
  16194. */
  16195. removeStartSizeGradient(gradient: number): IParticleSystem;
  16196. /**
  16197. * Gets the current list of start size gradients.
  16198. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16199. * @returns the list of start size gradients
  16200. */
  16201. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16202. /**
  16203. * Adds a new life time gradient
  16204. * @param gradient defines the gradient to use (between 0 and 1)
  16205. * @param factor defines the life time factor to affect to the specified gradient
  16206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16207. * @returns the current particle system
  16208. */
  16209. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16210. /**
  16211. * Remove a specific life time gradient
  16212. * @param gradient defines the gradient to remove
  16213. * @returns the current particle system
  16214. */
  16215. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16216. /**
  16217. * Gets the current list of life time gradients.
  16218. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16219. * @returns the list of life time gradients
  16220. */
  16221. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16222. /**
  16223. * Gets the current list of color gradients.
  16224. * You must use addColorGradient and removeColorGradient to udpate this list
  16225. * @returns the list of color gradients
  16226. */
  16227. getColorGradients(): Nullable<Array<ColorGradient>>;
  16228. /**
  16229. * Adds a new ramp gradient used to remap particle colors
  16230. * @param gradient defines the gradient to use (between 0 and 1)
  16231. * @param color defines the color to affect to the specified gradient
  16232. * @returns the current particle system
  16233. */
  16234. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16235. /**
  16236. * Gets the current list of ramp gradients.
  16237. * You must use addRampGradient and removeRampGradient to udpate this list
  16238. * @returns the list of ramp gradients
  16239. */
  16240. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16241. /** Gets or sets a boolean indicating that ramp gradients must be used
  16242. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16243. */
  16244. useRampGradients: boolean;
  16245. /**
  16246. * Adds a new color remap gradient
  16247. * @param gradient defines the gradient to use (between 0 and 1)
  16248. * @param min defines the color remap minimal range
  16249. * @param max defines the color remap maximal range
  16250. * @returns the current particle system
  16251. */
  16252. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16253. /**
  16254. * Gets the current list of color remap gradients.
  16255. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16256. * @returns the list of color remap gradients
  16257. */
  16258. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16259. /**
  16260. * Adds a new alpha remap gradient
  16261. * @param gradient defines the gradient to use (between 0 and 1)
  16262. * @param min defines the alpha remap minimal range
  16263. * @param max defines the alpha remap maximal range
  16264. * @returns the current particle system
  16265. */
  16266. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16267. /**
  16268. * Gets the current list of alpha remap gradients.
  16269. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16270. * @returns the list of alpha remap gradients
  16271. */
  16272. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16273. /**
  16274. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16275. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16276. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16277. * @returns the emitter
  16278. */
  16279. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16280. /**
  16281. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16282. * @param radius The radius of the hemisphere to emit from
  16283. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16284. * @returns the emitter
  16285. */
  16286. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16287. /**
  16288. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16289. * @param radius The radius of the sphere to emit from
  16290. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16291. * @returns the emitter
  16292. */
  16293. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16294. /**
  16295. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16296. * @param radius The radius of the sphere to emit from
  16297. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16298. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16299. * @returns the emitter
  16300. */
  16301. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16302. /**
  16303. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16304. * @param radius The radius of the emission cylinder
  16305. * @param height The height of the emission cylinder
  16306. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16307. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16308. * @returns the emitter
  16309. */
  16310. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16311. /**
  16312. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16313. * @param radius The radius of the cylinder to emit from
  16314. * @param height The height of the emission cylinder
  16315. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16316. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16317. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16318. * @returns the emitter
  16319. */
  16320. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16321. /**
  16322. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16323. * @param radius The radius of the cone to emit from
  16324. * @param angle The base angle of the cone
  16325. * @returns the emitter
  16326. */
  16327. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16328. /**
  16329. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16330. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16331. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16332. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16333. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16334. * @returns the emitter
  16335. */
  16336. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16337. /**
  16338. * Get hosting scene
  16339. * @returns the scene
  16340. */
  16341. getScene(): Scene;
  16342. }
  16343. }
  16344. declare module BABYLON {
  16345. /**
  16346. * Creates an instance based on a source mesh.
  16347. */
  16348. export class InstancedMesh extends AbstractMesh {
  16349. private _sourceMesh;
  16350. private _currentLOD;
  16351. /** @hidden */ indexInSourceMeshInstanceArray: number;
  16352. constructor(name: string, source: Mesh);
  16353. /**
  16354. * Returns the string "InstancedMesh".
  16355. */
  16356. getClassName(): string;
  16357. /**
  16358. * If the source mesh receives shadows
  16359. */
  16360. readonly receiveShadows: boolean;
  16361. /**
  16362. * The material of the source mesh
  16363. */
  16364. readonly material: Nullable<Material>;
  16365. /**
  16366. * Visibility of the source mesh
  16367. */
  16368. readonly visibility: number;
  16369. /**
  16370. * Skeleton of the source mesh
  16371. */
  16372. readonly skeleton: Nullable<Skeleton>;
  16373. /**
  16374. * Rendering ground id of the source mesh
  16375. */
  16376. renderingGroupId: number;
  16377. /**
  16378. * Returns the total number of vertices (integer).
  16379. */
  16380. getTotalVertices(): number;
  16381. /**
  16382. * Returns a positive integer : the total number of indices in this mesh geometry.
  16383. * @returns the numner of indices or zero if the mesh has no geometry.
  16384. */
  16385. getTotalIndices(): number;
  16386. /**
  16387. * The source mesh of the instance
  16388. */
  16389. readonly sourceMesh: Mesh;
  16390. /**
  16391. * Is this node ready to be used/rendered
  16392. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16393. * @return {boolean} is it ready
  16394. */
  16395. isReady(completeCheck?: boolean): boolean;
  16396. /**
  16397. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16398. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16399. * @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.
  16400. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16401. */
  16402. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16403. /**
  16404. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16405. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16406. * The `data` are either a numeric array either a Float32Array.
  16407. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16408. * 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).
  16409. * Note that a new underlying VertexBuffer object is created each call.
  16410. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16411. *
  16412. * Possible `kind` values :
  16413. * - VertexBuffer.PositionKind
  16414. * - VertexBuffer.UVKind
  16415. * - VertexBuffer.UV2Kind
  16416. * - VertexBuffer.UV3Kind
  16417. * - VertexBuffer.UV4Kind
  16418. * - VertexBuffer.UV5Kind
  16419. * - VertexBuffer.UV6Kind
  16420. * - VertexBuffer.ColorKind
  16421. * - VertexBuffer.MatricesIndicesKind
  16422. * - VertexBuffer.MatricesIndicesExtraKind
  16423. * - VertexBuffer.MatricesWeightsKind
  16424. * - VertexBuffer.MatricesWeightsExtraKind
  16425. *
  16426. * Returns the Mesh.
  16427. */
  16428. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16429. /**
  16430. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16431. * If the mesh has no geometry, it is simply returned as it is.
  16432. * The `data` are either a numeric array either a Float32Array.
  16433. * No new underlying VertexBuffer object is created.
  16434. * 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.
  16435. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16436. *
  16437. * Possible `kind` values :
  16438. * - VertexBuffer.PositionKind
  16439. * - VertexBuffer.UVKind
  16440. * - VertexBuffer.UV2Kind
  16441. * - VertexBuffer.UV3Kind
  16442. * - VertexBuffer.UV4Kind
  16443. * - VertexBuffer.UV5Kind
  16444. * - VertexBuffer.UV6Kind
  16445. * - VertexBuffer.ColorKind
  16446. * - VertexBuffer.MatricesIndicesKind
  16447. * - VertexBuffer.MatricesIndicesExtraKind
  16448. * - VertexBuffer.MatricesWeightsKind
  16449. * - VertexBuffer.MatricesWeightsExtraKind
  16450. *
  16451. * Returns the Mesh.
  16452. */
  16453. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16454. /**
  16455. * Sets the mesh indices.
  16456. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16457. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16458. * This method creates a new index buffer each call.
  16459. * Returns the Mesh.
  16460. */
  16461. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16462. /**
  16463. * Boolean : True if the mesh owns the requested kind of data.
  16464. */
  16465. isVerticesDataPresent(kind: string): boolean;
  16466. /**
  16467. * Returns an array of indices (IndicesArray).
  16468. */
  16469. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  16470. /**
  16471. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16472. * This means the mesh underlying bounding box and sphere are recomputed.
  16473. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16474. * @returns the current mesh
  16475. */
  16476. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16477. /** @hidden */ preActivate(): InstancedMesh;
  16478. /** @hidden */ activate(renderId: number): boolean;
  16479. /**
  16480. * Returns the current associated LOD AbstractMesh.
  16481. */
  16482. getLOD(camera: Camera): AbstractMesh;
  16483. /** @hidden */ syncSubMeshes(): InstancedMesh;
  16484. /** @hidden */ generatePointsArray(): boolean;
  16485. /**
  16486. * Creates a new InstancedMesh from the current mesh.
  16487. * - name (string) : the cloned mesh name
  16488. * - newParent (optional Node) : the optional Node to parent the clone to.
  16489. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16490. *
  16491. * Returns the clone.
  16492. */
  16493. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16494. /**
  16495. * Disposes the InstancedMesh.
  16496. * Returns nothing.
  16497. */
  16498. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16499. }
  16500. }
  16501. declare module BABYLON {
  16502. /**
  16503. * Defines the options associated with the creation of a shader material.
  16504. */
  16505. export interface IShaderMaterialOptions {
  16506. /**
  16507. * Does the material work in alpha blend mode
  16508. */
  16509. needAlphaBlending: boolean;
  16510. /**
  16511. * Does the material work in alpha test mode
  16512. */
  16513. needAlphaTesting: boolean;
  16514. /**
  16515. * The list of attribute names used in the shader
  16516. */
  16517. attributes: string[];
  16518. /**
  16519. * The list of unifrom names used in the shader
  16520. */
  16521. uniforms: string[];
  16522. /**
  16523. * The list of UBO names used in the shader
  16524. */
  16525. uniformBuffers: string[];
  16526. /**
  16527. * The list of sampler names used in the shader
  16528. */
  16529. samplers: string[];
  16530. /**
  16531. * The list of defines used in the shader
  16532. */
  16533. defines: string[];
  16534. }
  16535. /**
  16536. * 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.
  16537. *
  16538. * This returned material effects how the mesh will look based on the code in the shaders.
  16539. *
  16540. * @see http://doc.babylonjs.com/how_to/shader_material
  16541. */
  16542. export class ShaderMaterial extends Material {
  16543. private _shaderPath;
  16544. private _options;
  16545. private _textures;
  16546. private _textureArrays;
  16547. private _floats;
  16548. private _ints;
  16549. private _floatsArrays;
  16550. private _colors3;
  16551. private _colors3Arrays;
  16552. private _colors4;
  16553. private _vectors2;
  16554. private _vectors3;
  16555. private _vectors4;
  16556. private _matrices;
  16557. private _matrices3x3;
  16558. private _matrices2x2;
  16559. private _vectors2Arrays;
  16560. private _vectors3Arrays;
  16561. private _cachedWorldViewMatrix;
  16562. private _renderId;
  16563. /**
  16564. * Instantiate a new shader material.
  16565. * 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.
  16566. * This returned material effects how the mesh will look based on the code in the shaders.
  16567. * @see http://doc.babylonjs.com/how_to/shader_material
  16568. * @param name Define the name of the material in the scene
  16569. * @param scene Define the scene the material belongs to
  16570. * @param shaderPath Defines the route to the shader code in one of three ways:
  16571. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16572. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16573. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16574. * @param options Define the options used to create the shader
  16575. */
  16576. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16577. /**
  16578. * Gets the options used to compile the shader.
  16579. * They can be modified to trigger a new compilation
  16580. */
  16581. readonly options: IShaderMaterialOptions;
  16582. /**
  16583. * Gets the current class name of the material e.g. "ShaderMaterial"
  16584. * Mainly use in serialization.
  16585. * @returns the class name
  16586. */
  16587. getClassName(): string;
  16588. /**
  16589. * Specifies if the material will require alpha blending
  16590. * @returns a boolean specifying if alpha blending is needed
  16591. */
  16592. needAlphaBlending(): boolean;
  16593. /**
  16594. * Specifies if this material should be rendered in alpha test mode
  16595. * @returns a boolean specifying if an alpha test is needed.
  16596. */
  16597. needAlphaTesting(): boolean;
  16598. private _checkUniform;
  16599. /**
  16600. * Set a texture in the shader.
  16601. * @param name Define the name of the uniform samplers as defined in the shader
  16602. * @param texture Define the texture to bind to this sampler
  16603. * @return the material itself allowing "fluent" like uniform updates
  16604. */
  16605. setTexture(name: string, texture: Texture): ShaderMaterial;
  16606. /**
  16607. * Set a texture array in the shader.
  16608. * @param name Define the name of the uniform sampler array as defined in the shader
  16609. * @param textures Define the list of textures to bind to this sampler
  16610. * @return the material itself allowing "fluent" like uniform updates
  16611. */
  16612. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16613. /**
  16614. * Set a float in the shader.
  16615. * @param name Define the name of the uniform as defined in the shader
  16616. * @param value Define the value to give to the uniform
  16617. * @return the material itself allowing "fluent" like uniform updates
  16618. */
  16619. setFloat(name: string, value: number): ShaderMaterial;
  16620. /**
  16621. * Set a int in the shader.
  16622. * @param name Define the name of the uniform as defined in the shader
  16623. * @param value Define the value to give to the uniform
  16624. * @return the material itself allowing "fluent" like uniform updates
  16625. */
  16626. setInt(name: string, value: number): ShaderMaterial;
  16627. /**
  16628. * Set an array of floats in the shader.
  16629. * @param name Define the name of the uniform as defined in the shader
  16630. * @param value Define the value to give to the uniform
  16631. * @return the material itself allowing "fluent" like uniform updates
  16632. */
  16633. setFloats(name: string, value: number[]): ShaderMaterial;
  16634. /**
  16635. * Set a vec3 in the shader from a Color3.
  16636. * @param name Define the name of the uniform as defined in the shader
  16637. * @param value Define the value to give to the uniform
  16638. * @return the material itself allowing "fluent" like uniform updates
  16639. */
  16640. setColor3(name: string, value: Color3): ShaderMaterial;
  16641. /**
  16642. * Set a vec3 array in the shader from a Color3 array.
  16643. * @param name Define the name of the uniform as defined in the shader
  16644. * @param value Define the value to give to the uniform
  16645. * @return the material itself allowing "fluent" like uniform updates
  16646. */
  16647. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16648. /**
  16649. * Set a vec4 in the shader from a Color4.
  16650. * @param name Define the name of the uniform as defined in the shader
  16651. * @param value Define the value to give to the uniform
  16652. * @return the material itself allowing "fluent" like uniform updates
  16653. */
  16654. setColor4(name: string, value: Color4): ShaderMaterial;
  16655. /**
  16656. * Set a vec2 in the shader from a Vector2.
  16657. * @param name Define the name of the uniform as defined in the shader
  16658. * @param value Define the value to give to the uniform
  16659. * @return the material itself allowing "fluent" like uniform updates
  16660. */
  16661. setVector2(name: string, value: Vector2): ShaderMaterial;
  16662. /**
  16663. * Set a vec3 in the shader from a Vector3.
  16664. * @param name Define the name of the uniform as defined in the shader
  16665. * @param value Define the value to give to the uniform
  16666. * @return the material itself allowing "fluent" like uniform updates
  16667. */
  16668. setVector3(name: string, value: Vector3): ShaderMaterial;
  16669. /**
  16670. * Set a vec4 in the shader from a Vector4.
  16671. * @param name Define the name of the uniform as defined in the shader
  16672. * @param value Define the value to give to the uniform
  16673. * @return the material itself allowing "fluent" like uniform updates
  16674. */
  16675. setVector4(name: string, value: Vector4): ShaderMaterial;
  16676. /**
  16677. * Set a mat4 in the shader from a Matrix.
  16678. * @param name Define the name of the uniform as defined in the shader
  16679. * @param value Define the value to give to the uniform
  16680. * @return the material itself allowing "fluent" like uniform updates
  16681. */
  16682. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16683. /**
  16684. * Set a mat3 in the shader from a Float32Array.
  16685. * @param name Define the name of the uniform as defined in the shader
  16686. * @param value Define the value to give to the uniform
  16687. * @return the material itself allowing "fluent" like uniform updates
  16688. */
  16689. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16690. /**
  16691. * Set a mat2 in the shader from a Float32Array.
  16692. * @param name Define the name of the uniform as defined in the shader
  16693. * @param value Define the value to give to the uniform
  16694. * @return the material itself allowing "fluent" like uniform updates
  16695. */
  16696. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16697. /**
  16698. * Set a vec2 array in the shader from a number array.
  16699. * @param name Define the name of the uniform as defined in the shader
  16700. * @param value Define the value to give to the uniform
  16701. * @return the material itself allowing "fluent" like uniform updates
  16702. */
  16703. setArray2(name: string, value: number[]): ShaderMaterial;
  16704. /**
  16705. * Set a vec3 array in the shader from a number array.
  16706. * @param name Define the name of the uniform as defined in the shader
  16707. * @param value Define the value to give to the uniform
  16708. * @return the material itself allowing "fluent" like uniform updates
  16709. */
  16710. setArray3(name: string, value: number[]): ShaderMaterial;
  16711. private _checkCache;
  16712. /**
  16713. * Specifies that the submesh is ready to be used
  16714. * @param mesh defines the mesh to check
  16715. * @param subMesh defines which submesh to check
  16716. * @param useInstances specifies that instances should be used
  16717. * @returns a boolean indicating that the submesh is ready or not
  16718. */
  16719. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16720. /**
  16721. * Checks if the material is ready to render the requested mesh
  16722. * @param mesh Define the mesh to render
  16723. * @param useInstances Define whether or not the material is used with instances
  16724. * @returns true if ready, otherwise false
  16725. */
  16726. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16727. /**
  16728. * Binds the world matrix to the material
  16729. * @param world defines the world transformation matrix
  16730. */
  16731. bindOnlyWorldMatrix(world: Matrix): void;
  16732. /**
  16733. * Binds the material to the mesh
  16734. * @param world defines the world transformation matrix
  16735. * @param mesh defines the mesh to bind the material to
  16736. */
  16737. bind(world: Matrix, mesh?: Mesh): void;
  16738. /**
  16739. * Gets the active textures from the material
  16740. * @returns an array of textures
  16741. */
  16742. getActiveTextures(): BaseTexture[];
  16743. /**
  16744. * Specifies if the material uses a texture
  16745. * @param texture defines the texture to check against the material
  16746. * @returns a boolean specifying if the material uses the texture
  16747. */
  16748. hasTexture(texture: BaseTexture): boolean;
  16749. /**
  16750. * Makes a duplicate of the material, and gives it a new name
  16751. * @param name defines the new name for the duplicated material
  16752. * @returns the cloned material
  16753. */
  16754. clone(name: string): ShaderMaterial;
  16755. /**
  16756. * Disposes the material
  16757. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16758. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16759. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16760. */
  16761. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16762. /**
  16763. * Serializes this material in a JSON representation
  16764. * @returns the serialized material object
  16765. */
  16766. serialize(): any;
  16767. /**
  16768. * Creates a shader material from parsed shader material data
  16769. * @param source defines the JSON represnetation of the material
  16770. * @param scene defines the hosting scene
  16771. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16772. * @returns a new material
  16773. */
  16774. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16775. }
  16776. }
  16777. declare module BABYLON {
  16778. /** @hidden */
  16779. export var colorPixelShader: {
  16780. name: string;
  16781. shader: string;
  16782. };
  16783. }
  16784. declare module BABYLON {
  16785. /** @hidden */
  16786. export var colorVertexShader: {
  16787. name: string;
  16788. shader: string;
  16789. };
  16790. }
  16791. declare module BABYLON {
  16792. /**
  16793. * Line mesh
  16794. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16795. */
  16796. export class LinesMesh extends Mesh {
  16797. /**
  16798. * If vertex color should be applied to the mesh
  16799. */
  16800. useVertexColor?: boolean | undefined;
  16801. /**
  16802. * If vertex alpha should be applied to the mesh
  16803. */
  16804. useVertexAlpha?: boolean | undefined;
  16805. /**
  16806. * Color of the line (Default: White)
  16807. */
  16808. color: Color3;
  16809. /**
  16810. * Alpha of the line (Default: 1)
  16811. */
  16812. alpha: number;
  16813. /**
  16814. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16815. * This margin is expressed in world space coordinates, so its value may vary.
  16816. * Default value is 0.1
  16817. */
  16818. intersectionThreshold: number;
  16819. private _colorShader;
  16820. /**
  16821. * Creates a new LinesMesh
  16822. * @param name defines the name
  16823. * @param scene defines the hosting scene
  16824. * @param parent defines the parent mesh if any
  16825. * @param source defines the optional source LinesMesh used to clone data from
  16826. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16827. * When false, achieved by calling a clone(), also passing False.
  16828. * This will make creation of children, recursive.
  16829. * @param useVertexColor defines if this LinesMesh supports vertex color
  16830. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16831. */
  16832. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16833. /**
  16834. * If vertex color should be applied to the mesh
  16835. */
  16836. useVertexColor?: boolean | undefined,
  16837. /**
  16838. * If vertex alpha should be applied to the mesh
  16839. */
  16840. useVertexAlpha?: boolean | undefined);
  16841. private _addClipPlaneDefine;
  16842. private _removeClipPlaneDefine;
  16843. isReady(): boolean;
  16844. /**
  16845. * Returns the string "LineMesh"
  16846. */
  16847. getClassName(): string;
  16848. /**
  16849. * @hidden
  16850. */
  16851. /**
  16852. * @hidden
  16853. */
  16854. material: Material;
  16855. /**
  16856. * @hidden
  16857. */
  16858. readonly checkCollisions: boolean;
  16859. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16860. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16861. /**
  16862. * Disposes of the line mesh
  16863. * @param doNotRecurse If children should be disposed
  16864. */
  16865. dispose(doNotRecurse?: boolean): void;
  16866. /**
  16867. * Returns a new LineMesh object cloned from the current one.
  16868. */
  16869. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16870. /**
  16871. * Creates a new InstancedLinesMesh object from the mesh model.
  16872. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16873. * @param name defines the name of the new instance
  16874. * @returns a new InstancedLinesMesh
  16875. */
  16876. createInstance(name: string): InstancedLinesMesh;
  16877. }
  16878. /**
  16879. * Creates an instance based on a source LinesMesh
  16880. */
  16881. export class InstancedLinesMesh extends InstancedMesh {
  16882. /**
  16883. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16884. * This margin is expressed in world space coordinates, so its value may vary.
  16885. * Initilized with the intersectionThreshold value of the source LinesMesh
  16886. */
  16887. intersectionThreshold: number;
  16888. constructor(name: string, source: LinesMesh);
  16889. /**
  16890. * Returns the string "InstancedLinesMesh".
  16891. */
  16892. getClassName(): string;
  16893. }
  16894. }
  16895. declare module BABYLON {
  16896. /** @hidden */
  16897. export var linePixelShader: {
  16898. name: string;
  16899. shader: string;
  16900. };
  16901. }
  16902. declare module BABYLON {
  16903. /** @hidden */
  16904. export var lineVertexShader: {
  16905. name: string;
  16906. shader: string;
  16907. };
  16908. }
  16909. declare module BABYLON {
  16910. interface AbstractMesh {
  16911. /**
  16912. * Disables the mesh edge rendering mode
  16913. * @returns the currentAbstractMesh
  16914. */
  16915. disableEdgesRendering(): AbstractMesh;
  16916. /**
  16917. * Enables the edge rendering mode on the mesh.
  16918. * This mode makes the mesh edges visible
  16919. * @param epsilon defines the maximal distance between two angles to detect a face
  16920. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16921. * @returns the currentAbstractMesh
  16922. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16923. */
  16924. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16925. /**
  16926. * Gets the edgesRenderer associated with the mesh
  16927. */
  16928. edgesRenderer: Nullable<EdgesRenderer>;
  16929. }
  16930. interface LinesMesh {
  16931. /**
  16932. * Enables the edge rendering mode on the mesh.
  16933. * This mode makes the mesh edges visible
  16934. * @param epsilon defines the maximal distance between two angles to detect a face
  16935. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16936. * @returns the currentAbstractMesh
  16937. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16938. */
  16939. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16940. }
  16941. interface InstancedLinesMesh {
  16942. /**
  16943. * Enables the edge rendering mode on the mesh.
  16944. * This mode makes the mesh edges visible
  16945. * @param epsilon defines the maximal distance between two angles to detect a face
  16946. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16947. * @returns the current InstancedLinesMesh
  16948. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16949. */
  16950. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16951. }
  16952. /**
  16953. * Defines the minimum contract an Edges renderer should follow.
  16954. */
  16955. export interface IEdgesRenderer extends IDisposable {
  16956. /**
  16957. * Gets or sets a boolean indicating if the edgesRenderer is active
  16958. */
  16959. isEnabled: boolean;
  16960. /**
  16961. * Renders the edges of the attached mesh,
  16962. */
  16963. render(): void;
  16964. /**
  16965. * Checks wether or not the edges renderer is ready to render.
  16966. * @return true if ready, otherwise false.
  16967. */
  16968. isReady(): boolean;
  16969. }
  16970. /**
  16971. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16972. */
  16973. export class EdgesRenderer implements IEdgesRenderer {
  16974. /**
  16975. * Define the size of the edges with an orthographic camera
  16976. */
  16977. edgesWidthScalerForOrthographic: number;
  16978. /**
  16979. * Define the size of the edges with a perspective camera
  16980. */
  16981. edgesWidthScalerForPerspective: number;
  16982. protected _source: AbstractMesh;
  16983. protected _linesPositions: number[];
  16984. protected _linesNormals: number[];
  16985. protected _linesIndices: number[];
  16986. protected _epsilon: number;
  16987. protected _indicesCount: number;
  16988. protected _lineShader: ShaderMaterial;
  16989. protected _ib: WebGLBuffer;
  16990. protected _buffers: {
  16991. [key: string]: Nullable<VertexBuffer>;
  16992. };
  16993. protected _checkVerticesInsteadOfIndices: boolean;
  16994. private _meshRebuildObserver;
  16995. private _meshDisposeObserver;
  16996. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16997. isEnabled: boolean;
  16998. /**
  16999. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17000. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17001. * @param source Mesh used to create edges
  17002. * @param epsilon sum of angles in adjacency to check for edge
  17003. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17004. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17005. */
  17006. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17007. protected _prepareRessources(): void;
  17008. /** @hidden */ rebuild(): void;
  17009. /**
  17010. * Releases the required resources for the edges renderer
  17011. */
  17012. dispose(): void;
  17013. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17014. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17015. /**
  17016. * Checks if the pair of p0 and p1 is en edge
  17017. * @param faceIndex
  17018. * @param edge
  17019. * @param faceNormals
  17020. * @param p0
  17021. * @param p1
  17022. * @private
  17023. */
  17024. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17025. /**
  17026. * push line into the position, normal and index buffer
  17027. * @protected
  17028. */
  17029. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17030. /**
  17031. * Generates lines edges from adjacencjes
  17032. * @private
  17033. */ generateEdgesLines(): void;
  17034. /**
  17035. * Checks wether or not the edges renderer is ready to render.
  17036. * @return true if ready, otherwise false.
  17037. */
  17038. isReady(): boolean;
  17039. /**
  17040. * Renders the edges of the attached mesh,
  17041. */
  17042. render(): void;
  17043. }
  17044. /**
  17045. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17046. */
  17047. export class LineEdgesRenderer extends EdgesRenderer {
  17048. /**
  17049. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17050. * @param source LineMesh used to generate edges
  17051. * @param epsilon not important (specified angle for edge detection)
  17052. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17053. */
  17054. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17055. /**
  17056. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17057. */ generateEdgesLines(): void;
  17058. }
  17059. }
  17060. declare module BABYLON {
  17061. /**
  17062. * This represents the object necessary to create a rendering group.
  17063. * This is exclusively used and created by the rendering manager.
  17064. * To modify the behavior, you use the available helpers in your scene or meshes.
  17065. * @hidden
  17066. */
  17067. export class RenderingGroup {
  17068. index: number;
  17069. private _scene;
  17070. private _opaqueSubMeshes;
  17071. private _transparentSubMeshes;
  17072. private _alphaTestSubMeshes;
  17073. private _depthOnlySubMeshes;
  17074. private _particleSystems;
  17075. private _spriteManagers;
  17076. private _opaqueSortCompareFn;
  17077. private _alphaTestSortCompareFn;
  17078. private _transparentSortCompareFn;
  17079. private _renderOpaque;
  17080. private _renderAlphaTest;
  17081. private _renderTransparent;
  17082. /** @hidden */ edgesRenderers: SmartArray<IEdgesRenderer>;
  17083. onBeforeTransparentRendering: () => void;
  17084. /**
  17085. * Set the opaque sort comparison function.
  17086. * If null the sub meshes will be render in the order they were created
  17087. */
  17088. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17089. /**
  17090. * Set the alpha test sort comparison function.
  17091. * If null the sub meshes will be render in the order they were created
  17092. */
  17093. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17094. /**
  17095. * Set the transparent sort comparison function.
  17096. * If null the sub meshes will be render in the order they were created
  17097. */
  17098. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17099. /**
  17100. * Creates a new rendering group.
  17101. * @param index The rendering group index
  17102. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17103. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17104. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17105. */
  17106. 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>);
  17107. /**
  17108. * Render all the sub meshes contained in the group.
  17109. * @param customRenderFunction Used to override the default render behaviour of the group.
  17110. * @returns true if rendered some submeshes.
  17111. */
  17112. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17113. /**
  17114. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17115. * @param subMeshes The submeshes to render
  17116. */
  17117. private renderOpaqueSorted;
  17118. /**
  17119. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17120. * @param subMeshes The submeshes to render
  17121. */
  17122. private renderAlphaTestSorted;
  17123. /**
  17124. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17125. * @param subMeshes The submeshes to render
  17126. */
  17127. private renderTransparentSorted;
  17128. /**
  17129. * Renders the submeshes in a specified order.
  17130. * @param subMeshes The submeshes to sort before render
  17131. * @param sortCompareFn The comparison function use to sort
  17132. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17133. * @param transparent Specifies to activate blending if true
  17134. */
  17135. private static renderSorted;
  17136. /**
  17137. * Renders the submeshes in the order they were dispatched (no sort applied).
  17138. * @param subMeshes The submeshes to render
  17139. */
  17140. private static renderUnsorted;
  17141. /**
  17142. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17143. * are rendered back to front if in the same alpha index.
  17144. *
  17145. * @param a The first submesh
  17146. * @param b The second submesh
  17147. * @returns The result of the comparison
  17148. */
  17149. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17150. /**
  17151. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17152. * are rendered back to front.
  17153. *
  17154. * @param a The first submesh
  17155. * @param b The second submesh
  17156. * @returns The result of the comparison
  17157. */
  17158. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17159. /**
  17160. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17161. * are rendered front to back (prevent overdraw).
  17162. *
  17163. * @param a The first submesh
  17164. * @param b The second submesh
  17165. * @returns The result of the comparison
  17166. */
  17167. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17168. /**
  17169. * Resets the different lists of submeshes to prepare a new frame.
  17170. */
  17171. prepare(): void;
  17172. dispose(): void;
  17173. /**
  17174. * Inserts the submesh in its correct queue depending on its material.
  17175. * @param subMesh The submesh to dispatch
  17176. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17177. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17178. */
  17179. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17180. dispatchSprites(spriteManager: ISpriteManager): void;
  17181. dispatchParticles(particleSystem: IParticleSystem): void;
  17182. private _renderParticles;
  17183. private _renderSprites;
  17184. }
  17185. }
  17186. declare module BABYLON {
  17187. /**
  17188. * Interface describing the different options available in the rendering manager
  17189. * regarding Auto Clear between groups.
  17190. */
  17191. export interface IRenderingManagerAutoClearSetup {
  17192. /**
  17193. * Defines whether or not autoclear is enable.
  17194. */
  17195. autoClear: boolean;
  17196. /**
  17197. * Defines whether or not to autoclear the depth buffer.
  17198. */
  17199. depth: boolean;
  17200. /**
  17201. * Defines whether or not to autoclear the stencil buffer.
  17202. */
  17203. stencil: boolean;
  17204. }
  17205. /**
  17206. * This class is used by the onRenderingGroupObservable
  17207. */
  17208. export class RenderingGroupInfo {
  17209. /**
  17210. * The Scene that being rendered
  17211. */
  17212. scene: Scene;
  17213. /**
  17214. * The camera currently used for the rendering pass
  17215. */
  17216. camera: Nullable<Camera>;
  17217. /**
  17218. * The ID of the renderingGroup being processed
  17219. */
  17220. renderingGroupId: number;
  17221. }
  17222. /**
  17223. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17224. * It is enable to manage the different groups as well as the different necessary sort functions.
  17225. * This should not be used directly aside of the few static configurations
  17226. */
  17227. export class RenderingManager {
  17228. /**
  17229. * The max id used for rendering groups (not included)
  17230. */
  17231. static MAX_RENDERINGGROUPS: number;
  17232. /**
  17233. * The min id used for rendering groups (included)
  17234. */
  17235. static MIN_RENDERINGGROUPS: number;
  17236. /**
  17237. * Used to globally prevent autoclearing scenes.
  17238. */
  17239. static AUTOCLEAR: boolean;
  17240. /**
  17241. * @hidden
  17242. */ useSceneAutoClearSetup: boolean;
  17243. private _scene;
  17244. private _renderingGroups;
  17245. private _depthStencilBufferAlreadyCleaned;
  17246. private _autoClearDepthStencil;
  17247. private _customOpaqueSortCompareFn;
  17248. private _customAlphaTestSortCompareFn;
  17249. private _customTransparentSortCompareFn;
  17250. private _renderingGroupInfo;
  17251. /**
  17252. * Instantiates a new rendering group for a particular scene
  17253. * @param scene Defines the scene the groups belongs to
  17254. */
  17255. constructor(scene: Scene);
  17256. private _clearDepthStencilBuffer;
  17257. /**
  17258. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17259. * @hidden
  17260. */
  17261. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17262. /**
  17263. * Resets the different information of the group to prepare a new frame
  17264. * @hidden
  17265. */
  17266. reset(): void;
  17267. /**
  17268. * Dispose and release the group and its associated resources.
  17269. * @hidden
  17270. */
  17271. dispose(): void;
  17272. /**
  17273. * Clear the info related to rendering groups preventing retention points during dispose.
  17274. */
  17275. freeRenderingGroups(): void;
  17276. private _prepareRenderingGroup;
  17277. /**
  17278. * Add a sprite manager to the rendering manager in order to render it this frame.
  17279. * @param spriteManager Define the sprite manager to render
  17280. */
  17281. dispatchSprites(spriteManager: ISpriteManager): void;
  17282. /**
  17283. * Add a particle system to the rendering manager in order to render it this frame.
  17284. * @param particleSystem Define the particle system to render
  17285. */
  17286. dispatchParticles(particleSystem: IParticleSystem): void;
  17287. /**
  17288. * Add a submesh to the manager in order to render it this frame
  17289. * @param subMesh The submesh to dispatch
  17290. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17291. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17292. */
  17293. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17294. /**
  17295. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17296. * This allowed control for front to back rendering or reversly depending of the special needs.
  17297. *
  17298. * @param renderingGroupId The rendering group id corresponding to its index
  17299. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17300. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17301. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17302. */
  17303. 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;
  17304. /**
  17305. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17306. *
  17307. * @param renderingGroupId The rendering group id corresponding to its index
  17308. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17309. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17310. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17311. */
  17312. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17313. /**
  17314. * Gets the current auto clear configuration for one rendering group of the rendering
  17315. * manager.
  17316. * @param index the rendering group index to get the information for
  17317. * @returns The auto clear setup for the requested rendering group
  17318. */
  17319. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17320. }
  17321. }
  17322. declare module BABYLON {
  17323. /**
  17324. * This Helps creating a texture that will be created from a camera in your scene.
  17325. * It is basically a dynamic texture that could be used to create special effects for instance.
  17326. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17327. */
  17328. export class RenderTargetTexture extends Texture {
  17329. isCube: boolean;
  17330. /**
  17331. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17332. */
  17333. static readonly REFRESHRATE_RENDER_ONCE: number;
  17334. /**
  17335. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17336. */
  17337. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17338. /**
  17339. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17340. * the central point of your effect and can save a lot of performances.
  17341. */
  17342. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17343. /**
  17344. * Use this predicate to dynamically define the list of mesh you want to render.
  17345. * If set, the renderList property will be overwritten.
  17346. */
  17347. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17348. private _renderList;
  17349. /**
  17350. * Use this list to define the list of mesh you want to render.
  17351. */
  17352. renderList: Nullable<Array<AbstractMesh>>;
  17353. private _hookArray;
  17354. /**
  17355. * Define if particles should be rendered in your texture.
  17356. */
  17357. renderParticles: boolean;
  17358. /**
  17359. * Define if sprites should be rendered in your texture.
  17360. */
  17361. renderSprites: boolean;
  17362. /**
  17363. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17364. */
  17365. coordinatesMode: number;
  17366. /**
  17367. * Define the camera used to render the texture.
  17368. */
  17369. activeCamera: Nullable<Camera>;
  17370. /**
  17371. * Override the render function of the texture with your own one.
  17372. */
  17373. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17374. /**
  17375. * Define if camera post processes should be use while rendering the texture.
  17376. */
  17377. useCameraPostProcesses: boolean;
  17378. /**
  17379. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17380. */
  17381. ignoreCameraViewport: boolean;
  17382. private _postProcessManager;
  17383. private _postProcesses;
  17384. private _resizeObserver;
  17385. /**
  17386. * An event triggered when the texture is unbind.
  17387. */
  17388. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17389. /**
  17390. * An event triggered when the texture is unbind.
  17391. */
  17392. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17393. private _onAfterUnbindObserver;
  17394. /**
  17395. * Set a after unbind callback in the texture.
  17396. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17397. */
  17398. onAfterUnbind: () => void;
  17399. /**
  17400. * An event triggered before rendering the texture
  17401. */
  17402. onBeforeRenderObservable: Observable<number>;
  17403. private _onBeforeRenderObserver;
  17404. /**
  17405. * Set a before render callback in the texture.
  17406. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17407. */
  17408. onBeforeRender: (faceIndex: number) => void;
  17409. /**
  17410. * An event triggered after rendering the texture
  17411. */
  17412. onAfterRenderObservable: Observable<number>;
  17413. private _onAfterRenderObserver;
  17414. /**
  17415. * Set a after render callback in the texture.
  17416. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17417. */
  17418. onAfterRender: (faceIndex: number) => void;
  17419. /**
  17420. * An event triggered after the texture clear
  17421. */
  17422. onClearObservable: Observable<Engine>;
  17423. private _onClearObserver;
  17424. /**
  17425. * Set a clear callback in the texture.
  17426. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17427. */
  17428. onClear: (Engine: Engine) => void;
  17429. /**
  17430. * Define the clear color of the Render Target if it should be different from the scene.
  17431. */
  17432. clearColor: Color4;
  17433. protected _size: number | {
  17434. width: number;
  17435. height: number;
  17436. };
  17437. protected _initialSizeParameter: number | {
  17438. width: number;
  17439. height: number;
  17440. } | {
  17441. ratio: number;
  17442. };
  17443. protected _sizeRatio: Nullable<number>;
  17444. /** @hidden */ generateMipMaps: boolean;
  17445. protected _renderingManager: RenderingManager;
  17446. /** @hidden */ waitingRenderList: string[];
  17447. protected _doNotChangeAspectRatio: boolean;
  17448. protected _currentRefreshId: number;
  17449. protected _refreshRate: number;
  17450. protected _textureMatrix: Matrix;
  17451. protected _samples: number;
  17452. protected _renderTargetOptions: RenderTargetCreationOptions;
  17453. /**
  17454. * Gets render target creation options that were used.
  17455. */
  17456. readonly renderTargetOptions: RenderTargetCreationOptions;
  17457. protected _engine: Engine;
  17458. protected _onRatioRescale(): void;
  17459. /**
  17460. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17461. * It must define where the camera used to render the texture is set
  17462. */
  17463. boundingBoxPosition: Vector3;
  17464. private _boundingBoxSize;
  17465. /**
  17466. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17467. * When defined, the cubemap will switch to local mode
  17468. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17469. * @example https://www.babylonjs-playground.com/#RNASML
  17470. */
  17471. boundingBoxSize: Vector3;
  17472. /**
  17473. * In case the RTT has been created with a depth texture, get the associated
  17474. * depth texture.
  17475. * Otherwise, return null.
  17476. */
  17477. depthStencilTexture: Nullable<InternalTexture>;
  17478. /**
  17479. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17480. * or used a shadow, depth texture...
  17481. * @param name The friendly name of the texture
  17482. * @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)
  17483. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17484. * @param generateMipMaps True if mip maps need to be generated after render.
  17485. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17486. * @param type The type of the buffer in the RTT (int, half float, float...)
  17487. * @param isCube True if a cube texture needs to be created
  17488. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17489. * @param generateDepthBuffer True to generate a depth buffer
  17490. * @param generateStencilBuffer True to generate a stencil buffer
  17491. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17492. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17493. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17494. */
  17495. constructor(name: string, size: number | {
  17496. width: number;
  17497. height: number;
  17498. } | {
  17499. ratio: number;
  17500. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17501. /**
  17502. * Creates a depth stencil texture.
  17503. * This is only available in WebGL 2 or with the depth texture extension available.
  17504. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17505. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17506. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17507. */
  17508. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17509. private _processSizeParameter;
  17510. /**
  17511. * Define the number of samples to use in case of MSAA.
  17512. * It defaults to one meaning no MSAA has been enabled.
  17513. */
  17514. samples: number;
  17515. /**
  17516. * Resets the refresh counter of the texture and start bak from scratch.
  17517. * Could be useful to regenerate the texture if it is setup to render only once.
  17518. */
  17519. resetRefreshCounter(): void;
  17520. /**
  17521. * Define the refresh rate of the texture or the rendering frequency.
  17522. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17523. */
  17524. refreshRate: number;
  17525. /**
  17526. * Adds a post process to the render target rendering passes.
  17527. * @param postProcess define the post process to add
  17528. */
  17529. addPostProcess(postProcess: PostProcess): void;
  17530. /**
  17531. * Clear all the post processes attached to the render target
  17532. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17533. */
  17534. clearPostProcesses(dispose?: boolean): void;
  17535. /**
  17536. * Remove one of the post process from the list of attached post processes to the texture
  17537. * @param postProcess define the post process to remove from the list
  17538. */
  17539. removePostProcess(postProcess: PostProcess): void;
  17540. /** @hidden */ shouldRender(): boolean;
  17541. /**
  17542. * Gets the actual render size of the texture.
  17543. * @returns the width of the render size
  17544. */
  17545. getRenderSize(): number;
  17546. /**
  17547. * Gets the actual render width of the texture.
  17548. * @returns the width of the render size
  17549. */
  17550. getRenderWidth(): number;
  17551. /**
  17552. * Gets the actual render height of the texture.
  17553. * @returns the height of the render size
  17554. */
  17555. getRenderHeight(): number;
  17556. /**
  17557. * Get if the texture can be rescaled or not.
  17558. */
  17559. readonly canRescale: boolean;
  17560. /**
  17561. * Resize the texture using a ratio.
  17562. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17563. */
  17564. scale(ratio: number): void;
  17565. /**
  17566. * Get the texture reflection matrix used to rotate/transform the reflection.
  17567. * @returns the reflection matrix
  17568. */
  17569. getReflectionTextureMatrix(): Matrix;
  17570. /**
  17571. * Resize the texture to a new desired size.
  17572. * Be carrefull as it will recreate all the data in the new texture.
  17573. * @param size Define the new size. It can be:
  17574. * - a number for squared texture,
  17575. * - an object containing { width: number, height: number }
  17576. * - or an object containing a ratio { ratio: number }
  17577. */
  17578. resize(size: number | {
  17579. width: number;
  17580. height: number;
  17581. } | {
  17582. ratio: number;
  17583. }): void;
  17584. /**
  17585. * Renders all the objects from the render list into the texture.
  17586. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17587. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17588. */
  17589. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17590. private _bestReflectionRenderTargetDimension;
  17591. /**
  17592. * @hidden
  17593. * @param faceIndex face index to bind to if this is a cubetexture
  17594. */ bindFrameBuffer(faceIndex?: number): void;
  17595. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17596. private renderToTarget;
  17597. /**
  17598. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17599. * This allowed control for front to back rendering or reversly depending of the special needs.
  17600. *
  17601. * @param renderingGroupId The rendering group id corresponding to its index
  17602. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17603. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17604. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17605. */
  17606. 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;
  17607. /**
  17608. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17609. *
  17610. * @param renderingGroupId The rendering group id corresponding to its index
  17611. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17612. */
  17613. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17614. /**
  17615. * Clones the texture.
  17616. * @returns the cloned texture
  17617. */
  17618. clone(): RenderTargetTexture;
  17619. /**
  17620. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17621. * @returns The JSON representation of the texture
  17622. */
  17623. serialize(): any;
  17624. /**
  17625. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17626. */
  17627. disposeFramebufferObjects(): void;
  17628. /**
  17629. * Dispose the texture and release its associated resources.
  17630. */
  17631. dispose(): void;
  17632. /** @hidden */ rebuild(): void;
  17633. /**
  17634. * Clear the info related to rendering groups preventing retention point in material dispose.
  17635. */
  17636. freeRenderingGroups(): void;
  17637. /**
  17638. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17639. * @returns the view count
  17640. */
  17641. getViewCount(): number;
  17642. }
  17643. }
  17644. declare module BABYLON {
  17645. /**
  17646. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17647. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17648. * You can then easily use it as a reflectionTexture on a flat surface.
  17649. * In case the surface is not a plane, please consider relying on reflection probes.
  17650. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17651. */
  17652. export class MirrorTexture extends RenderTargetTexture {
  17653. private scene;
  17654. /**
  17655. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17656. * 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.
  17657. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17658. */
  17659. mirrorPlane: Plane;
  17660. /**
  17661. * Define the blur ratio used to blur the reflection if needed.
  17662. */
  17663. blurRatio: number;
  17664. /**
  17665. * Define the adaptive blur kernel used to blur the reflection if needed.
  17666. * This will autocompute the closest best match for the `blurKernel`
  17667. */
  17668. adaptiveBlurKernel: number;
  17669. /**
  17670. * Define the blur kernel used to blur the reflection if needed.
  17671. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17672. */
  17673. blurKernel: number;
  17674. /**
  17675. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17676. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17677. */
  17678. blurKernelX: number;
  17679. /**
  17680. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17681. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17682. */
  17683. blurKernelY: number;
  17684. private _autoComputeBlurKernel;
  17685. protected _onRatioRescale(): void;
  17686. private _updateGammaSpace;
  17687. private _imageProcessingConfigChangeObserver;
  17688. private _transformMatrix;
  17689. private _mirrorMatrix;
  17690. private _savedViewMatrix;
  17691. private _blurX;
  17692. private _blurY;
  17693. private _adaptiveBlurKernel;
  17694. private _blurKernelX;
  17695. private _blurKernelY;
  17696. private _blurRatio;
  17697. /**
  17698. * Instantiates a Mirror Texture.
  17699. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17700. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17701. * You can then easily use it as a reflectionTexture on a flat surface.
  17702. * In case the surface is not a plane, please consider relying on reflection probes.
  17703. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17704. * @param name
  17705. * @param size
  17706. * @param scene
  17707. * @param generateMipMaps
  17708. * @param type
  17709. * @param samplingMode
  17710. * @param generateDepthBuffer
  17711. */
  17712. constructor(name: string, size: number | {
  17713. width: number;
  17714. height: number;
  17715. } | {
  17716. ratio: number;
  17717. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17718. private _preparePostProcesses;
  17719. /**
  17720. * Clone the mirror texture.
  17721. * @returns the cloned texture
  17722. */
  17723. clone(): MirrorTexture;
  17724. /**
  17725. * Serialize the texture to a JSON representation you could use in Parse later on
  17726. * @returns the serialized JSON representation
  17727. */
  17728. serialize(): any;
  17729. /**
  17730. * Dispose the texture and release its associated resources.
  17731. */
  17732. dispose(): void;
  17733. }
  17734. }
  17735. declare module BABYLON {
  17736. /**
  17737. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17738. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17739. */
  17740. export class Texture extends BaseTexture {
  17741. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17742. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17743. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17744. /** nearest is mag = nearest and min = nearest and mip = linear */
  17745. static readonly NEAREST_SAMPLINGMODE: number;
  17746. /** nearest is mag = nearest and min = nearest and mip = linear */
  17747. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17748. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17749. static readonly BILINEAR_SAMPLINGMODE: number;
  17750. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17751. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17752. /** Trilinear is mag = linear and min = linear and mip = linear */
  17753. static readonly TRILINEAR_SAMPLINGMODE: number;
  17754. /** Trilinear is mag = linear and min = linear and mip = linear */
  17755. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17756. /** mag = nearest and min = nearest and mip = nearest */
  17757. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17758. /** mag = nearest and min = linear and mip = nearest */
  17759. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17760. /** mag = nearest and min = linear and mip = linear */
  17761. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17762. /** mag = nearest and min = linear and mip = none */
  17763. static readonly NEAREST_LINEAR: number;
  17764. /** mag = nearest and min = nearest and mip = none */
  17765. static readonly NEAREST_NEAREST: number;
  17766. /** mag = linear and min = nearest and mip = nearest */
  17767. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17768. /** mag = linear and min = nearest and mip = linear */
  17769. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17770. /** mag = linear and min = linear and mip = none */
  17771. static readonly LINEAR_LINEAR: number;
  17772. /** mag = linear and min = nearest and mip = none */
  17773. static readonly LINEAR_NEAREST: number;
  17774. /** Explicit coordinates mode */
  17775. static readonly EXPLICIT_MODE: number;
  17776. /** Spherical coordinates mode */
  17777. static readonly SPHERICAL_MODE: number;
  17778. /** Planar coordinates mode */
  17779. static readonly PLANAR_MODE: number;
  17780. /** Cubic coordinates mode */
  17781. static readonly CUBIC_MODE: number;
  17782. /** Projection coordinates mode */
  17783. static readonly PROJECTION_MODE: number;
  17784. /** Inverse Cubic coordinates mode */
  17785. static readonly SKYBOX_MODE: number;
  17786. /** Inverse Cubic coordinates mode */
  17787. static readonly INVCUBIC_MODE: number;
  17788. /** Equirectangular coordinates mode */
  17789. static readonly EQUIRECTANGULAR_MODE: number;
  17790. /** Equirectangular Fixed coordinates mode */
  17791. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17792. /** Equirectangular Fixed Mirrored coordinates mode */
  17793. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17794. /** Texture is not repeating outside of 0..1 UVs */
  17795. static readonly CLAMP_ADDRESSMODE: number;
  17796. /** Texture is repeating outside of 0..1 UVs */
  17797. static readonly WRAP_ADDRESSMODE: number;
  17798. /** Texture is repeating and mirrored */
  17799. static readonly MIRROR_ADDRESSMODE: number;
  17800. /**
  17801. * 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
  17802. */
  17803. static UseSerializedUrlIfAny: boolean;
  17804. /**
  17805. * Define the url of the texture.
  17806. */
  17807. url: Nullable<string>;
  17808. /**
  17809. * Define an offset on the texture to offset the u coordinates of the UVs
  17810. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17811. */
  17812. uOffset: number;
  17813. /**
  17814. * Define an offset on the texture to offset the v coordinates of the UVs
  17815. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17816. */
  17817. vOffset: number;
  17818. /**
  17819. * Define an offset on the texture to scale the u coordinates of the UVs
  17820. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17821. */
  17822. uScale: number;
  17823. /**
  17824. * Define an offset on the texture to scale the v coordinates of the UVs
  17825. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17826. */
  17827. vScale: number;
  17828. /**
  17829. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17830. * @see http://doc.babylonjs.com/how_to/more_materials
  17831. */
  17832. uAng: number;
  17833. /**
  17834. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17835. * @see http://doc.babylonjs.com/how_to/more_materials
  17836. */
  17837. vAng: number;
  17838. /**
  17839. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17840. * @see http://doc.babylonjs.com/how_to/more_materials
  17841. */
  17842. wAng: number;
  17843. /**
  17844. * Defines the center of rotation (U)
  17845. */
  17846. uRotationCenter: number;
  17847. /**
  17848. * Defines the center of rotation (V)
  17849. */
  17850. vRotationCenter: number;
  17851. /**
  17852. * Defines the center of rotation (W)
  17853. */
  17854. wRotationCenter: number;
  17855. /**
  17856. * Are mip maps generated for this texture or not.
  17857. */
  17858. readonly noMipmap: boolean;
  17859. /**
  17860. * List of inspectable custom properties (used by the Inspector)
  17861. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17862. */
  17863. inspectableCustomProperties: Nullable<IInspectable[]>;
  17864. private _noMipmap;
  17865. /** @hidden */ invertY: boolean;
  17866. private _rowGenerationMatrix;
  17867. private _cachedTextureMatrix;
  17868. private _projectionModeMatrix;
  17869. private _t0;
  17870. private _t1;
  17871. private _t2;
  17872. private _cachedUOffset;
  17873. private _cachedVOffset;
  17874. private _cachedUScale;
  17875. private _cachedVScale;
  17876. private _cachedUAng;
  17877. private _cachedVAng;
  17878. private _cachedWAng;
  17879. private _cachedProjectionMatrixId;
  17880. private _cachedCoordinatesMode;
  17881. /** @hidden */
  17882. protected _initialSamplingMode: number;
  17883. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17884. private _deleteBuffer;
  17885. protected _format: Nullable<number>;
  17886. private _delayedOnLoad;
  17887. private _delayedOnError;
  17888. /**
  17889. * Observable triggered once the texture has been loaded.
  17890. */
  17891. onLoadObservable: Observable<Texture>;
  17892. protected _isBlocking: boolean;
  17893. /**
  17894. * Is the texture preventing material to render while loading.
  17895. * If false, a default texture will be used instead of the loading one during the preparation step.
  17896. */
  17897. isBlocking: boolean;
  17898. /**
  17899. * Get the current sampling mode associated with the texture.
  17900. */
  17901. readonly samplingMode: number;
  17902. /**
  17903. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17904. */
  17905. readonly invertY: boolean;
  17906. /**
  17907. * Instantiates a new texture.
  17908. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17909. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17910. * @param url define the url of the picture to load as a texture
  17911. * @param scene define the scene the texture will belong to
  17912. * @param noMipmap define if the texture will require mip maps or not
  17913. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17914. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17915. * @param onLoad define a callback triggered when the texture has been loaded
  17916. * @param onError define a callback triggered when an error occurred during the loading session
  17917. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17918. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17919. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17920. */
  17921. 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);
  17922. /**
  17923. * Update the url (and optional buffer) of this texture if url was null during construction.
  17924. * @param url the url of the texture
  17925. * @param buffer the buffer of the texture (defaults to null)
  17926. * @param onLoad callback called when the texture is loaded (defaults to null)
  17927. */
  17928. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17929. /**
  17930. * Finish the loading sequence of a texture flagged as delayed load.
  17931. * @hidden
  17932. */
  17933. delayLoad(): void;
  17934. private _prepareRowForTextureGeneration;
  17935. /**
  17936. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17937. * @returns the transform matrix of the texture.
  17938. */
  17939. getTextureMatrix(): Matrix;
  17940. /**
  17941. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17942. * @returns The reflection texture transform
  17943. */
  17944. getReflectionTextureMatrix(): Matrix;
  17945. /**
  17946. * Clones the texture.
  17947. * @returns the cloned texture
  17948. */
  17949. clone(): Texture;
  17950. /**
  17951. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17952. * @returns The JSON representation of the texture
  17953. */
  17954. serialize(): any;
  17955. /**
  17956. * Get the current class name of the texture useful for serialization or dynamic coding.
  17957. * @returns "Texture"
  17958. */
  17959. getClassName(): string;
  17960. /**
  17961. * Dispose the texture and release its associated resources.
  17962. */
  17963. dispose(): void;
  17964. /**
  17965. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17966. * @param parsedTexture Define the JSON representation of the texture
  17967. * @param scene Define the scene the parsed texture should be instantiated in
  17968. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17969. * @returns The parsed texture if successful
  17970. */
  17971. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17972. /**
  17973. * Creates a texture from its base 64 representation.
  17974. * @param data Define the base64 payload without the data: prefix
  17975. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17976. * @param scene Define the scene the texture should belong to
  17977. * @param noMipmap Forces the texture to not create mip map information if true
  17978. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17979. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17980. * @param onLoad define a callback triggered when the texture has been loaded
  17981. * @param onError define a callback triggered when an error occurred during the loading session
  17982. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17983. * @returns the created texture
  17984. */
  17985. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17986. /**
  17987. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17988. * @param data Define the base64 payload without the data: prefix
  17989. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17990. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17991. * @param scene Define the scene the texture should belong to
  17992. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17993. * @param noMipmap Forces the texture to not create mip map information if true
  17994. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17995. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17996. * @param onLoad define a callback triggered when the texture has been loaded
  17997. * @param onError define a callback triggered when an error occurred during the loading session
  17998. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17999. * @returns the created texture
  18000. */
  18001. 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;
  18002. }
  18003. }
  18004. declare module BABYLON {
  18005. interface Engine {
  18006. /**
  18007. * Creates a raw texture
  18008. * @param data defines the data to store in the texture
  18009. * @param width defines the width of the texture
  18010. * @param height defines the height of the texture
  18011. * @param format defines the format of the data
  18012. * @param generateMipMaps defines if the engine should generate the mip levels
  18013. * @param invertY defines if data must be stored with Y axis inverted
  18014. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18015. * @param compression defines the compression used (null by default)
  18016. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18017. * @returns the raw texture inside an InternalTexture
  18018. */
  18019. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18020. /**
  18021. * Update a raw texture
  18022. * @param texture defines the texture to update
  18023. * @param data defines the data to store in the texture
  18024. * @param format defines the format of the data
  18025. * @param invertY defines if data must be stored with Y axis inverted
  18026. */
  18027. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18028. /**
  18029. * Update a raw texture
  18030. * @param texture defines the texture to update
  18031. * @param data defines the data to store in the texture
  18032. * @param format defines the format of the data
  18033. * @param invertY defines if data must be stored with Y axis inverted
  18034. * @param compression defines the compression used (null by default)
  18035. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18036. */
  18037. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18038. /**
  18039. * Creates a new raw cube texture
  18040. * @param data defines the array of data to use to create each face
  18041. * @param size defines the size of the textures
  18042. * @param format defines the format of the data
  18043. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18044. * @param generateMipMaps defines if the engine should generate the mip levels
  18045. * @param invertY defines if data must be stored with Y axis inverted
  18046. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18047. * @param compression defines the compression used (null by default)
  18048. * @returns the cube texture as an InternalTexture
  18049. */
  18050. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18051. /**
  18052. * Update a raw cube texture
  18053. * @param texture defines the texture to udpdate
  18054. * @param data defines the data to store
  18055. * @param format defines the data format
  18056. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18057. * @param invertY defines if data must be stored with Y axis inverted
  18058. */
  18059. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18060. /**
  18061. * Update a raw cube texture
  18062. * @param texture defines the texture to udpdate
  18063. * @param data defines the data to store
  18064. * @param format defines the data format
  18065. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18066. * @param invertY defines if data must be stored with Y axis inverted
  18067. * @param compression defines the compression used (null by default)
  18068. */
  18069. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18070. /**
  18071. * Update a raw cube texture
  18072. * @param texture defines the texture to udpdate
  18073. * @param data defines the data to store
  18074. * @param format defines the data format
  18075. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18076. * @param invertY defines if data must be stored with Y axis inverted
  18077. * @param compression defines the compression used (null by default)
  18078. * @param level defines which level of the texture to update
  18079. */
  18080. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18081. /**
  18082. * Creates a new raw cube texture from a specified url
  18083. * @param url defines the url where the data is located
  18084. * @param scene defines the current scene
  18085. * @param size defines the size of the textures
  18086. * @param format defines the format of the data
  18087. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18088. * @param noMipmap defines if the engine should avoid generating the mip levels
  18089. * @param callback defines a callback used to extract texture data from loaded data
  18090. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18091. * @param onLoad defines a callback called when texture is loaded
  18092. * @param onError defines a callback called if there is an error
  18093. * @returns the cube texture as an InternalTexture
  18094. */
  18095. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  18096. /**
  18097. * Creates a new raw cube texture from a specified url
  18098. * @param url defines the url where the data is located
  18099. * @param scene defines the current scene
  18100. * @param size defines the size of the textures
  18101. * @param format defines the format of the data
  18102. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18103. * @param noMipmap defines if the engine should avoid generating the mip levels
  18104. * @param callback defines a callback used to extract texture data from loaded data
  18105. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18106. * @param onLoad defines a callback called when texture is loaded
  18107. * @param onError defines a callback called if there is an error
  18108. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18109. * @param invertY defines if data must be stored with Y axis inverted
  18110. * @returns the cube texture as an InternalTexture
  18111. */
  18112. 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;
  18113. /**
  18114. * Creates a new raw 3D texture
  18115. * @param data defines the data used to create the texture
  18116. * @param width defines the width of the texture
  18117. * @param height defines the height of the texture
  18118. * @param depth defines the depth of the texture
  18119. * @param format defines the format of the texture
  18120. * @param generateMipMaps defines if the engine must generate mip levels
  18121. * @param invertY defines if data must be stored with Y axis inverted
  18122. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18123. * @param compression defines the compressed used (can be null)
  18124. * @param textureType defines the compressed used (can be null)
  18125. * @returns a new raw 3D texture (stored in an InternalTexture)
  18126. */
  18127. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18128. /**
  18129. * Update a raw 3D texture
  18130. * @param texture defines the texture to update
  18131. * @param data defines the data to store
  18132. * @param format defines the data format
  18133. * @param invertY defines if data must be stored with Y axis inverted
  18134. */
  18135. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18136. /**
  18137. * Update a raw 3D texture
  18138. * @param texture defines the texture to update
  18139. * @param data defines the data to store
  18140. * @param format defines the data format
  18141. * @param invertY defines if data must be stored with Y axis inverted
  18142. * @param compression defines the used compression (can be null)
  18143. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18144. */
  18145. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18146. }
  18147. }
  18148. declare module BABYLON {
  18149. /**
  18150. * Raw texture can help creating a texture directly from an array of data.
  18151. * This can be super useful if you either get the data from an uncompressed source or
  18152. * if you wish to create your texture pixel by pixel.
  18153. */
  18154. export class RawTexture extends Texture {
  18155. /**
  18156. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18157. */
  18158. format: number;
  18159. private _engine;
  18160. /**
  18161. * Instantiates a new RawTexture.
  18162. * Raw texture can help creating a texture directly from an array of data.
  18163. * This can be super useful if you either get the data from an uncompressed source or
  18164. * if you wish to create your texture pixel by pixel.
  18165. * @param data define the array of data to use to create the texture
  18166. * @param width define the width of the texture
  18167. * @param height define the height of the texture
  18168. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18169. * @param scene define the scene the texture belongs to
  18170. * @param generateMipMaps define whether mip maps should be generated or not
  18171. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18172. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18173. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18174. */
  18175. constructor(data: ArrayBufferView, width: number, height: number,
  18176. /**
  18177. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18178. */
  18179. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18180. /**
  18181. * Updates the texture underlying data.
  18182. * @param data Define the new data of the texture
  18183. */
  18184. update(data: ArrayBufferView): void;
  18185. /**
  18186. * Creates a luminance texture from some data.
  18187. * @param data Define the texture data
  18188. * @param width Define the width of the texture
  18189. * @param height Define the height of the texture
  18190. * @param scene Define the scene the texture belongs to
  18191. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18192. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18193. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18194. * @returns the luminance texture
  18195. */
  18196. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18197. /**
  18198. * Creates a luminance alpha texture from some data.
  18199. * @param data Define the texture data
  18200. * @param width Define the width of the texture
  18201. * @param height Define the height of the texture
  18202. * @param scene Define the scene the texture belongs to
  18203. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18204. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18205. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18206. * @returns the luminance alpha texture
  18207. */
  18208. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18209. /**
  18210. * Creates an alpha texture from some data.
  18211. * @param data Define the texture data
  18212. * @param width Define the width of the texture
  18213. * @param height Define the height of the texture
  18214. * @param scene Define the scene the texture belongs to
  18215. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18216. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18217. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18218. * @returns the alpha texture
  18219. */
  18220. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18221. /**
  18222. * Creates a RGB texture from some data.
  18223. * @param data Define the texture data
  18224. * @param width Define the width of the texture
  18225. * @param height Define the height of the texture
  18226. * @param scene Define the scene the texture belongs to
  18227. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18228. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18229. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18230. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18231. * @returns the RGB alpha texture
  18232. */
  18233. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18234. /**
  18235. * Creates a RGBA texture from some data.
  18236. * @param data Define the texture data
  18237. * @param width Define the width of the texture
  18238. * @param height Define the height of the texture
  18239. * @param scene Define the scene the texture belongs to
  18240. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18241. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18242. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18243. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18244. * @returns the RGBA texture
  18245. */
  18246. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18247. /**
  18248. * Creates a R texture from some data.
  18249. * @param data Define the texture data
  18250. * @param width Define the width of the texture
  18251. * @param height Define the height of the texture
  18252. * @param scene Define the scene the texture belongs to
  18253. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18254. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18255. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18256. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18257. * @returns the R texture
  18258. */
  18259. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18260. }
  18261. }
  18262. declare module BABYLON {
  18263. /**
  18264. * Defines a runtime animation
  18265. */
  18266. export class RuntimeAnimation {
  18267. private _events;
  18268. /**
  18269. * The current frame of the runtime animation
  18270. */
  18271. private _currentFrame;
  18272. /**
  18273. * The animation used by the runtime animation
  18274. */
  18275. private _animation;
  18276. /**
  18277. * The target of the runtime animation
  18278. */
  18279. private _target;
  18280. /**
  18281. * The initiating animatable
  18282. */
  18283. private _host;
  18284. /**
  18285. * The original value of the runtime animation
  18286. */
  18287. private _originalValue;
  18288. /**
  18289. * The original blend value of the runtime animation
  18290. */
  18291. private _originalBlendValue;
  18292. /**
  18293. * The offsets cache of the runtime animation
  18294. */
  18295. private _offsetsCache;
  18296. /**
  18297. * The high limits cache of the runtime animation
  18298. */
  18299. private _highLimitsCache;
  18300. /**
  18301. * Specifies if the runtime animation has been stopped
  18302. */
  18303. private _stopped;
  18304. /**
  18305. * The blending factor of the runtime animation
  18306. */
  18307. private _blendingFactor;
  18308. /**
  18309. * The BabylonJS scene
  18310. */
  18311. private _scene;
  18312. /**
  18313. * The current value of the runtime animation
  18314. */
  18315. private _currentValue;
  18316. /** @hidden */ animationState: _IAnimationState;
  18317. /**
  18318. * The active target of the runtime animation
  18319. */
  18320. private _activeTargets;
  18321. private _currentActiveTarget;
  18322. private _directTarget;
  18323. /**
  18324. * The target path of the runtime animation
  18325. */
  18326. private _targetPath;
  18327. /**
  18328. * The weight of the runtime animation
  18329. */
  18330. private _weight;
  18331. /**
  18332. * The ratio offset of the runtime animation
  18333. */
  18334. private _ratioOffset;
  18335. /**
  18336. * The previous delay of the runtime animation
  18337. */
  18338. private _previousDelay;
  18339. /**
  18340. * The previous ratio of the runtime animation
  18341. */
  18342. private _previousRatio;
  18343. private _enableBlending;
  18344. private _keys;
  18345. private _minFrame;
  18346. private _maxFrame;
  18347. private _minValue;
  18348. private _maxValue;
  18349. private _targetIsArray;
  18350. /**
  18351. * Gets the current frame of the runtime animation
  18352. */
  18353. readonly currentFrame: number;
  18354. /**
  18355. * Gets the weight of the runtime animation
  18356. */
  18357. readonly weight: number;
  18358. /**
  18359. * Gets the current value of the runtime animation
  18360. */
  18361. readonly currentValue: any;
  18362. /**
  18363. * Gets the target path of the runtime animation
  18364. */
  18365. readonly targetPath: string;
  18366. /**
  18367. * Gets the actual target of the runtime animation
  18368. */
  18369. readonly target: any;
  18370. /** @hidden */ onLoop: () => void;
  18371. /**
  18372. * Create a new RuntimeAnimation object
  18373. * @param target defines the target of the animation
  18374. * @param animation defines the source animation object
  18375. * @param scene defines the hosting scene
  18376. * @param host defines the initiating Animatable
  18377. */
  18378. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18379. private _preparePath;
  18380. /**
  18381. * Gets the animation from the runtime animation
  18382. */
  18383. readonly animation: Animation;
  18384. /**
  18385. * Resets the runtime animation to the beginning
  18386. * @param restoreOriginal defines whether to restore the target property to the original value
  18387. */
  18388. reset(restoreOriginal?: boolean): void;
  18389. /**
  18390. * Specifies if the runtime animation is stopped
  18391. * @returns Boolean specifying if the runtime animation is stopped
  18392. */
  18393. isStopped(): boolean;
  18394. /**
  18395. * Disposes of the runtime animation
  18396. */
  18397. dispose(): void;
  18398. /**
  18399. * Apply the interpolated value to the target
  18400. * @param currentValue defines the value computed by the animation
  18401. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18402. */
  18403. setValue(currentValue: any, weight: number): void;
  18404. private _getOriginalValues;
  18405. private _setValue;
  18406. /**
  18407. * Gets the loop pmode of the runtime animation
  18408. * @returns Loop Mode
  18409. */
  18410. private _getCorrectLoopMode;
  18411. /**
  18412. * Move the current animation to a given frame
  18413. * @param frame defines the frame to move to
  18414. */
  18415. goToFrame(frame: number): void;
  18416. /**
  18417. * @hidden Internal use only
  18418. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18419. /**
  18420. * Execute the current animation
  18421. * @param delay defines the delay to add to the current frame
  18422. * @param from defines the lower bound of the animation range
  18423. * @param to defines the upper bound of the animation range
  18424. * @param loop defines if the current animation must loop
  18425. * @param speedRatio defines the current speed ratio
  18426. * @param weight defines the weight of the animation (default is -1 so no weight)
  18427. * @param onLoop optional callback called when animation loops
  18428. * @returns a boolean indicating if the animation is running
  18429. */
  18430. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18431. }
  18432. }
  18433. declare module BABYLON {
  18434. /**
  18435. * Class used to store an actual running animation
  18436. */
  18437. export class Animatable {
  18438. /** defines the target object */
  18439. target: any;
  18440. /** defines the starting frame number (default is 0) */
  18441. fromFrame: number;
  18442. /** defines the ending frame number (default is 100) */
  18443. toFrame: number;
  18444. /** defines if the animation must loop (default is false) */
  18445. loopAnimation: boolean;
  18446. /** defines a callback to call when animation ends if it is not looping */
  18447. onAnimationEnd?: (() => void) | null | undefined;
  18448. /** defines a callback to call when animation loops */
  18449. onAnimationLoop?: (() => void) | null | undefined;
  18450. private _localDelayOffset;
  18451. private _pausedDelay;
  18452. private _runtimeAnimations;
  18453. private _paused;
  18454. private _scene;
  18455. private _speedRatio;
  18456. private _weight;
  18457. private _syncRoot;
  18458. /**
  18459. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18460. * This will only apply for non looping animation (default is true)
  18461. */
  18462. disposeOnEnd: boolean;
  18463. /**
  18464. * Gets a boolean indicating if the animation has started
  18465. */
  18466. animationStarted: boolean;
  18467. /**
  18468. * Observer raised when the animation ends
  18469. */
  18470. onAnimationEndObservable: Observable<Animatable>;
  18471. /**
  18472. * Observer raised when the animation loops
  18473. */
  18474. onAnimationLoopObservable: Observable<Animatable>;
  18475. /**
  18476. * Gets the root Animatable used to synchronize and normalize animations
  18477. */
  18478. readonly syncRoot: Nullable<Animatable>;
  18479. /**
  18480. * Gets the current frame of the first RuntimeAnimation
  18481. * Used to synchronize Animatables
  18482. */
  18483. readonly masterFrame: number;
  18484. /**
  18485. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18486. */
  18487. weight: number;
  18488. /**
  18489. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18490. */
  18491. speedRatio: number;
  18492. /**
  18493. * Creates a new Animatable
  18494. * @param scene defines the hosting scene
  18495. * @param target defines the target object
  18496. * @param fromFrame defines the starting frame number (default is 0)
  18497. * @param toFrame defines the ending frame number (default is 100)
  18498. * @param loopAnimation defines if the animation must loop (default is false)
  18499. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18500. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18501. * @param animations defines a group of animation to add to the new Animatable
  18502. * @param onAnimationLoop defines a callback to call when animation loops
  18503. */
  18504. constructor(scene: Scene,
  18505. /** defines the target object */
  18506. target: any,
  18507. /** defines the starting frame number (default is 0) */
  18508. fromFrame?: number,
  18509. /** defines the ending frame number (default is 100) */
  18510. toFrame?: number,
  18511. /** defines if the animation must loop (default is false) */
  18512. loopAnimation?: boolean, speedRatio?: number,
  18513. /** defines a callback to call when animation ends if it is not looping */
  18514. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18515. /** defines a callback to call when animation loops */
  18516. onAnimationLoop?: (() => void) | null | undefined);
  18517. /**
  18518. * Synchronize and normalize current Animatable with a source Animatable
  18519. * This is useful when using animation weights and when animations are not of the same length
  18520. * @param root defines the root Animatable to synchronize with
  18521. * @returns the current Animatable
  18522. */
  18523. syncWith(root: Animatable): Animatable;
  18524. /**
  18525. * Gets the list of runtime animations
  18526. * @returns an array of RuntimeAnimation
  18527. */
  18528. getAnimations(): RuntimeAnimation[];
  18529. /**
  18530. * Adds more animations to the current animatable
  18531. * @param target defines the target of the animations
  18532. * @param animations defines the new animations to add
  18533. */
  18534. appendAnimations(target: any, animations: Animation[]): void;
  18535. /**
  18536. * Gets the source animation for a specific property
  18537. * @param property defines the propertyu to look for
  18538. * @returns null or the source animation for the given property
  18539. */
  18540. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18541. /**
  18542. * Gets the runtime animation for a specific property
  18543. * @param property defines the propertyu to look for
  18544. * @returns null or the runtime animation for the given property
  18545. */
  18546. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18547. /**
  18548. * Resets the animatable to its original state
  18549. */
  18550. reset(): void;
  18551. /**
  18552. * Allows the animatable to blend with current running animations
  18553. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18554. * @param blendingSpeed defines the blending speed to use
  18555. */
  18556. enableBlending(blendingSpeed: number): void;
  18557. /**
  18558. * Disable animation blending
  18559. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18560. */
  18561. disableBlending(): void;
  18562. /**
  18563. * Jump directly to a given frame
  18564. * @param frame defines the frame to jump to
  18565. */
  18566. goToFrame(frame: number): void;
  18567. /**
  18568. * Pause the animation
  18569. */
  18570. pause(): void;
  18571. /**
  18572. * Restart the animation
  18573. */
  18574. restart(): void;
  18575. private _raiseOnAnimationEnd;
  18576. /**
  18577. * Stop and delete the current animation
  18578. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18579. * @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)
  18580. */
  18581. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18582. /**
  18583. * Wait asynchronously for the animation to end
  18584. * @returns a promise which will be fullfilled when the animation ends
  18585. */
  18586. waitAsync(): Promise<Animatable>;
  18587. /** @hidden */ animate(delay: number): boolean;
  18588. }
  18589. interface Scene {
  18590. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18591. /** @hidden */ processLateAnimationBindingsForMatrices(holder: {
  18592. totalWeight: number;
  18593. animations: RuntimeAnimation[];
  18594. originalValue: Matrix;
  18595. }): any;
  18596. /** @hidden */ processLateAnimationBindingsForQuaternions(holder: {
  18597. totalWeight: number;
  18598. animations: RuntimeAnimation[];
  18599. originalValue: Quaternion;
  18600. }, refQuaternion: Quaternion): Quaternion;
  18601. /** @hidden */ processLateAnimationBindings(): void;
  18602. /**
  18603. * Will start the animation sequence of a given target
  18604. * @param target defines the target
  18605. * @param from defines from which frame should animation start
  18606. * @param to defines until which frame should animation run.
  18607. * @param weight defines the weight to apply to the animation (1.0 by default)
  18608. * @param loop defines if the animation loops
  18609. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18610. * @param onAnimationEnd defines the function to be executed when the animation ends
  18611. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18612. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18613. * @param onAnimationLoop defines the callback to call when an animation loops
  18614. * @returns the animatable object created for this animation
  18615. */
  18616. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18617. /**
  18618. * Will start the animation sequence of a given target
  18619. * @param target defines the target
  18620. * @param from defines from which frame should animation start
  18621. * @param to defines until which frame should animation run.
  18622. * @param loop defines if the animation loops
  18623. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18624. * @param onAnimationEnd defines the function to be executed when the animation ends
  18625. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18626. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18627. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18628. * @param onAnimationLoop defines the callback to call when an animation loops
  18629. * @returns the animatable object created for this animation
  18630. */
  18631. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18632. /**
  18633. * Will start the animation sequence of a given target and its hierarchy
  18634. * @param target defines the target
  18635. * @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.
  18636. * @param from defines from which frame should animation start
  18637. * @param to defines until which frame should animation run.
  18638. * @param loop defines if the animation loops
  18639. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18640. * @param onAnimationEnd defines the function to be executed when the animation ends
  18641. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18642. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18643. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18644. * @param onAnimationLoop defines the callback to call when an animation loops
  18645. * @returns the list of created animatables
  18646. */
  18647. 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[];
  18648. /**
  18649. * Begin a new animation on a given node
  18650. * @param target defines the target where the animation will take place
  18651. * @param animations defines the list of animations to start
  18652. * @param from defines the initial value
  18653. * @param to defines the final value
  18654. * @param loop defines if you want animation to loop (off by default)
  18655. * @param speedRatio defines the speed ratio to apply to all animations
  18656. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18657. * @param onAnimationLoop defines the callback to call when an animation loops
  18658. * @returns the list of created animatables
  18659. */
  18660. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18661. /**
  18662. * Begin a new animation on a given node and its hierarchy
  18663. * @param target defines the root node where the animation will take place
  18664. * @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.
  18665. * @param animations defines the list of animations to start
  18666. * @param from defines the initial value
  18667. * @param to defines the final value
  18668. * @param loop defines if you want animation to loop (off by default)
  18669. * @param speedRatio defines the speed ratio to apply to all animations
  18670. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18671. * @param onAnimationLoop defines the callback to call when an animation loops
  18672. * @returns the list of animatables created for all nodes
  18673. */
  18674. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18675. /**
  18676. * Gets the animatable associated with a specific target
  18677. * @param target defines the target of the animatable
  18678. * @returns the required animatable if found
  18679. */
  18680. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18681. /**
  18682. * Gets all animatables associated with a given target
  18683. * @param target defines the target to look animatables for
  18684. * @returns an array of Animatables
  18685. */
  18686. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18687. /**
  18688. * Will stop the animation of the given target
  18689. * @param target - the target
  18690. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18691. * @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)
  18692. */
  18693. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18694. /**
  18695. * Stops and removes all animations that have been applied to the scene
  18696. */
  18697. stopAllAnimations(): void;
  18698. }
  18699. interface Bone {
  18700. /**
  18701. * Copy an animation range from another bone
  18702. * @param source defines the source bone
  18703. * @param rangeName defines the range name to copy
  18704. * @param frameOffset defines the frame offset
  18705. * @param rescaleAsRequired defines if rescaling must be applied if required
  18706. * @param skelDimensionsRatio defines the scaling ratio
  18707. * @returns true if operation was successful
  18708. */
  18709. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18710. }
  18711. }
  18712. declare module BABYLON {
  18713. /**
  18714. * Class used to handle skinning animations
  18715. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18716. */
  18717. export class Skeleton implements IAnimatable {
  18718. /** defines the skeleton name */
  18719. name: string;
  18720. /** defines the skeleton Id */
  18721. id: string;
  18722. /**
  18723. * Defines the list of child bones
  18724. */
  18725. bones: Bone[];
  18726. /**
  18727. * Defines an estimate of the dimension of the skeleton at rest
  18728. */
  18729. dimensionsAtRest: Vector3;
  18730. /**
  18731. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18732. */
  18733. needInitialSkinMatrix: boolean;
  18734. /**
  18735. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18736. */
  18737. overrideMesh: Nullable<AbstractMesh>;
  18738. /**
  18739. * Gets the list of animations attached to this skeleton
  18740. */
  18741. animations: Array<Animation>;
  18742. private _scene;
  18743. private _isDirty;
  18744. private _transformMatrices;
  18745. private _transformMatrixTexture;
  18746. private _meshesWithPoseMatrix;
  18747. private _animatables;
  18748. private _identity;
  18749. private _synchronizedWithMesh;
  18750. private _ranges;
  18751. private _lastAbsoluteTransformsUpdateId;
  18752. private _canUseTextureForBones;
  18753. private _uniqueId;
  18754. /** @hidden */ numBonesWithLinkedTransformNode: number;
  18755. /**
  18756. * Specifies if the skeleton should be serialized
  18757. */
  18758. doNotSerialize: boolean;
  18759. private _useTextureToStoreBoneMatrices;
  18760. /**
  18761. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18762. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18763. */
  18764. useTextureToStoreBoneMatrices: boolean;
  18765. private _animationPropertiesOverride;
  18766. /**
  18767. * Gets or sets the animation properties override
  18768. */
  18769. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18770. /**
  18771. * List of inspectable custom properties (used by the Inspector)
  18772. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18773. */
  18774. inspectableCustomProperties: IInspectable[];
  18775. /**
  18776. * An observable triggered before computing the skeleton's matrices
  18777. */
  18778. onBeforeComputeObservable: Observable<Skeleton>;
  18779. /**
  18780. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18781. */
  18782. readonly isUsingTextureForMatrices: boolean;
  18783. /**
  18784. * Gets the unique ID of this skeleton
  18785. */
  18786. readonly uniqueId: number;
  18787. /**
  18788. * Creates a new skeleton
  18789. * @param name defines the skeleton name
  18790. * @param id defines the skeleton Id
  18791. * @param scene defines the hosting scene
  18792. */
  18793. constructor(
  18794. /** defines the skeleton name */
  18795. name: string,
  18796. /** defines the skeleton Id */
  18797. id: string, scene: Scene);
  18798. /**
  18799. * Gets the current object class name.
  18800. * @return the class name
  18801. */
  18802. getClassName(): string;
  18803. /**
  18804. * Returns an array containing the root bones
  18805. * @returns an array containing the root bones
  18806. */
  18807. getChildren(): Array<Bone>;
  18808. /**
  18809. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18810. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18811. * @returns a Float32Array containing matrices data
  18812. */
  18813. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18814. /**
  18815. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18816. * @returns a raw texture containing the data
  18817. */
  18818. getTransformMatrixTexture(): Nullable<RawTexture>;
  18819. /**
  18820. * Gets the current hosting scene
  18821. * @returns a scene object
  18822. */
  18823. getScene(): Scene;
  18824. /**
  18825. * Gets a string representing the current skeleton data
  18826. * @param fullDetails defines a boolean indicating if we want a verbose version
  18827. * @returns a string representing the current skeleton data
  18828. */
  18829. toString(fullDetails?: boolean): string;
  18830. /**
  18831. * Get bone's index searching by name
  18832. * @param name defines bone's name to search for
  18833. * @return the indice of the bone. Returns -1 if not found
  18834. */
  18835. getBoneIndexByName(name: string): number;
  18836. /**
  18837. * Creater a new animation range
  18838. * @param name defines the name of the range
  18839. * @param from defines the start key
  18840. * @param to defines the end key
  18841. */
  18842. createAnimationRange(name: string, from: number, to: number): void;
  18843. /**
  18844. * Delete a specific animation range
  18845. * @param name defines the name of the range
  18846. * @param deleteFrames defines if frames must be removed as well
  18847. */
  18848. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18849. /**
  18850. * Gets a specific animation range
  18851. * @param name defines the name of the range to look for
  18852. * @returns the requested animation range or null if not found
  18853. */
  18854. getAnimationRange(name: string): Nullable<AnimationRange>;
  18855. /**
  18856. * Gets the list of all animation ranges defined on this skeleton
  18857. * @returns an array
  18858. */
  18859. getAnimationRanges(): Nullable<AnimationRange>[];
  18860. /**
  18861. * Copy animation range from a source skeleton.
  18862. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18863. * @param source defines the source skeleton
  18864. * @param name defines the name of the range to copy
  18865. * @param rescaleAsRequired defines if rescaling must be applied if required
  18866. * @returns true if operation was successful
  18867. */
  18868. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18869. /**
  18870. * Forces the skeleton to go to rest pose
  18871. */
  18872. returnToRest(): void;
  18873. private _getHighestAnimationFrame;
  18874. /**
  18875. * Begin a specific animation range
  18876. * @param name defines the name of the range to start
  18877. * @param loop defines if looping must be turned on (false by default)
  18878. * @param speedRatio defines the speed ratio to apply (1 by default)
  18879. * @param onAnimationEnd defines a callback which will be called when animation will end
  18880. * @returns a new animatable
  18881. */
  18882. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18883. /** @hidden */ markAsDirty(): void;
  18884. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18885. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18886. private _computeTransformMatrices;
  18887. /**
  18888. * Build all resources required to render a skeleton
  18889. */
  18890. prepare(): void;
  18891. /**
  18892. * Gets the list of animatables currently running for this skeleton
  18893. * @returns an array of animatables
  18894. */
  18895. getAnimatables(): IAnimatable[];
  18896. /**
  18897. * Clone the current skeleton
  18898. * @param name defines the name of the new skeleton
  18899. * @param id defines the id of the new skeleton
  18900. * @returns the new skeleton
  18901. */
  18902. clone(name: string, id: string): Skeleton;
  18903. /**
  18904. * Enable animation blending for this skeleton
  18905. * @param blendingSpeed defines the blending speed to apply
  18906. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18907. */
  18908. enableBlending(blendingSpeed?: number): void;
  18909. /**
  18910. * Releases all resources associated with the current skeleton
  18911. */
  18912. dispose(): void;
  18913. /**
  18914. * Serialize the skeleton in a JSON object
  18915. * @returns a JSON object
  18916. */
  18917. serialize(): any;
  18918. /**
  18919. * Creates a new skeleton from serialized data
  18920. * @param parsedSkeleton defines the serialized data
  18921. * @param scene defines the hosting scene
  18922. * @returns a new skeleton
  18923. */
  18924. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18925. /**
  18926. * Compute all node absolute transforms
  18927. * @param forceUpdate defines if computation must be done even if cache is up to date
  18928. */
  18929. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18930. /**
  18931. * Gets the root pose matrix
  18932. * @returns a matrix
  18933. */
  18934. getPoseMatrix(): Nullable<Matrix>;
  18935. /**
  18936. * Sorts bones per internal index
  18937. */
  18938. sortBones(): void;
  18939. private _sortBones;
  18940. }
  18941. }
  18942. declare module BABYLON {
  18943. /**
  18944. * Defines a target to use with MorphTargetManager
  18945. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18946. */
  18947. export class MorphTarget implements IAnimatable {
  18948. /** defines the name of the target */
  18949. name: string;
  18950. /**
  18951. * Gets or sets the list of animations
  18952. */
  18953. animations: Animation[];
  18954. private _scene;
  18955. private _positions;
  18956. private _normals;
  18957. private _tangents;
  18958. private _influence;
  18959. /**
  18960. * Observable raised when the influence changes
  18961. */
  18962. onInfluenceChanged: Observable<boolean>;
  18963. /** @hidden */ onDataLayoutChanged: Observable<void>;
  18964. /**
  18965. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18966. */
  18967. influence: number;
  18968. /**
  18969. * Gets or sets the id of the morph Target
  18970. */
  18971. id: string;
  18972. private _animationPropertiesOverride;
  18973. /**
  18974. * Gets or sets the animation properties override
  18975. */
  18976. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18977. /**
  18978. * Creates a new MorphTarget
  18979. * @param name defines the name of the target
  18980. * @param influence defines the influence to use
  18981. * @param scene defines the scene the morphtarget belongs to
  18982. */
  18983. constructor(
  18984. /** defines the name of the target */
  18985. name: string, influence?: number, scene?: Nullable<Scene>);
  18986. /**
  18987. * Gets a boolean defining if the target contains position data
  18988. */
  18989. readonly hasPositions: boolean;
  18990. /**
  18991. * Gets a boolean defining if the target contains normal data
  18992. */
  18993. readonly hasNormals: boolean;
  18994. /**
  18995. * Gets a boolean defining if the target contains tangent data
  18996. */
  18997. readonly hasTangents: boolean;
  18998. /**
  18999. * Affects position data to this target
  19000. * @param data defines the position data to use
  19001. */
  19002. setPositions(data: Nullable<FloatArray>): void;
  19003. /**
  19004. * Gets the position data stored in this target
  19005. * @returns a FloatArray containing the position data (or null if not present)
  19006. */
  19007. getPositions(): Nullable<FloatArray>;
  19008. /**
  19009. * Affects normal data to this target
  19010. * @param data defines the normal data to use
  19011. */
  19012. setNormals(data: Nullable<FloatArray>): void;
  19013. /**
  19014. * Gets the normal data stored in this target
  19015. * @returns a FloatArray containing the normal data (or null if not present)
  19016. */
  19017. getNormals(): Nullable<FloatArray>;
  19018. /**
  19019. * Affects tangent data to this target
  19020. * @param data defines the tangent data to use
  19021. */
  19022. setTangents(data: Nullable<FloatArray>): void;
  19023. /**
  19024. * Gets the tangent data stored in this target
  19025. * @returns a FloatArray containing the tangent data (or null if not present)
  19026. */
  19027. getTangents(): Nullable<FloatArray>;
  19028. /**
  19029. * Serializes the current target into a Serialization object
  19030. * @returns the serialized object
  19031. */
  19032. serialize(): any;
  19033. /**
  19034. * Returns the string "MorphTarget"
  19035. * @returns "MorphTarget"
  19036. */
  19037. getClassName(): string;
  19038. /**
  19039. * Creates a new target from serialized data
  19040. * @param serializationObject defines the serialized data to use
  19041. * @returns a new MorphTarget
  19042. */
  19043. static Parse(serializationObject: any): MorphTarget;
  19044. /**
  19045. * Creates a MorphTarget from mesh data
  19046. * @param mesh defines the source mesh
  19047. * @param name defines the name to use for the new target
  19048. * @param influence defines the influence to attach to the target
  19049. * @returns a new MorphTarget
  19050. */
  19051. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19052. }
  19053. }
  19054. declare module BABYLON {
  19055. /**
  19056. * This class is used to deform meshes using morphing between different targets
  19057. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19058. */
  19059. export class MorphTargetManager {
  19060. private _targets;
  19061. private _targetInfluenceChangedObservers;
  19062. private _targetDataLayoutChangedObservers;
  19063. private _activeTargets;
  19064. private _scene;
  19065. private _influences;
  19066. private _supportsNormals;
  19067. private _supportsTangents;
  19068. private _vertexCount;
  19069. private _uniqueId;
  19070. private _tempInfluences;
  19071. /**
  19072. * Creates a new MorphTargetManager
  19073. * @param scene defines the current scene
  19074. */
  19075. constructor(scene?: Nullable<Scene>);
  19076. /**
  19077. * Gets the unique ID of this manager
  19078. */
  19079. readonly uniqueId: number;
  19080. /**
  19081. * Gets the number of vertices handled by this manager
  19082. */
  19083. readonly vertexCount: number;
  19084. /**
  19085. * Gets a boolean indicating if this manager supports morphing of normals
  19086. */
  19087. readonly supportsNormals: boolean;
  19088. /**
  19089. * Gets a boolean indicating if this manager supports morphing of tangents
  19090. */
  19091. readonly supportsTangents: boolean;
  19092. /**
  19093. * Gets the number of targets stored in this manager
  19094. */
  19095. readonly numTargets: number;
  19096. /**
  19097. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19098. */
  19099. readonly numInfluencers: number;
  19100. /**
  19101. * Gets the list of influences (one per target)
  19102. */
  19103. readonly influences: Float32Array;
  19104. /**
  19105. * Gets the active target at specified index. An active target is a target with an influence > 0
  19106. * @param index defines the index to check
  19107. * @returns the requested target
  19108. */
  19109. getActiveTarget(index: number): MorphTarget;
  19110. /**
  19111. * Gets the target at specified index
  19112. * @param index defines the index to check
  19113. * @returns the requested target
  19114. */
  19115. getTarget(index: number): MorphTarget;
  19116. /**
  19117. * Add a new target to this manager
  19118. * @param target defines the target to add
  19119. */
  19120. addTarget(target: MorphTarget): void;
  19121. /**
  19122. * Removes a target from the manager
  19123. * @param target defines the target to remove
  19124. */
  19125. removeTarget(target: MorphTarget): void;
  19126. /**
  19127. * Serializes the current manager into a Serialization object
  19128. * @returns the serialized object
  19129. */
  19130. serialize(): any;
  19131. private _syncActiveTargets;
  19132. /**
  19133. * Syncrhonize the targets with all the meshes using this morph target manager
  19134. */
  19135. synchronize(): void;
  19136. /**
  19137. * Creates a new MorphTargetManager from serialized data
  19138. * @param serializationObject defines the serialized data
  19139. * @param scene defines the hosting scene
  19140. * @returns the new MorphTargetManager
  19141. */
  19142. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19143. }
  19144. }
  19145. declare module BABYLON {
  19146. /**
  19147. * Mesh representing the gorund
  19148. */
  19149. export class GroundMesh extends Mesh {
  19150. /** If octree should be generated */
  19151. generateOctree: boolean;
  19152. private _heightQuads;
  19153. /** @hidden */ subdivisionsX: number;
  19154. /** @hidden */ subdivisionsY: number;
  19155. /** @hidden */ width: number;
  19156. /** @hidden */ height: number;
  19157. /** @hidden */ minX: number;
  19158. /** @hidden */ maxX: number;
  19159. /** @hidden */ minZ: number;
  19160. /** @hidden */ maxZ: number;
  19161. constructor(name: string, scene: Scene);
  19162. /**
  19163. * "GroundMesh"
  19164. * @returns "GroundMesh"
  19165. */
  19166. getClassName(): string;
  19167. /**
  19168. * The minimum of x and y subdivisions
  19169. */
  19170. readonly subdivisions: number;
  19171. /**
  19172. * X subdivisions
  19173. */
  19174. readonly subdivisionsX: number;
  19175. /**
  19176. * Y subdivisions
  19177. */
  19178. readonly subdivisionsY: number;
  19179. /**
  19180. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19181. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19182. * @param chunksCount the number of subdivisions for x and y
  19183. * @param octreeBlocksSize (Default: 32)
  19184. */
  19185. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19186. /**
  19187. * Returns a height (y) value in the Worl system :
  19188. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19189. * @param x x coordinate
  19190. * @param z z coordinate
  19191. * @returns the ground y position if (x, z) are outside the ground surface.
  19192. */
  19193. getHeightAtCoordinates(x: number, z: number): number;
  19194. /**
  19195. * Returns a normalized vector (Vector3) orthogonal to the ground
  19196. * at the ground coordinates (x, z) expressed in the World system.
  19197. * @param x x coordinate
  19198. * @param z z coordinate
  19199. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19200. */
  19201. getNormalAtCoordinates(x: number, z: number): Vector3;
  19202. /**
  19203. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19204. * at the ground coordinates (x, z) expressed in the World system.
  19205. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19206. * @param x x coordinate
  19207. * @param z z coordinate
  19208. * @param ref vector to store the result
  19209. * @returns the GroundMesh.
  19210. */
  19211. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19212. /**
  19213. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19214. * if the ground has been updated.
  19215. * This can be used in the render loop.
  19216. * @returns the GroundMesh.
  19217. */
  19218. updateCoordinateHeights(): GroundMesh;
  19219. private _getFacetAt;
  19220. private _initHeightQuads;
  19221. private _computeHeightQuads;
  19222. /**
  19223. * Serializes this ground mesh
  19224. * @param serializationObject object to write serialization to
  19225. */
  19226. serialize(serializationObject: any): void;
  19227. /**
  19228. * Parses a serialized ground mesh
  19229. * @param parsedMesh the serialized mesh
  19230. * @param scene the scene to create the ground mesh in
  19231. * @returns the created ground mesh
  19232. */
  19233. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19234. }
  19235. }
  19236. declare module BABYLON {
  19237. /**
  19238. * Interface for Physics-Joint data
  19239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19240. */
  19241. export interface PhysicsJointData {
  19242. /**
  19243. * The main pivot of the joint
  19244. */
  19245. mainPivot?: Vector3;
  19246. /**
  19247. * The connected pivot of the joint
  19248. */
  19249. connectedPivot?: Vector3;
  19250. /**
  19251. * The main axis of the joint
  19252. */
  19253. mainAxis?: Vector3;
  19254. /**
  19255. * The connected axis of the joint
  19256. */
  19257. connectedAxis?: Vector3;
  19258. /**
  19259. * The collision of the joint
  19260. */
  19261. collision?: boolean;
  19262. /**
  19263. * Native Oimo/Cannon/Energy data
  19264. */
  19265. nativeParams?: any;
  19266. }
  19267. /**
  19268. * This is a holder class for the physics joint created by the physics plugin
  19269. * It holds a set of functions to control the underlying joint
  19270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19271. */
  19272. export class PhysicsJoint {
  19273. /**
  19274. * The type of the physics joint
  19275. */
  19276. type: number;
  19277. /**
  19278. * The data for the physics joint
  19279. */
  19280. jointData: PhysicsJointData;
  19281. private _physicsJoint;
  19282. protected _physicsPlugin: IPhysicsEnginePlugin;
  19283. /**
  19284. * Initializes the physics joint
  19285. * @param type The type of the physics joint
  19286. * @param jointData The data for the physics joint
  19287. */
  19288. constructor(
  19289. /**
  19290. * The type of the physics joint
  19291. */
  19292. type: number,
  19293. /**
  19294. * The data for the physics joint
  19295. */
  19296. jointData: PhysicsJointData);
  19297. /**
  19298. * Gets the physics joint
  19299. */
  19300. /**
  19301. * Sets the physics joint
  19302. */
  19303. physicsJoint: any;
  19304. /**
  19305. * Sets the physics plugin
  19306. */
  19307. physicsPlugin: IPhysicsEnginePlugin;
  19308. /**
  19309. * Execute a function that is physics-plugin specific.
  19310. * @param {Function} func the function that will be executed.
  19311. * It accepts two parameters: the physics world and the physics joint
  19312. */
  19313. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19314. /**
  19315. * Distance-Joint type
  19316. */
  19317. static DistanceJoint: number;
  19318. /**
  19319. * Hinge-Joint type
  19320. */
  19321. static HingeJoint: number;
  19322. /**
  19323. * Ball-and-Socket joint type
  19324. */
  19325. static BallAndSocketJoint: number;
  19326. /**
  19327. * Wheel-Joint type
  19328. */
  19329. static WheelJoint: number;
  19330. /**
  19331. * Slider-Joint type
  19332. */
  19333. static SliderJoint: number;
  19334. /**
  19335. * Prismatic-Joint type
  19336. */
  19337. static PrismaticJoint: number;
  19338. /**
  19339. * Universal-Joint type
  19340. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19341. */
  19342. static UniversalJoint: number;
  19343. /**
  19344. * Hinge-Joint 2 type
  19345. */
  19346. static Hinge2Joint: number;
  19347. /**
  19348. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19349. */
  19350. static PointToPointJoint: number;
  19351. /**
  19352. * Spring-Joint type
  19353. */
  19354. static SpringJoint: number;
  19355. /**
  19356. * Lock-Joint type
  19357. */
  19358. static LockJoint: number;
  19359. }
  19360. /**
  19361. * A class representing a physics distance joint
  19362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19363. */
  19364. export class DistanceJoint extends PhysicsJoint {
  19365. /**
  19366. *
  19367. * @param jointData The data for the Distance-Joint
  19368. */
  19369. constructor(jointData: DistanceJointData);
  19370. /**
  19371. * Update the predefined distance.
  19372. * @param maxDistance The maximum preferred distance
  19373. * @param minDistance The minimum preferred distance
  19374. */
  19375. updateDistance(maxDistance: number, minDistance?: number): void;
  19376. }
  19377. /**
  19378. * Represents a Motor-Enabled Joint
  19379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19380. */
  19381. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19382. /**
  19383. * Initializes the Motor-Enabled Joint
  19384. * @param type The type of the joint
  19385. * @param jointData The physica joint data for the joint
  19386. */
  19387. constructor(type: number, jointData: PhysicsJointData);
  19388. /**
  19389. * Set the motor values.
  19390. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19391. * @param force the force to apply
  19392. * @param maxForce max force for this motor.
  19393. */
  19394. setMotor(force?: number, maxForce?: number): void;
  19395. /**
  19396. * Set the motor's limits.
  19397. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19398. * @param upperLimit The upper limit of the motor
  19399. * @param lowerLimit The lower limit of the motor
  19400. */
  19401. setLimit(upperLimit: number, lowerLimit?: number): void;
  19402. }
  19403. /**
  19404. * This class represents a single physics Hinge-Joint
  19405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19406. */
  19407. export class HingeJoint extends MotorEnabledJoint {
  19408. /**
  19409. * Initializes the Hinge-Joint
  19410. * @param jointData The joint data for the Hinge-Joint
  19411. */
  19412. constructor(jointData: PhysicsJointData);
  19413. /**
  19414. * Set the motor values.
  19415. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19416. * @param {number} force the force to apply
  19417. * @param {number} maxForce max force for this motor.
  19418. */
  19419. setMotor(force?: number, maxForce?: number): void;
  19420. /**
  19421. * Set the motor's limits.
  19422. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19423. * @param upperLimit The upper limit of the motor
  19424. * @param lowerLimit The lower limit of the motor
  19425. */
  19426. setLimit(upperLimit: number, lowerLimit?: number): void;
  19427. }
  19428. /**
  19429. * This class represents a dual hinge physics joint (same as wheel joint)
  19430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19431. */
  19432. export class Hinge2Joint extends MotorEnabledJoint {
  19433. /**
  19434. * Initializes the Hinge2-Joint
  19435. * @param jointData The joint data for the Hinge2-Joint
  19436. */
  19437. constructor(jointData: PhysicsJointData);
  19438. /**
  19439. * Set the motor values.
  19440. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19441. * @param {number} targetSpeed the speed the motor is to reach
  19442. * @param {number} maxForce max force for this motor.
  19443. * @param {motorIndex} the motor's index, 0 or 1.
  19444. */
  19445. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19446. /**
  19447. * Set the motor limits.
  19448. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19449. * @param {number} upperLimit the upper limit
  19450. * @param {number} lowerLimit lower limit
  19451. * @param {motorIndex} the motor's index, 0 or 1.
  19452. */
  19453. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19454. }
  19455. /**
  19456. * Interface for a motor enabled joint
  19457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19458. */
  19459. export interface IMotorEnabledJoint {
  19460. /**
  19461. * Physics joint
  19462. */
  19463. physicsJoint: any;
  19464. /**
  19465. * Sets the motor of the motor-enabled joint
  19466. * @param force The force of the motor
  19467. * @param maxForce The maximum force of the motor
  19468. * @param motorIndex The index of the motor
  19469. */
  19470. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19471. /**
  19472. * Sets the limit of the motor
  19473. * @param upperLimit The upper limit of the motor
  19474. * @param lowerLimit The lower limit of the motor
  19475. * @param motorIndex The index of the motor
  19476. */
  19477. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19478. }
  19479. /**
  19480. * Joint data for a Distance-Joint
  19481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19482. */
  19483. export interface DistanceJointData extends PhysicsJointData {
  19484. /**
  19485. * Max distance the 2 joint objects can be apart
  19486. */
  19487. maxDistance: number;
  19488. }
  19489. /**
  19490. * Joint data from a spring joint
  19491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19492. */
  19493. export interface SpringJointData extends PhysicsJointData {
  19494. /**
  19495. * Length of the spring
  19496. */
  19497. length: number;
  19498. /**
  19499. * Stiffness of the spring
  19500. */
  19501. stiffness: number;
  19502. /**
  19503. * Damping of the spring
  19504. */
  19505. damping: number;
  19506. /** this callback will be called when applying the force to the impostors. */
  19507. forceApplicationCallback: () => void;
  19508. }
  19509. }
  19510. declare module BABYLON {
  19511. /**
  19512. * Holds the data for the raycast result
  19513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19514. */
  19515. export class PhysicsRaycastResult {
  19516. private _hasHit;
  19517. private _hitDistance;
  19518. private _hitNormalWorld;
  19519. private _hitPointWorld;
  19520. private _rayFromWorld;
  19521. private _rayToWorld;
  19522. /**
  19523. * Gets if there was a hit
  19524. */
  19525. readonly hasHit: boolean;
  19526. /**
  19527. * Gets the distance from the hit
  19528. */
  19529. readonly hitDistance: number;
  19530. /**
  19531. * Gets the hit normal/direction in the world
  19532. */
  19533. readonly hitNormalWorld: Vector3;
  19534. /**
  19535. * Gets the hit point in the world
  19536. */
  19537. readonly hitPointWorld: Vector3;
  19538. /**
  19539. * Gets the ray "start point" of the ray in the world
  19540. */
  19541. readonly rayFromWorld: Vector3;
  19542. /**
  19543. * Gets the ray "end point" of the ray in the world
  19544. */
  19545. readonly rayToWorld: Vector3;
  19546. /**
  19547. * Sets the hit data (normal & point in world space)
  19548. * @param hitNormalWorld defines the normal in world space
  19549. * @param hitPointWorld defines the point in world space
  19550. */
  19551. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19552. /**
  19553. * Sets the distance from the start point to the hit point
  19554. * @param distance
  19555. */
  19556. setHitDistance(distance: number): void;
  19557. /**
  19558. * Calculates the distance manually
  19559. */
  19560. calculateHitDistance(): void;
  19561. /**
  19562. * Resets all the values to default
  19563. * @param from The from point on world space
  19564. * @param to The to point on world space
  19565. */
  19566. reset(from?: Vector3, to?: Vector3): void;
  19567. }
  19568. /**
  19569. * Interface for the size containing width and height
  19570. */
  19571. interface IXYZ {
  19572. /**
  19573. * X
  19574. */
  19575. x: number;
  19576. /**
  19577. * Y
  19578. */
  19579. y: number;
  19580. /**
  19581. * Z
  19582. */
  19583. z: number;
  19584. }
  19585. }
  19586. declare module BABYLON {
  19587. /**
  19588. * Interface used to describe a physics joint
  19589. */
  19590. export interface PhysicsImpostorJoint {
  19591. /** Defines the main impostor to which the joint is linked */
  19592. mainImpostor: PhysicsImpostor;
  19593. /** Defines the impostor that is connected to the main impostor using this joint */
  19594. connectedImpostor: PhysicsImpostor;
  19595. /** Defines the joint itself */
  19596. joint: PhysicsJoint;
  19597. }
  19598. /** @hidden */
  19599. export interface IPhysicsEnginePlugin {
  19600. world: any;
  19601. name: string;
  19602. setGravity(gravity: Vector3): void;
  19603. setTimeStep(timeStep: number): void;
  19604. getTimeStep(): number;
  19605. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19606. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19607. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19608. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19609. removePhysicsBody(impostor: PhysicsImpostor): void;
  19610. generateJoint(joint: PhysicsImpostorJoint): void;
  19611. removeJoint(joint: PhysicsImpostorJoint): void;
  19612. isSupported(): boolean;
  19613. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19614. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19615. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19616. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19617. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19618. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19619. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19620. getBodyMass(impostor: PhysicsImpostor): number;
  19621. getBodyFriction(impostor: PhysicsImpostor): number;
  19622. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19623. getBodyRestitution(impostor: PhysicsImpostor): number;
  19624. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19625. getBodyPressure?(impostor: PhysicsImpostor): number;
  19626. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19627. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19628. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19629. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19630. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19631. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19632. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19633. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19634. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19635. sleepBody(impostor: PhysicsImpostor): void;
  19636. wakeUpBody(impostor: PhysicsImpostor): void;
  19637. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19638. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19639. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19640. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19641. getRadius(impostor: PhysicsImpostor): number;
  19642. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19643. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19644. dispose(): void;
  19645. }
  19646. /**
  19647. * Interface used to define a physics engine
  19648. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19649. */
  19650. export interface IPhysicsEngine {
  19651. /**
  19652. * Gets the gravity vector used by the simulation
  19653. */
  19654. gravity: Vector3;
  19655. /**
  19656. * Sets the gravity vector used by the simulation
  19657. * @param gravity defines the gravity vector to use
  19658. */
  19659. setGravity(gravity: Vector3): void;
  19660. /**
  19661. * Set the time step of the physics engine.
  19662. * Default is 1/60.
  19663. * To slow it down, enter 1/600 for example.
  19664. * To speed it up, 1/30
  19665. * @param newTimeStep the new timestep to apply to this world.
  19666. */
  19667. setTimeStep(newTimeStep: number): void;
  19668. /**
  19669. * Get the time step of the physics engine.
  19670. * @returns the current time step
  19671. */
  19672. getTimeStep(): number;
  19673. /**
  19674. * Release all resources
  19675. */
  19676. dispose(): void;
  19677. /**
  19678. * Gets the name of the current physics plugin
  19679. * @returns the name of the plugin
  19680. */
  19681. getPhysicsPluginName(): string;
  19682. /**
  19683. * Adding a new impostor for the impostor tracking.
  19684. * This will be done by the impostor itself.
  19685. * @param impostor the impostor to add
  19686. */
  19687. addImpostor(impostor: PhysicsImpostor): void;
  19688. /**
  19689. * Remove an impostor from the engine.
  19690. * This impostor and its mesh will not longer be updated by the physics engine.
  19691. * @param impostor the impostor to remove
  19692. */
  19693. removeImpostor(impostor: PhysicsImpostor): void;
  19694. /**
  19695. * Add a joint to the physics engine
  19696. * @param mainImpostor defines the main impostor to which the joint is added.
  19697. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19698. * @param joint defines the joint that will connect both impostors.
  19699. */
  19700. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19701. /**
  19702. * Removes a joint from the simulation
  19703. * @param mainImpostor defines the impostor used with the joint
  19704. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19705. * @param joint defines the joint to remove
  19706. */
  19707. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19708. /**
  19709. * Gets the current plugin used to run the simulation
  19710. * @returns current plugin
  19711. */
  19712. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19713. /**
  19714. * Gets the list of physic impostors
  19715. * @returns an array of PhysicsImpostor
  19716. */
  19717. getImpostors(): Array<PhysicsImpostor>;
  19718. /**
  19719. * Gets the impostor for a physics enabled object
  19720. * @param object defines the object impersonated by the impostor
  19721. * @returns the PhysicsImpostor or null if not found
  19722. */
  19723. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19724. /**
  19725. * Gets the impostor for a physics body object
  19726. * @param body defines physics body used by the impostor
  19727. * @returns the PhysicsImpostor or null if not found
  19728. */
  19729. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19730. /**
  19731. * Does a raycast in the physics world
  19732. * @param from when should the ray start?
  19733. * @param to when should the ray end?
  19734. * @returns PhysicsRaycastResult
  19735. */
  19736. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19737. /**
  19738. * Called by the scene. No need to call it.
  19739. * @param delta defines the timespam between frames
  19740. */ step(delta: number): void;
  19741. }
  19742. }
  19743. declare module BABYLON {
  19744. /**
  19745. * The interface for the physics imposter parameters
  19746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19747. */
  19748. export interface PhysicsImpostorParameters {
  19749. /**
  19750. * The mass of the physics imposter
  19751. */
  19752. mass: number;
  19753. /**
  19754. * The friction of the physics imposter
  19755. */
  19756. friction?: number;
  19757. /**
  19758. * The coefficient of restitution of the physics imposter
  19759. */
  19760. restitution?: number;
  19761. /**
  19762. * The native options of the physics imposter
  19763. */
  19764. nativeOptions?: any;
  19765. /**
  19766. * Specifies if the parent should be ignored
  19767. */
  19768. ignoreParent?: boolean;
  19769. /**
  19770. * Specifies if bi-directional transformations should be disabled
  19771. */
  19772. disableBidirectionalTransformation?: boolean;
  19773. /**
  19774. * The pressure inside the physics imposter, soft object only
  19775. */
  19776. pressure?: number;
  19777. /**
  19778. * The stiffness the physics imposter, soft object only
  19779. */
  19780. stiffness?: number;
  19781. /**
  19782. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19783. */
  19784. velocityIterations?: number;
  19785. /**
  19786. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19787. */
  19788. positionIterations?: number;
  19789. /**
  19790. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19791. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19792. * Add to fix multiple points
  19793. */
  19794. fixedPoints?: number;
  19795. /**
  19796. * The collision margin around a soft object
  19797. */
  19798. margin?: number;
  19799. /**
  19800. * The collision margin around a soft object
  19801. */
  19802. damping?: number;
  19803. /**
  19804. * The path for a rope based on an extrusion
  19805. */
  19806. path?: any;
  19807. /**
  19808. * The shape of an extrusion used for a rope based on an extrusion
  19809. */
  19810. shape?: any;
  19811. }
  19812. /**
  19813. * Interface for a physics-enabled object
  19814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19815. */
  19816. export interface IPhysicsEnabledObject {
  19817. /**
  19818. * The position of the physics-enabled object
  19819. */
  19820. position: Vector3;
  19821. /**
  19822. * The rotation of the physics-enabled object
  19823. */
  19824. rotationQuaternion: Nullable<Quaternion>;
  19825. /**
  19826. * The scale of the physics-enabled object
  19827. */
  19828. scaling: Vector3;
  19829. /**
  19830. * The rotation of the physics-enabled object
  19831. */
  19832. rotation?: Vector3;
  19833. /**
  19834. * The parent of the physics-enabled object
  19835. */
  19836. parent?: any;
  19837. /**
  19838. * The bounding info of the physics-enabled object
  19839. * @returns The bounding info of the physics-enabled object
  19840. */
  19841. getBoundingInfo(): BoundingInfo;
  19842. /**
  19843. * Computes the world matrix
  19844. * @param force Specifies if the world matrix should be computed by force
  19845. * @returns A world matrix
  19846. */
  19847. computeWorldMatrix(force: boolean): Matrix;
  19848. /**
  19849. * Gets the world matrix
  19850. * @returns A world matrix
  19851. */
  19852. getWorldMatrix?(): Matrix;
  19853. /**
  19854. * Gets the child meshes
  19855. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19856. * @returns An array of abstract meshes
  19857. */
  19858. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19859. /**
  19860. * Gets the vertex data
  19861. * @param kind The type of vertex data
  19862. * @returns A nullable array of numbers, or a float32 array
  19863. */
  19864. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19865. /**
  19866. * Gets the indices from the mesh
  19867. * @returns A nullable array of index arrays
  19868. */
  19869. getIndices?(): Nullable<IndicesArray>;
  19870. /**
  19871. * Gets the scene from the mesh
  19872. * @returns the indices array or null
  19873. */
  19874. getScene?(): Scene;
  19875. /**
  19876. * Gets the absolute position from the mesh
  19877. * @returns the absolute position
  19878. */
  19879. getAbsolutePosition(): Vector3;
  19880. /**
  19881. * Gets the absolute pivot point from the mesh
  19882. * @returns the absolute pivot point
  19883. */
  19884. getAbsolutePivotPoint(): Vector3;
  19885. /**
  19886. * Rotates the mesh
  19887. * @param axis The axis of rotation
  19888. * @param amount The amount of rotation
  19889. * @param space The space of the rotation
  19890. * @returns The rotation transform node
  19891. */
  19892. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19893. /**
  19894. * Translates the mesh
  19895. * @param axis The axis of translation
  19896. * @param distance The distance of translation
  19897. * @param space The space of the translation
  19898. * @returns The transform node
  19899. */
  19900. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19901. /**
  19902. * Sets the absolute position of the mesh
  19903. * @param absolutePosition The absolute position of the mesh
  19904. * @returns The transform node
  19905. */
  19906. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19907. /**
  19908. * Gets the class name of the mesh
  19909. * @returns The class name
  19910. */
  19911. getClassName(): string;
  19912. }
  19913. /**
  19914. * Represents a physics imposter
  19915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19916. */
  19917. export class PhysicsImpostor {
  19918. /**
  19919. * The physics-enabled object used as the physics imposter
  19920. */
  19921. object: IPhysicsEnabledObject;
  19922. /**
  19923. * The type of the physics imposter
  19924. */
  19925. type: number;
  19926. private _options;
  19927. private _scene?;
  19928. /**
  19929. * The default object size of the imposter
  19930. */
  19931. static DEFAULT_OBJECT_SIZE: Vector3;
  19932. /**
  19933. * The identity quaternion of the imposter
  19934. */
  19935. static IDENTITY_QUATERNION: Quaternion;
  19936. /** @hidden */ pluginData: any;
  19937. private _physicsEngine;
  19938. private _physicsBody;
  19939. private _bodyUpdateRequired;
  19940. private _onBeforePhysicsStepCallbacks;
  19941. private _onAfterPhysicsStepCallbacks;
  19942. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  19943. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19944. otherImpostors: Array<PhysicsImpostor>;
  19945. }>;
  19946. private _deltaPosition;
  19947. private _deltaRotation;
  19948. private _deltaRotationConjugated;
  19949. /** hidden */ isFromLine: boolean;
  19950. private _parent;
  19951. private _isDisposed;
  19952. private static _tmpVecs;
  19953. private static _tmpQuat;
  19954. /**
  19955. * Specifies if the physics imposter is disposed
  19956. */
  19957. readonly isDisposed: boolean;
  19958. /**
  19959. * Gets the mass of the physics imposter
  19960. */
  19961. mass: number;
  19962. /**
  19963. * Gets the coefficient of friction
  19964. */
  19965. /**
  19966. * Sets the coefficient of friction
  19967. */
  19968. friction: number;
  19969. /**
  19970. * Gets the coefficient of restitution
  19971. */
  19972. /**
  19973. * Sets the coefficient of restitution
  19974. */
  19975. restitution: number;
  19976. /**
  19977. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  19978. */
  19979. /**
  19980. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  19981. */
  19982. pressure: number;
  19983. /**
  19984. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  19985. */
  19986. /**
  19987. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  19988. */
  19989. stiffness: number;
  19990. /**
  19991. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  19992. */
  19993. /**
  19994. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  19995. */
  19996. velocityIterations: number;
  19997. /**
  19998. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  19999. */
  20000. /**
  20001. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20002. */
  20003. positionIterations: number;
  20004. /**
  20005. * The unique id of the physics imposter
  20006. * set by the physics engine when adding this impostor to the array
  20007. */
  20008. uniqueId: number;
  20009. /**
  20010. * @hidden
  20011. */
  20012. soft: boolean;
  20013. /**
  20014. * @hidden
  20015. */
  20016. segments: number;
  20017. private _joints;
  20018. /**
  20019. * Initializes the physics imposter
  20020. * @param object The physics-enabled object used as the physics imposter
  20021. * @param type The type of the physics imposter
  20022. * @param _options The options for the physics imposter
  20023. * @param _scene The Babylon scene
  20024. */
  20025. constructor(
  20026. /**
  20027. * The physics-enabled object used as the physics imposter
  20028. */
  20029. object: IPhysicsEnabledObject,
  20030. /**
  20031. * The type of the physics imposter
  20032. */
  20033. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20034. /**
  20035. * This function will completly initialize this impostor.
  20036. * It will create a new body - but only if this mesh has no parent.
  20037. * If it has, this impostor will not be used other than to define the impostor
  20038. * of the child mesh.
  20039. * @hidden
  20040. */ init(): void;
  20041. private _getPhysicsParent;
  20042. /**
  20043. * Should a new body be generated.
  20044. * @returns boolean specifying if body initialization is required
  20045. */
  20046. isBodyInitRequired(): boolean;
  20047. /**
  20048. * Sets the updated scaling
  20049. * @param updated Specifies if the scaling is updated
  20050. */
  20051. setScalingUpdated(): void;
  20052. /**
  20053. * Force a regeneration of this or the parent's impostor's body.
  20054. * Use under cautious - This will remove all joints already implemented.
  20055. */
  20056. forceUpdate(): void;
  20057. /**
  20058. * Gets the body that holds this impostor. Either its own, or its parent.
  20059. */
  20060. /**
  20061. * Set the physics body. Used mainly by the physics engine/plugin
  20062. */
  20063. physicsBody: any;
  20064. /**
  20065. * Get the parent of the physics imposter
  20066. * @returns Physics imposter or null
  20067. */
  20068. /**
  20069. * Sets the parent of the physics imposter
  20070. */
  20071. parent: Nullable<PhysicsImpostor>;
  20072. /**
  20073. * Resets the update flags
  20074. */
  20075. resetUpdateFlags(): void;
  20076. /**
  20077. * Gets the object extend size
  20078. * @returns the object extend size
  20079. */
  20080. getObjectExtendSize(): Vector3;
  20081. /**
  20082. * Gets the object center
  20083. * @returns The object center
  20084. */
  20085. getObjectCenter(): Vector3;
  20086. /**
  20087. * Get a specific parametes from the options parameter
  20088. * @param paramName The object parameter name
  20089. * @returns The object parameter
  20090. */
  20091. getParam(paramName: string): any;
  20092. /**
  20093. * Sets a specific parameter in the options given to the physics plugin
  20094. * @param paramName The parameter name
  20095. * @param value The value of the parameter
  20096. */
  20097. setParam(paramName: string, value: number): void;
  20098. /**
  20099. * Specifically change the body's mass option. Won't recreate the physics body object
  20100. * @param mass The mass of the physics imposter
  20101. */
  20102. setMass(mass: number): void;
  20103. /**
  20104. * Gets the linear velocity
  20105. * @returns linear velocity or null
  20106. */
  20107. getLinearVelocity(): Nullable<Vector3>;
  20108. /**
  20109. * Sets the linear velocity
  20110. * @param velocity linear velocity or null
  20111. */
  20112. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20113. /**
  20114. * Gets the angular velocity
  20115. * @returns angular velocity or null
  20116. */
  20117. getAngularVelocity(): Nullable<Vector3>;
  20118. /**
  20119. * Sets the angular velocity
  20120. * @param velocity The velocity or null
  20121. */
  20122. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20123. /**
  20124. * Execute a function with the physics plugin native code
  20125. * Provide a function the will have two variables - the world object and the physics body object
  20126. * @param func The function to execute with the physics plugin native code
  20127. */
  20128. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20129. /**
  20130. * Register a function that will be executed before the physics world is stepping forward
  20131. * @param func The function to execute before the physics world is stepped forward
  20132. */
  20133. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20134. /**
  20135. * Unregister a function that will be executed before the physics world is stepping forward
  20136. * @param func The function to execute before the physics world is stepped forward
  20137. */
  20138. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20139. /**
  20140. * Register a function that will be executed after the physics step
  20141. * @param func The function to execute after physics step
  20142. */
  20143. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20144. /**
  20145. * Unregisters a function that will be executed after the physics step
  20146. * @param func The function to execute after physics step
  20147. */
  20148. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20149. /**
  20150. * register a function that will be executed when this impostor collides against a different body
  20151. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20152. * @param func Callback that is executed on collision
  20153. */
  20154. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20155. /**
  20156. * Unregisters the physics imposter on contact
  20157. * @param collideAgainst The physics object to collide against
  20158. * @param func Callback to execute on collision
  20159. */
  20160. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20161. private _tmpQuat;
  20162. private _tmpQuat2;
  20163. /**
  20164. * Get the parent rotation
  20165. * @returns The parent rotation
  20166. */
  20167. getParentsRotation(): Quaternion;
  20168. /**
  20169. * this function is executed by the physics engine.
  20170. */
  20171. beforeStep: () => void;
  20172. /**
  20173. * this function is executed by the physics engine
  20174. */
  20175. afterStep: () => void;
  20176. /**
  20177. * Legacy collision detection event support
  20178. */
  20179. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20180. /**
  20181. * event and body object due to cannon's event-based architecture.
  20182. */
  20183. onCollide: (e: {
  20184. body: any;
  20185. }) => void;
  20186. /**
  20187. * Apply a force
  20188. * @param force The force to apply
  20189. * @param contactPoint The contact point for the force
  20190. * @returns The physics imposter
  20191. */
  20192. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20193. /**
  20194. * Apply an impulse
  20195. * @param force The impulse force
  20196. * @param contactPoint The contact point for the impulse force
  20197. * @returns The physics imposter
  20198. */
  20199. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20200. /**
  20201. * A help function to create a joint
  20202. * @param otherImpostor A physics imposter used to create a joint
  20203. * @param jointType The type of joint
  20204. * @param jointData The data for the joint
  20205. * @returns The physics imposter
  20206. */
  20207. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20208. /**
  20209. * Add a joint to this impostor with a different impostor
  20210. * @param otherImpostor A physics imposter used to add a joint
  20211. * @param joint The joint to add
  20212. * @returns The physics imposter
  20213. */
  20214. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20215. /**
  20216. * Add an anchor to a cloth impostor
  20217. * @param otherImpostor rigid impostor to anchor to
  20218. * @param width ratio across width from 0 to 1
  20219. * @param height ratio up height from 0 to 1
  20220. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20221. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20222. * @returns impostor the soft imposter
  20223. */
  20224. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20225. /**
  20226. * Add a hook to a rope impostor
  20227. * @param otherImpostor rigid impostor to anchor to
  20228. * @param length ratio across rope from 0 to 1
  20229. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20230. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20231. * @returns impostor the rope imposter
  20232. */
  20233. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20234. /**
  20235. * Will keep this body still, in a sleep mode.
  20236. * @returns the physics imposter
  20237. */
  20238. sleep(): PhysicsImpostor;
  20239. /**
  20240. * Wake the body up.
  20241. * @returns The physics imposter
  20242. */
  20243. wakeUp(): PhysicsImpostor;
  20244. /**
  20245. * Clones the physics imposter
  20246. * @param newObject The physics imposter clones to this physics-enabled object
  20247. * @returns A nullable physics imposter
  20248. */
  20249. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20250. /**
  20251. * Disposes the physics imposter
  20252. */
  20253. dispose(): void;
  20254. /**
  20255. * Sets the delta position
  20256. * @param position The delta position amount
  20257. */
  20258. setDeltaPosition(position: Vector3): void;
  20259. /**
  20260. * Sets the delta rotation
  20261. * @param rotation The delta rotation amount
  20262. */
  20263. setDeltaRotation(rotation: Quaternion): void;
  20264. /**
  20265. * Gets the box size of the physics imposter and stores the result in the input parameter
  20266. * @param result Stores the box size
  20267. * @returns The physics imposter
  20268. */
  20269. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20270. /**
  20271. * Gets the radius of the physics imposter
  20272. * @returns Radius of the physics imposter
  20273. */
  20274. getRadius(): number;
  20275. /**
  20276. * Sync a bone with this impostor
  20277. * @param bone The bone to sync to the impostor.
  20278. * @param boneMesh The mesh that the bone is influencing.
  20279. * @param jointPivot The pivot of the joint / bone in local space.
  20280. * @param distToJoint Optional distance from the impostor to the joint.
  20281. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20282. */
  20283. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20284. /**
  20285. * Sync impostor to a bone
  20286. * @param bone The bone that the impostor will be synced to.
  20287. * @param boneMesh The mesh that the bone is influencing.
  20288. * @param jointPivot The pivot of the joint / bone in local space.
  20289. * @param distToJoint Optional distance from the impostor to the joint.
  20290. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20291. * @param boneAxis Optional vector3 axis the bone is aligned with
  20292. */
  20293. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20294. /**
  20295. * No-Imposter type
  20296. */
  20297. static NoImpostor: number;
  20298. /**
  20299. * Sphere-Imposter type
  20300. */
  20301. static SphereImpostor: number;
  20302. /**
  20303. * Box-Imposter type
  20304. */
  20305. static BoxImpostor: number;
  20306. /**
  20307. * Plane-Imposter type
  20308. */
  20309. static PlaneImpostor: number;
  20310. /**
  20311. * Mesh-imposter type
  20312. */
  20313. static MeshImpostor: number;
  20314. /**
  20315. * Cylinder-Imposter type
  20316. */
  20317. static CylinderImpostor: number;
  20318. /**
  20319. * Particle-Imposter type
  20320. */
  20321. static ParticleImpostor: number;
  20322. /**
  20323. * Heightmap-Imposter type
  20324. */
  20325. static HeightmapImpostor: number;
  20326. /**
  20327. * ConvexHull-Impostor type (Ammo.js plugin only)
  20328. */
  20329. static ConvexHullImpostor: number;
  20330. /**
  20331. * Rope-Imposter type
  20332. */
  20333. static RopeImpostor: number;
  20334. /**
  20335. * Cloth-Imposter type
  20336. */
  20337. static ClothImpostor: number;
  20338. /**
  20339. * Softbody-Imposter type
  20340. */
  20341. static SoftbodyImpostor: number;
  20342. }
  20343. }
  20344. declare module BABYLON {
  20345. /**
  20346. * Class used to represent a specific level of detail of a mesh
  20347. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20348. */
  20349. export class MeshLODLevel {
  20350. /** Defines the distance where this level should star being displayed */
  20351. distance: number;
  20352. /** Defines the mesh to use to render this level */
  20353. mesh: Nullable<Mesh>;
  20354. /**
  20355. * Creates a new LOD level
  20356. * @param distance defines the distance where this level should star being displayed
  20357. * @param mesh defines the mesh to use to render this level
  20358. */
  20359. constructor(
  20360. /** Defines the distance where this level should star being displayed */
  20361. distance: number,
  20362. /** Defines the mesh to use to render this level */
  20363. mesh: Nullable<Mesh>);
  20364. }
  20365. /**
  20366. * @hidden
  20367. **/
  20368. export class _CreationDataStorage {
  20369. closePath?: boolean;
  20370. closeArray?: boolean;
  20371. idx: number[];
  20372. dashSize: number;
  20373. gapSize: number;
  20374. path3D: Path3D;
  20375. pathArray: Vector3[][];
  20376. arc: number;
  20377. radius: number;
  20378. cap: number;
  20379. tessellation: number;
  20380. }
  20381. /**
  20382. * @hidden
  20383. **/ private class _InstanceDataStorage {
  20384. visibleInstances: any;
  20385. batchCache: _InstancesBatch;
  20386. instancesBufferSize: number;
  20387. instancesBuffer: Nullable<Buffer>;
  20388. instancesData: Float32Array;
  20389. overridenInstanceCount: number;
  20390. isFrozen: boolean;
  20391. previousBatch: _InstancesBatch;
  20392. hardwareInstancedRendering: boolean;
  20393. sideOrientation: number;
  20394. }
  20395. /**
  20396. * @hidden
  20397. **/
  20398. export class _InstancesBatch {
  20399. mustReturn: boolean;
  20400. visibleInstances: Nullable<InstancedMesh[]>[];
  20401. renderSelf: boolean[];
  20402. hardwareInstancedRendering: boolean[];
  20403. }
  20404. /**
  20405. * Class used to represent renderable models
  20406. */
  20407. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20408. /**
  20409. * Mesh side orientation : usually the external or front surface
  20410. */
  20411. static readonly FRONTSIDE: number;
  20412. /**
  20413. * Mesh side orientation : usually the internal or back surface
  20414. */
  20415. static readonly BACKSIDE: number;
  20416. /**
  20417. * Mesh side orientation : both internal and external or front and back surfaces
  20418. */
  20419. static readonly DOUBLESIDE: number;
  20420. /**
  20421. * Mesh side orientation : by default, `FRONTSIDE`
  20422. */
  20423. static readonly DEFAULTSIDE: number;
  20424. /**
  20425. * Mesh cap setting : no cap
  20426. */
  20427. static readonly NO_CAP: number;
  20428. /**
  20429. * Mesh cap setting : one cap at the beginning of the mesh
  20430. */
  20431. static readonly CAP_START: number;
  20432. /**
  20433. * Mesh cap setting : one cap at the end of the mesh
  20434. */
  20435. static readonly CAP_END: number;
  20436. /**
  20437. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20438. */
  20439. static readonly CAP_ALL: number;
  20440. /**
  20441. * Gets the default side orientation.
  20442. * @param orientation the orientation to value to attempt to get
  20443. * @returns the default orientation
  20444. * @hidden
  20445. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  20446. private _onBeforeRenderObservable;
  20447. private _onBeforeBindObservable;
  20448. private _onAfterRenderObservable;
  20449. private _onBeforeDrawObservable;
  20450. /**
  20451. * An event triggered before rendering the mesh
  20452. */
  20453. readonly onBeforeRenderObservable: Observable<Mesh>;
  20454. /**
  20455. * An event triggered before binding the mesh
  20456. */
  20457. readonly onBeforeBindObservable: Observable<Mesh>;
  20458. /**
  20459. * An event triggered after rendering the mesh
  20460. */
  20461. readonly onAfterRenderObservable: Observable<Mesh>;
  20462. /**
  20463. * An event triggered before drawing the mesh
  20464. */
  20465. readonly onBeforeDrawObservable: Observable<Mesh>;
  20466. private _onBeforeDrawObserver;
  20467. /**
  20468. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20469. */
  20470. onBeforeDraw: () => void;
  20471. /**
  20472. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20473. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20474. */
  20475. delayLoadState: number;
  20476. /**
  20477. * Gets the list of instances created from this mesh
  20478. * it is not supposed to be modified manually.
  20479. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20480. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20481. */
  20482. instances: InstancedMesh[];
  20483. /**
  20484. * Gets the file containing delay loading data for this mesh
  20485. */
  20486. delayLoadingFile: string;
  20487. /** @hidden */ binaryInfo: any;
  20488. private _LODLevels;
  20489. /**
  20490. * User defined function used to change how LOD level selection is done
  20491. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20492. */
  20493. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20494. private _morphTargetManager;
  20495. /**
  20496. * Gets or sets the morph target manager
  20497. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20498. */
  20499. morphTargetManager: Nullable<MorphTargetManager>;
  20500. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  20501. /** @hidden */ geometry: Nullable<Geometry>;
  20502. /** @hidden */ delayInfo: Array<string>;
  20503. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20504. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  20505. private _effectiveMaterial;
  20506. /** @hidden */ shouldGenerateFlatShading: boolean;
  20507. private _preActivateId;
  20508. /** @hidden */ originalBuilderSideOrientation: number;
  20509. /**
  20510. * Use this property to change the original side orientation defined at construction time
  20511. */
  20512. overrideMaterialSideOrientation: Nullable<number>;
  20513. private _areNormalsFrozen;
  20514. private _sourcePositions;
  20515. private _sourceNormals;
  20516. private _source;
  20517. private meshMap;
  20518. /**
  20519. * Gets the source mesh (the one used to clone this one from)
  20520. */
  20521. readonly source: Nullable<Mesh>;
  20522. /**
  20523. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20524. */
  20525. isUnIndexed: boolean;
  20526. /**
  20527. * @constructor
  20528. * @param name The value used by scene.getMeshByName() to do a lookup.
  20529. * @param scene The scene to add this mesh to.
  20530. * @param parent The parent of this mesh, if it has one
  20531. * @param source An optional Mesh from which geometry is shared, cloned.
  20532. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20533. * When false, achieved by calling a clone(), also passing False.
  20534. * This will make creation of children, recursive.
  20535. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20536. */
  20537. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20538. /**
  20539. * Gets the class name
  20540. * @returns the string "Mesh".
  20541. */
  20542. getClassName(): string;
  20543. /** @hidden */ protected readonly _isMesh: boolean;
  20544. /**
  20545. * Returns a description of this mesh
  20546. * @param fullDetails define if full details about this mesh must be used
  20547. * @returns a descriptive string representing this mesh
  20548. */
  20549. toString(fullDetails?: boolean): string;
  20550. /** @hidden */ unBindEffect(): void;
  20551. /**
  20552. * Gets a boolean indicating if this mesh has LOD
  20553. */
  20554. readonly hasLODLevels: boolean;
  20555. /**
  20556. * Gets the list of MeshLODLevel associated with the current mesh
  20557. * @returns an array of MeshLODLevel
  20558. */
  20559. getLODLevels(): MeshLODLevel[];
  20560. private _sortLODLevels;
  20561. /**
  20562. * Add a mesh as LOD level triggered at the given distance.
  20563. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20564. * @param distance The distance from the center of the object to show this level
  20565. * @param mesh The mesh to be added as LOD level (can be null)
  20566. * @return This mesh (for chaining)
  20567. */
  20568. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20569. /**
  20570. * Returns the LOD level mesh at the passed distance or null if not found.
  20571. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20572. * @param distance The distance from the center of the object to show this level
  20573. * @returns a Mesh or `null`
  20574. */
  20575. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20576. /**
  20577. * Remove a mesh from the LOD array
  20578. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20579. * @param mesh defines the mesh to be removed
  20580. * @return This mesh (for chaining)
  20581. */
  20582. removeLODLevel(mesh: Mesh): Mesh;
  20583. /**
  20584. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20585. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20586. * @param camera defines the camera to use to compute distance
  20587. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20588. * @return This mesh (for chaining)
  20589. */
  20590. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20591. /**
  20592. * Gets the mesh internal Geometry object
  20593. */
  20594. readonly geometry: Nullable<Geometry>;
  20595. /**
  20596. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20597. * @returns the total number of vertices
  20598. */
  20599. getTotalVertices(): number;
  20600. /**
  20601. * Returns the content of an associated vertex buffer
  20602. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20603. * - VertexBuffer.PositionKind
  20604. * - VertexBuffer.UVKind
  20605. * - VertexBuffer.UV2Kind
  20606. * - VertexBuffer.UV3Kind
  20607. * - VertexBuffer.UV4Kind
  20608. * - VertexBuffer.UV5Kind
  20609. * - VertexBuffer.UV6Kind
  20610. * - VertexBuffer.ColorKind
  20611. * - VertexBuffer.MatricesIndicesKind
  20612. * - VertexBuffer.MatricesIndicesExtraKind
  20613. * - VertexBuffer.MatricesWeightsKind
  20614. * - VertexBuffer.MatricesWeightsExtraKind
  20615. * @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
  20616. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20617. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20618. */
  20619. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20620. /**
  20621. * Returns the mesh VertexBuffer object from the requested `kind`
  20622. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20623. * - VertexBuffer.PositionKind
  20624. * - VertexBuffer.UVKind
  20625. * - VertexBuffer.UV2Kind
  20626. * - VertexBuffer.UV3Kind
  20627. * - VertexBuffer.UV4Kind
  20628. * - VertexBuffer.UV5Kind
  20629. * - VertexBuffer.UV6Kind
  20630. * - VertexBuffer.ColorKind
  20631. * - VertexBuffer.MatricesIndicesKind
  20632. * - VertexBuffer.MatricesIndicesExtraKind
  20633. * - VertexBuffer.MatricesWeightsKind
  20634. * - VertexBuffer.MatricesWeightsExtraKind
  20635. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20636. */
  20637. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20638. /**
  20639. * Tests if a specific vertex buffer is associated with this mesh
  20640. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20641. * - VertexBuffer.PositionKind
  20642. * - VertexBuffer.UVKind
  20643. * - VertexBuffer.UV2Kind
  20644. * - VertexBuffer.UV3Kind
  20645. * - VertexBuffer.UV4Kind
  20646. * - VertexBuffer.UV5Kind
  20647. * - VertexBuffer.UV6Kind
  20648. * - VertexBuffer.ColorKind
  20649. * - VertexBuffer.MatricesIndicesKind
  20650. * - VertexBuffer.MatricesIndicesExtraKind
  20651. * - VertexBuffer.MatricesWeightsKind
  20652. * - VertexBuffer.MatricesWeightsExtraKind
  20653. * @returns a boolean
  20654. */
  20655. isVerticesDataPresent(kind: string): boolean;
  20656. /**
  20657. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20658. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20659. * - VertexBuffer.PositionKind
  20660. * - VertexBuffer.UVKind
  20661. * - VertexBuffer.UV2Kind
  20662. * - VertexBuffer.UV3Kind
  20663. * - VertexBuffer.UV4Kind
  20664. * - VertexBuffer.UV5Kind
  20665. * - VertexBuffer.UV6Kind
  20666. * - VertexBuffer.ColorKind
  20667. * - VertexBuffer.MatricesIndicesKind
  20668. * - VertexBuffer.MatricesIndicesExtraKind
  20669. * - VertexBuffer.MatricesWeightsKind
  20670. * - VertexBuffer.MatricesWeightsExtraKind
  20671. * @returns a boolean
  20672. */
  20673. isVertexBufferUpdatable(kind: string): boolean;
  20674. /**
  20675. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20676. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20677. * - VertexBuffer.PositionKind
  20678. * - VertexBuffer.UVKind
  20679. * - VertexBuffer.UV2Kind
  20680. * - VertexBuffer.UV3Kind
  20681. * - VertexBuffer.UV4Kind
  20682. * - VertexBuffer.UV5Kind
  20683. * - VertexBuffer.UV6Kind
  20684. * - VertexBuffer.ColorKind
  20685. * - VertexBuffer.MatricesIndicesKind
  20686. * - VertexBuffer.MatricesIndicesExtraKind
  20687. * - VertexBuffer.MatricesWeightsKind
  20688. * - VertexBuffer.MatricesWeightsExtraKind
  20689. * @returns an array of strings
  20690. */
  20691. getVerticesDataKinds(): string[];
  20692. /**
  20693. * Returns a positive integer : the total number of indices in this mesh geometry.
  20694. * @returns the numner of indices or zero if the mesh has no geometry.
  20695. */
  20696. getTotalIndices(): number;
  20697. /**
  20698. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20699. * @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.
  20700. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20701. * @returns the indices array or an empty array if the mesh has no geometry
  20702. */
  20703. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20704. readonly isBlocked: boolean;
  20705. /**
  20706. * Determine if the current mesh is ready to be rendered
  20707. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20708. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20709. * @returns true if all associated assets are ready (material, textures, shaders)
  20710. */
  20711. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20712. /**
  20713. * 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.
  20714. */
  20715. readonly areNormalsFrozen: boolean;
  20716. /**
  20717. * 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.
  20718. * @returns the current mesh
  20719. */
  20720. freezeNormals(): Mesh;
  20721. /**
  20722. * 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
  20723. * @returns the current mesh
  20724. */
  20725. unfreezeNormals(): Mesh;
  20726. /**
  20727. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20728. */
  20729. overridenInstanceCount: number;
  20730. /** @hidden */ preActivate(): Mesh;
  20731. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  20732. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20733. /**
  20734. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20735. * This means the mesh underlying bounding box and sphere are recomputed.
  20736. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20737. * @returns the current mesh
  20738. */
  20739. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20740. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20741. /**
  20742. * This function will subdivide the mesh into multiple submeshes
  20743. * @param count defines the expected number of submeshes
  20744. */
  20745. subdivide(count: number): void;
  20746. /**
  20747. * Copy a FloatArray into a specific associated vertex buffer
  20748. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20749. * - VertexBuffer.PositionKind
  20750. * - VertexBuffer.UVKind
  20751. * - VertexBuffer.UV2Kind
  20752. * - VertexBuffer.UV3Kind
  20753. * - VertexBuffer.UV4Kind
  20754. * - VertexBuffer.UV5Kind
  20755. * - VertexBuffer.UV6Kind
  20756. * - VertexBuffer.ColorKind
  20757. * - VertexBuffer.MatricesIndicesKind
  20758. * - VertexBuffer.MatricesIndicesExtraKind
  20759. * - VertexBuffer.MatricesWeightsKind
  20760. * - VertexBuffer.MatricesWeightsExtraKind
  20761. * @param data defines the data source
  20762. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20763. * @param stride defines the data stride size (can be null)
  20764. * @returns the current mesh
  20765. */
  20766. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20767. /**
  20768. * Flags an associated vertex buffer as updatable
  20769. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20770. * - VertexBuffer.PositionKind
  20771. * - VertexBuffer.UVKind
  20772. * - VertexBuffer.UV2Kind
  20773. * - VertexBuffer.UV3Kind
  20774. * - VertexBuffer.UV4Kind
  20775. * - VertexBuffer.UV5Kind
  20776. * - VertexBuffer.UV6Kind
  20777. * - VertexBuffer.ColorKind
  20778. * - VertexBuffer.MatricesIndicesKind
  20779. * - VertexBuffer.MatricesIndicesExtraKind
  20780. * - VertexBuffer.MatricesWeightsKind
  20781. * - VertexBuffer.MatricesWeightsExtraKind
  20782. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20783. */
  20784. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20785. /**
  20786. * Sets the mesh global Vertex Buffer
  20787. * @param buffer defines the buffer to use
  20788. * @returns the current mesh
  20789. */
  20790. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20791. /**
  20792. * Update a specific associated vertex buffer
  20793. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20794. * - VertexBuffer.PositionKind
  20795. * - VertexBuffer.UVKind
  20796. * - VertexBuffer.UV2Kind
  20797. * - VertexBuffer.UV3Kind
  20798. * - VertexBuffer.UV4Kind
  20799. * - VertexBuffer.UV5Kind
  20800. * - VertexBuffer.UV6Kind
  20801. * - VertexBuffer.ColorKind
  20802. * - VertexBuffer.MatricesIndicesKind
  20803. * - VertexBuffer.MatricesIndicesExtraKind
  20804. * - VertexBuffer.MatricesWeightsKind
  20805. * - VertexBuffer.MatricesWeightsExtraKind
  20806. * @param data defines the data source
  20807. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20808. * @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)
  20809. * @returns the current mesh
  20810. */
  20811. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20812. /**
  20813. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20814. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20815. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20816. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20817. * @returns the current mesh
  20818. */
  20819. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20820. /**
  20821. * Creates a un-shared specific occurence of the geometry for the mesh.
  20822. * @returns the current mesh
  20823. */
  20824. makeGeometryUnique(): Mesh;
  20825. /**
  20826. * Set the index buffer of this mesh
  20827. * @param indices defines the source data
  20828. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20829. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20830. * @returns the current mesh
  20831. */
  20832. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20833. /**
  20834. * Update the current index buffer
  20835. * @param indices defines the source data
  20836. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20837. * @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)
  20838. * @returns the current mesh
  20839. */
  20840. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20841. /**
  20842. * Invert the geometry to move from a right handed system to a left handed one.
  20843. * @returns the current mesh
  20844. */
  20845. toLeftHanded(): Mesh;
  20846. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20847. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20848. /**
  20849. * Registers for this mesh a javascript function called just before the rendering process
  20850. * @param func defines the function to call before rendering this mesh
  20851. * @returns the current mesh
  20852. */
  20853. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20854. /**
  20855. * Disposes a previously registered javascript function called before the rendering
  20856. * @param func defines the function to remove
  20857. * @returns the current mesh
  20858. */
  20859. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20860. /**
  20861. * Registers for this mesh a javascript function called just after the rendering is complete
  20862. * @param func defines the function to call after rendering this mesh
  20863. * @returns the current mesh
  20864. */
  20865. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20866. /**
  20867. * Disposes a previously registered javascript function called after the rendering.
  20868. * @param func defines the function to remove
  20869. * @returns the current mesh
  20870. */
  20871. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20872. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20873. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20874. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20875. /** @hidden */ freeze(): void;
  20876. /** @hidden */ unFreeze(): void;
  20877. /**
  20878. * 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
  20879. * @param subMesh defines the subMesh to render
  20880. * @param enableAlphaMode defines if alpha mode can be changed
  20881. * @returns the current mesh
  20882. */
  20883. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20884. private _onBeforeDraw;
  20885. /**
  20886. * Renormalize the mesh and patch it up if there are no weights
  20887. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20888. * However in the case of zero weights then we set just a single influence to 1.
  20889. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20890. */
  20891. cleanMatrixWeights(): void;
  20892. private normalizeSkinFourWeights;
  20893. private normalizeSkinWeightsAndExtra;
  20894. /**
  20895. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20896. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20897. * the user know there was an issue with importing the mesh
  20898. * @returns a validation object with skinned, valid and report string
  20899. */
  20900. validateSkinning(): {
  20901. skinned: boolean;
  20902. valid: boolean;
  20903. report: string;
  20904. };
  20905. /** @hidden */ checkDelayState(): Mesh;
  20906. private _queueLoad;
  20907. /**
  20908. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20909. * A mesh is in the frustum if its bounding box intersects the frustum
  20910. * @param frustumPlanes defines the frustum to test
  20911. * @returns true if the mesh is in the frustum planes
  20912. */
  20913. isInFrustum(frustumPlanes: Plane[]): boolean;
  20914. /**
  20915. * Sets the mesh material by the material or multiMaterial `id` property
  20916. * @param id is a string identifying the material or the multiMaterial
  20917. * @returns the current mesh
  20918. */
  20919. setMaterialByID(id: string): Mesh;
  20920. /**
  20921. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20922. * @returns an array of IAnimatable
  20923. */
  20924. getAnimatables(): IAnimatable[];
  20925. /**
  20926. * Modifies the mesh geometry according to the passed transformation matrix.
  20927. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20928. * The mesh normals are modified using the same transformation.
  20929. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20930. * @param transform defines the transform matrix to use
  20931. * @see http://doc.babylonjs.com/resources/baking_transformations
  20932. * @returns the current mesh
  20933. */
  20934. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20935. /**
  20936. * Modifies the mesh geometry according to its own current World Matrix.
  20937. * The mesh World Matrix is then reset.
  20938. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20939. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20940. * @see http://doc.babylonjs.com/resources/baking_transformations
  20941. * @returns the current mesh
  20942. */
  20943. bakeCurrentTransformIntoVertices(): Mesh;
  20944. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  20945. /** @hidden */ resetPointsArrayCache(): Mesh;
  20946. /** @hidden */ generatePointsArray(): boolean;
  20947. /**
  20948. * Returns a new Mesh object generated from the current mesh properties.
  20949. * This method must not get confused with createInstance()
  20950. * @param name is a string, the name given to the new mesh
  20951. * @param newParent can be any Node object (default `null`)
  20952. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20953. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20954. * @returns a new mesh
  20955. */
  20956. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20957. /**
  20958. * Releases resources associated with this mesh.
  20959. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20960. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20961. */
  20962. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20963. /**
  20964. * Modifies the mesh geometry according to a displacement map.
  20965. * 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.
  20966. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20967. * @param url is a string, the URL from the image file is to be downloaded.
  20968. * @param minHeight is the lower limit of the displacement.
  20969. * @param maxHeight is the upper limit of the displacement.
  20970. * @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.
  20971. * @param uvOffset is an optional vector2 used to offset UV.
  20972. * @param uvScale is an optional vector2 used to scale UV.
  20973. * @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.
  20974. * @returns the Mesh.
  20975. */
  20976. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20977. /**
  20978. * Modifies the mesh geometry according to a displacementMap buffer.
  20979. * 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.
  20980. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20981. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20982. * @param heightMapWidth is the width of the buffer image.
  20983. * @param heightMapHeight is the height of the buffer image.
  20984. * @param minHeight is the lower limit of the displacement.
  20985. * @param maxHeight is the upper limit of the displacement.
  20986. * @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.
  20987. * @param uvOffset is an optional vector2 used to offset UV.
  20988. * @param uvScale is an optional vector2 used to scale UV.
  20989. * @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.
  20990. * @returns the Mesh.
  20991. */
  20992. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20993. /**
  20994. * Modify the mesh to get a flat shading rendering.
  20995. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20996. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20997. * @returns current mesh
  20998. */
  20999. convertToFlatShadedMesh(): Mesh;
  21000. /**
  21001. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21002. * In other words, more vertices, no more indices and a single bigger VBO.
  21003. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21004. * @returns current mesh
  21005. */
  21006. convertToUnIndexedMesh(): Mesh;
  21007. /**
  21008. * Inverses facet orientations.
  21009. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21010. * @param flipNormals will also inverts the normals
  21011. * @returns current mesh
  21012. */
  21013. flipFaces(flipNormals?: boolean): Mesh;
  21014. /**
  21015. * Increase the number of facets and hence vertices in a mesh
  21016. * Vertex normals are interpolated from existing vertex normals
  21017. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21018. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21019. */
  21020. increaseVertices(numberPerEdge: number): void;
  21021. /**
  21022. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21023. * This will undo any application of covertToFlatShadedMesh
  21024. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21025. */
  21026. forceSharedVertices(): void;
  21027. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21028. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21029. /**
  21030. * Creates a new InstancedMesh object from the mesh model.
  21031. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21032. * @param name defines the name of the new instance
  21033. * @returns a new InstancedMesh
  21034. */
  21035. createInstance(name: string): InstancedMesh;
  21036. /**
  21037. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21038. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21039. * @returns the current mesh
  21040. */
  21041. synchronizeInstances(): Mesh;
  21042. /**
  21043. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21044. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21045. * This should be used together with the simplification to avoid disappearing triangles.
  21046. * @param successCallback an optional success callback to be called after the optimization finished.
  21047. * @returns the current mesh
  21048. */
  21049. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21050. /**
  21051. * Serialize current mesh
  21052. * @param serializationObject defines the object which will receive the serialization data
  21053. */
  21054. serialize(serializationObject: any): void;
  21055. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  21056. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21057. /**
  21058. * Returns a new Mesh object parsed from the source provided.
  21059. * @param parsedMesh is the source
  21060. * @param scene defines the hosting scene
  21061. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21062. * @returns a new Mesh
  21063. */
  21064. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21065. /**
  21066. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21067. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21068. * @param name defines the name of the mesh to create
  21069. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21070. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21071. * @param closePath creates a seam between the first and the last points of each path of the path array
  21072. * @param offset is taken in account only if the `pathArray` is containing a single path
  21073. * @param scene defines the hosting scene
  21074. * @param updatable defines if the mesh must be flagged as updatable
  21075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21076. * @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)
  21077. * @returns a new Mesh
  21078. */
  21079. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21080. /**
  21081. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21082. * @param name defines the name of the mesh to create
  21083. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21084. * @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
  21085. * @param scene defines the hosting scene
  21086. * @param updatable defines if the mesh must be flagged as updatable
  21087. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21088. * @returns a new Mesh
  21089. */
  21090. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21091. /**
  21092. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21093. * @param name defines the name of the mesh to create
  21094. * @param size sets the size (float) of each box side (default 1)
  21095. * @param scene defines the hosting scene
  21096. * @param updatable defines if the mesh must be flagged as updatable
  21097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21098. * @returns a new Mesh
  21099. */
  21100. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21101. /**
  21102. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21103. * @param name defines the name of the mesh to create
  21104. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21105. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21106. * @param scene defines the hosting scene
  21107. * @param updatable defines if the mesh must be flagged as updatable
  21108. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21109. * @returns a new Mesh
  21110. */
  21111. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21112. /**
  21113. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21114. * @param name defines the name of the mesh to create
  21115. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21116. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21117. * @param scene defines the hosting scene
  21118. * @returns a new Mesh
  21119. */
  21120. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21121. /**
  21122. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21123. * @param name defines the name of the mesh to create
  21124. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21125. * @param diameterTop set the top cap diameter (floats, default 1)
  21126. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21127. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21128. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21129. * @param scene defines the hosting scene
  21130. * @param updatable defines if the mesh must be flagged as updatable
  21131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21132. * @returns a new Mesh
  21133. */
  21134. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21135. /**
  21136. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21137. * @param name defines the name of the mesh to create
  21138. * @param diameter sets the diameter size (float) of the torus (default 1)
  21139. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21140. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21141. * @param scene defines the hosting scene
  21142. * @param updatable defines if the mesh must be flagged as updatable
  21143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21144. * @returns a new Mesh
  21145. */
  21146. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21147. /**
  21148. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21149. * @param name defines the name of the mesh to create
  21150. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21151. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21152. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21153. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21154. * @param p the number of windings on X axis (positive integers, default 2)
  21155. * @param q the number of windings on Y axis (positive integers, default 3)
  21156. * @param scene defines the hosting scene
  21157. * @param updatable defines if the mesh must be flagged as updatable
  21158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21159. * @returns a new Mesh
  21160. */
  21161. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21162. /**
  21163. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21164. * @param name defines the name of the mesh to create
  21165. * @param points is an array successive Vector3
  21166. * @param scene defines the hosting scene
  21167. * @param updatable defines if the mesh must be flagged as updatable
  21168. * @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).
  21169. * @returns a new Mesh
  21170. */
  21171. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21172. /**
  21173. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21174. * @param name defines the name of the mesh to create
  21175. * @param points is an array successive Vector3
  21176. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21177. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21178. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21179. * @param scene defines the hosting scene
  21180. * @param updatable defines if the mesh must be flagged as updatable
  21181. * @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)
  21182. * @returns a new Mesh
  21183. */
  21184. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21185. /**
  21186. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21187. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21188. * 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.
  21189. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21190. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21191. * Remember you can only change the shape positions, not their number when updating a polygon.
  21192. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21193. * @param name defines the name of the mesh to create
  21194. * @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
  21195. * @param scene defines the hosting scene
  21196. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21197. * @param updatable defines if the mesh must be flagged as updatable
  21198. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21199. * @param earcutInjection can be used to inject your own earcut reference
  21200. * @returns a new Mesh
  21201. */
  21202. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21203. /**
  21204. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21205. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21206. * @param name defines the name of the mesh to create
  21207. * @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
  21208. * @param depth defines the height of extrusion
  21209. * @param scene defines the hosting scene
  21210. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21211. * @param updatable defines if the mesh must be flagged as updatable
  21212. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21213. * @param earcutInjection can be used to inject your own earcut reference
  21214. * @returns a new Mesh
  21215. */
  21216. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21217. /**
  21218. * Creates an extruded shape mesh.
  21219. * 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
  21220. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21221. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21222. * @param name defines the name of the mesh to create
  21223. * @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
  21224. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21225. * @param scale is the value to scale the shape
  21226. * @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
  21227. * @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
  21228. * @param scene defines the hosting scene
  21229. * @param updatable defines if the mesh must be flagged as updatable
  21230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21231. * @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)
  21232. * @returns a new Mesh
  21233. */
  21234. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21235. /**
  21236. * Creates an custom extruded shape mesh.
  21237. * The custom extrusion is a parametric shape.
  21238. * It has no predefined shape. Its final shape will depend on the input parameters.
  21239. * Please consider using the same method from the MeshBuilder class instead
  21240. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21241. * @param name defines the name of the mesh to create
  21242. * @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
  21243. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21244. * @param scaleFunction is a custom Javascript function called on each path point
  21245. * @param rotationFunction is a custom Javascript function called on each path point
  21246. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21247. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21248. * @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
  21249. * @param scene defines the hosting scene
  21250. * @param updatable defines if the mesh must be flagged as updatable
  21251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21252. * @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)
  21253. * @returns a new Mesh
  21254. */
  21255. 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;
  21256. /**
  21257. * Creates lathe mesh.
  21258. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21259. * Please consider using the same method from the MeshBuilder class instead
  21260. * @param name defines the name of the mesh to create
  21261. * @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
  21262. * @param radius is the radius value of the lathe
  21263. * @param tessellation is the side number of the lathe.
  21264. * @param scene defines the hosting scene
  21265. * @param updatable defines if the mesh must be flagged as updatable
  21266. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21267. * @returns a new Mesh
  21268. */
  21269. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21270. /**
  21271. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21272. * @param name defines the name of the mesh to create
  21273. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21274. * @param scene defines the hosting scene
  21275. * @param updatable defines if the mesh must be flagged as updatable
  21276. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21277. * @returns a new Mesh
  21278. */
  21279. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21280. /**
  21281. * Creates a ground mesh.
  21282. * Please consider using the same method from the MeshBuilder class instead
  21283. * @param name defines the name of the mesh to create
  21284. * @param width set the width of the ground
  21285. * @param height set the height of the ground
  21286. * @param subdivisions sets the number of subdivisions per side
  21287. * @param scene defines the hosting scene
  21288. * @param updatable defines if the mesh must be flagged as updatable
  21289. * @returns a new Mesh
  21290. */
  21291. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21292. /**
  21293. * Creates a tiled ground mesh.
  21294. * Please consider using the same method from the MeshBuilder class instead
  21295. * @param name defines the name of the mesh to create
  21296. * @param xmin set the ground minimum X coordinate
  21297. * @param zmin set the ground minimum Y coordinate
  21298. * @param xmax set the ground maximum X coordinate
  21299. * @param zmax set the ground maximum Z coordinate
  21300. * @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
  21301. * @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
  21302. * @param scene defines the hosting scene
  21303. * @param updatable defines if the mesh must be flagged as updatable
  21304. * @returns a new Mesh
  21305. */
  21306. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21307. w: number;
  21308. h: number;
  21309. }, precision: {
  21310. w: number;
  21311. h: number;
  21312. }, scene: Scene, updatable?: boolean): Mesh;
  21313. /**
  21314. * Creates a ground mesh from a height map.
  21315. * Please consider using the same method from the MeshBuilder class instead
  21316. * @see http://doc.babylonjs.com/babylon101/height_map
  21317. * @param name defines the name of the mesh to create
  21318. * @param url sets the URL of the height map image resource
  21319. * @param width set the ground width size
  21320. * @param height set the ground height size
  21321. * @param subdivisions sets the number of subdivision per side
  21322. * @param minHeight is the minimum altitude on the ground
  21323. * @param maxHeight is the maximum altitude on the ground
  21324. * @param scene defines the hosting scene
  21325. * @param updatable defines if the mesh must be flagged as updatable
  21326. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21327. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21328. * @returns a new Mesh
  21329. */
  21330. 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;
  21331. /**
  21332. * Creates a tube mesh.
  21333. * The tube is a parametric shape.
  21334. * It has no predefined shape. Its final shape will depend on the input parameters.
  21335. * Please consider using the same method from the MeshBuilder class instead
  21336. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21337. * @param name defines the name of the mesh to create
  21338. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21339. * @param radius sets the tube radius size
  21340. * @param tessellation is the number of sides on the tubular surface
  21341. * @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
  21342. * @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
  21343. * @param scene defines the hosting scene
  21344. * @param updatable defines if the mesh must be flagged as updatable
  21345. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21346. * @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)
  21347. * @returns a new Mesh
  21348. */
  21349. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21350. (i: number, distance: number): number;
  21351. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21352. /**
  21353. * Creates a polyhedron mesh.
  21354. * Please consider using the same method from the MeshBuilder class instead.
  21355. * * 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
  21356. * * The parameter `size` (positive float, default 1) sets the polygon size
  21357. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21358. * * 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`
  21359. * * 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
  21360. * * 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)`)
  21361. * * 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
  21362. * * 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
  21363. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21364. * * 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
  21365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21366. * @param name defines the name of the mesh to create
  21367. * @param options defines the options used to create the mesh
  21368. * @param scene defines the hosting scene
  21369. * @returns a new Mesh
  21370. */
  21371. static CreatePolyhedron(name: string, options: {
  21372. type?: number;
  21373. size?: number;
  21374. sizeX?: number;
  21375. sizeY?: number;
  21376. sizeZ?: number;
  21377. custom?: any;
  21378. faceUV?: Vector4[];
  21379. faceColors?: Color4[];
  21380. updatable?: boolean;
  21381. sideOrientation?: number;
  21382. }, scene: Scene): Mesh;
  21383. /**
  21384. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21385. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21386. * * 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`)
  21387. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21388. * * 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
  21389. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21390. * * 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
  21391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21392. * @param name defines the name of the mesh
  21393. * @param options defines the options used to create the mesh
  21394. * @param scene defines the hosting scene
  21395. * @returns a new Mesh
  21396. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21397. */
  21398. static CreateIcoSphere(name: string, options: {
  21399. radius?: number;
  21400. flat?: boolean;
  21401. subdivisions?: number;
  21402. sideOrientation?: number;
  21403. updatable?: boolean;
  21404. }, scene: Scene): Mesh;
  21405. /**
  21406. * Creates a decal mesh.
  21407. * Please consider using the same method from the MeshBuilder class instead.
  21408. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21409. * @param name defines the name of the mesh
  21410. * @param sourceMesh defines the mesh receiving the decal
  21411. * @param position sets the position of the decal in world coordinates
  21412. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21413. * @param size sets the decal scaling
  21414. * @param angle sets the angle to rotate the decal
  21415. * @returns a new Mesh
  21416. */
  21417. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21418. /**
  21419. * Prepare internal position array for software CPU skinning
  21420. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21421. */
  21422. setPositionsForCPUSkinning(): Float32Array;
  21423. /**
  21424. * Prepare internal normal array for software CPU skinning
  21425. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21426. */
  21427. setNormalsForCPUSkinning(): Float32Array;
  21428. /**
  21429. * Updates the vertex buffer by applying transformation from the bones
  21430. * @param skeleton defines the skeleton to apply to current mesh
  21431. * @returns the current mesh
  21432. */
  21433. applySkeleton(skeleton: Skeleton): Mesh;
  21434. /**
  21435. * 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
  21436. * @param meshes defines the list of meshes to scan
  21437. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21438. */
  21439. static MinMax(meshes: AbstractMesh[]): {
  21440. min: Vector3;
  21441. max: Vector3;
  21442. };
  21443. /**
  21444. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21445. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21446. * @returns a vector3
  21447. */
  21448. static Center(meshesOrMinMaxVector: {
  21449. min: Vector3;
  21450. max: Vector3;
  21451. } | AbstractMesh[]): Vector3;
  21452. /**
  21453. * Merge the array of meshes into a single mesh for performance reasons.
  21454. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21455. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21456. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21457. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21458. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21459. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21460. * @returns a new mesh
  21461. */
  21462. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21463. /** @hidden */
  21464. addInstance(instance: InstancedMesh): void;
  21465. /** @hidden */
  21466. removeInstance(instance: InstancedMesh): void;
  21467. }
  21468. }
  21469. declare module BABYLON {
  21470. /**
  21471. * Base class for the main features of a material in Babylon.js
  21472. */
  21473. export class Material implements IAnimatable {
  21474. /**
  21475. * Returns the triangle fill mode
  21476. */
  21477. static readonly TriangleFillMode: number;
  21478. /**
  21479. * Returns the wireframe mode
  21480. */
  21481. static readonly WireFrameFillMode: number;
  21482. /**
  21483. * Returns the point fill mode
  21484. */
  21485. static readonly PointFillMode: number;
  21486. /**
  21487. * Returns the point list draw mode
  21488. */
  21489. static readonly PointListDrawMode: number;
  21490. /**
  21491. * Returns the line list draw mode
  21492. */
  21493. static readonly LineListDrawMode: number;
  21494. /**
  21495. * Returns the line loop draw mode
  21496. */
  21497. static readonly LineLoopDrawMode: number;
  21498. /**
  21499. * Returns the line strip draw mode
  21500. */
  21501. static readonly LineStripDrawMode: number;
  21502. /**
  21503. * Returns the triangle strip draw mode
  21504. */
  21505. static readonly TriangleStripDrawMode: number;
  21506. /**
  21507. * Returns the triangle fan draw mode
  21508. */
  21509. static readonly TriangleFanDrawMode: number;
  21510. /**
  21511. * Stores the clock-wise side orientation
  21512. */
  21513. static readonly ClockWiseSideOrientation: number;
  21514. /**
  21515. * Stores the counter clock-wise side orientation
  21516. */
  21517. static readonly CounterClockWiseSideOrientation: number;
  21518. /**
  21519. * The dirty texture flag value
  21520. */
  21521. static readonly TextureDirtyFlag: number;
  21522. /**
  21523. * The dirty light flag value
  21524. */
  21525. static readonly LightDirtyFlag: number;
  21526. /**
  21527. * The dirty fresnel flag value
  21528. */
  21529. static readonly FresnelDirtyFlag: number;
  21530. /**
  21531. * The dirty attribute flag value
  21532. */
  21533. static readonly AttributesDirtyFlag: number;
  21534. /**
  21535. * The dirty misc flag value
  21536. */
  21537. static readonly MiscDirtyFlag: number;
  21538. /**
  21539. * The all dirty flag value
  21540. */
  21541. static readonly AllDirtyFlag: number;
  21542. /**
  21543. * The ID of the material
  21544. */
  21545. id: string;
  21546. /**
  21547. * Gets or sets the unique id of the material
  21548. */
  21549. uniqueId: number;
  21550. /**
  21551. * The name of the material
  21552. */
  21553. name: string;
  21554. /**
  21555. * Gets or sets user defined metadata
  21556. */
  21557. metadata: any;
  21558. /**
  21559. * For internal use only. Please do not use.
  21560. */
  21561. reservedDataStore: any;
  21562. /**
  21563. * Specifies if the ready state should be checked on each call
  21564. */
  21565. checkReadyOnEveryCall: boolean;
  21566. /**
  21567. * Specifies if the ready state should be checked once
  21568. */
  21569. checkReadyOnlyOnce: boolean;
  21570. /**
  21571. * The state of the material
  21572. */
  21573. state: string;
  21574. /**
  21575. * The alpha value of the material
  21576. */
  21577. protected _alpha: number;
  21578. /**
  21579. * List of inspectable custom properties (used by the Inspector)
  21580. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21581. */
  21582. inspectableCustomProperties: IInspectable[];
  21583. /**
  21584. * Sets the alpha value of the material
  21585. */
  21586. /**
  21587. * Gets the alpha value of the material
  21588. */
  21589. alpha: number;
  21590. /**
  21591. * Specifies if back face culling is enabled
  21592. */
  21593. protected _backFaceCulling: boolean;
  21594. /**
  21595. * Sets the back-face culling state
  21596. */
  21597. /**
  21598. * Gets the back-face culling state
  21599. */
  21600. backFaceCulling: boolean;
  21601. /**
  21602. * Stores the value for side orientation
  21603. */
  21604. sideOrientation: number;
  21605. /**
  21606. * Callback triggered when the material is compiled
  21607. */
  21608. onCompiled: Nullable<(effect: Effect) => void>;
  21609. /**
  21610. * Callback triggered when an error occurs
  21611. */
  21612. onError: Nullable<(effect: Effect, errors: string) => void>;
  21613. /**
  21614. * Callback triggered to get the render target textures
  21615. */
  21616. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21617. /**
  21618. * Gets a boolean indicating that current material needs to register RTT
  21619. */
  21620. readonly hasRenderTargetTextures: boolean;
  21621. /**
  21622. * Specifies if the material should be serialized
  21623. */
  21624. doNotSerialize: boolean;
  21625. /**
  21626. * @hidden
  21627. */ storeEffectOnSubMeshes: boolean;
  21628. /**
  21629. * Stores the animations for the material
  21630. */
  21631. animations: Nullable<Array<Animation>>;
  21632. /**
  21633. * An event triggered when the material is disposed
  21634. */
  21635. onDisposeObservable: Observable<Material>;
  21636. /**
  21637. * An observer which watches for dispose events
  21638. */
  21639. private _onDisposeObserver;
  21640. private _onUnBindObservable;
  21641. /**
  21642. * Called during a dispose event
  21643. */
  21644. onDispose: () => void;
  21645. private _onBindObservable;
  21646. /**
  21647. * An event triggered when the material is bound
  21648. */
  21649. readonly onBindObservable: Observable<AbstractMesh>;
  21650. /**
  21651. * An observer which watches for bind events
  21652. */
  21653. private _onBindObserver;
  21654. /**
  21655. * Called during a bind event
  21656. */
  21657. onBind: (Mesh: AbstractMesh) => void;
  21658. /**
  21659. * An event triggered when the material is unbound
  21660. */
  21661. readonly onUnBindObservable: Observable<Material>;
  21662. /**
  21663. * Stores the value of the alpha mode
  21664. */
  21665. private _alphaMode;
  21666. /**
  21667. * Sets the value of the alpha mode.
  21668. *
  21669. * | Value | Type | Description |
  21670. * | --- | --- | --- |
  21671. * | 0 | ALPHA_DISABLE | |
  21672. * | 1 | ALPHA_ADD | |
  21673. * | 2 | ALPHA_COMBINE | |
  21674. * | 3 | ALPHA_SUBTRACT | |
  21675. * | 4 | ALPHA_MULTIPLY | |
  21676. * | 5 | ALPHA_MAXIMIZED | |
  21677. * | 6 | ALPHA_ONEONE | |
  21678. * | 7 | ALPHA_PREMULTIPLIED | |
  21679. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21680. * | 9 | ALPHA_INTERPOLATE | |
  21681. * | 10 | ALPHA_SCREENMODE | |
  21682. *
  21683. */
  21684. /**
  21685. * Gets the value of the alpha mode
  21686. */
  21687. alphaMode: number;
  21688. /**
  21689. * Stores the state of the need depth pre-pass value
  21690. */
  21691. private _needDepthPrePass;
  21692. /**
  21693. * Sets the need depth pre-pass value
  21694. */
  21695. /**
  21696. * Gets the depth pre-pass value
  21697. */
  21698. needDepthPrePass: boolean;
  21699. /**
  21700. * Specifies if depth writing should be disabled
  21701. */
  21702. disableDepthWrite: boolean;
  21703. /**
  21704. * Specifies if depth writing should be forced
  21705. */
  21706. forceDepthWrite: boolean;
  21707. /**
  21708. * Specifies if there should be a separate pass for culling
  21709. */
  21710. separateCullingPass: boolean;
  21711. /**
  21712. * Stores the state specifing if fog should be enabled
  21713. */
  21714. private _fogEnabled;
  21715. /**
  21716. * Sets the state for enabling fog
  21717. */
  21718. /**
  21719. * Gets the value of the fog enabled state
  21720. */
  21721. fogEnabled: boolean;
  21722. /**
  21723. * Stores the size of points
  21724. */
  21725. pointSize: number;
  21726. /**
  21727. * Stores the z offset value
  21728. */
  21729. zOffset: number;
  21730. /**
  21731. * Gets a value specifying if wireframe mode is enabled
  21732. */
  21733. /**
  21734. * Sets the state of wireframe mode
  21735. */
  21736. wireframe: boolean;
  21737. /**
  21738. * Gets the value specifying if point clouds are enabled
  21739. */
  21740. /**
  21741. * Sets the state of point cloud mode
  21742. */
  21743. pointsCloud: boolean;
  21744. /**
  21745. * Gets the material fill mode
  21746. */
  21747. /**
  21748. * Sets the material fill mode
  21749. */
  21750. fillMode: number;
  21751. /**
  21752. * @hidden
  21753. * Stores the effects for the material
  21754. */ effect: Nullable<Effect>;
  21755. /**
  21756. * @hidden
  21757. * Specifies if the material was previously ready
  21758. */ wasPreviouslyReady: boolean;
  21759. /**
  21760. * Specifies if uniform buffers should be used
  21761. */
  21762. private _useUBO;
  21763. /**
  21764. * Stores a reference to the scene
  21765. */
  21766. private _scene;
  21767. /**
  21768. * Stores the fill mode state
  21769. */
  21770. private _fillMode;
  21771. /**
  21772. * Specifies if the depth write state should be cached
  21773. */
  21774. private _cachedDepthWriteState;
  21775. /**
  21776. * Stores the uniform buffer
  21777. */
  21778. protected _uniformBuffer: UniformBuffer;
  21779. /** @hidden */ indexInSceneMaterialArray: number;
  21780. /** @hidden */
  21781. meshMap: Nullable<{
  21782. [id: string]: AbstractMesh | undefined;
  21783. }>;
  21784. /**
  21785. * Creates a material instance
  21786. * @param name defines the name of the material
  21787. * @param scene defines the scene to reference
  21788. * @param doNotAdd specifies if the material should be added to the scene
  21789. */
  21790. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21791. /**
  21792. * Returns a string representation of the current material
  21793. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21794. * @returns a string with material information
  21795. */
  21796. toString(fullDetails?: boolean): string;
  21797. /**
  21798. * Gets the class name of the material
  21799. * @returns a string with the class name of the material
  21800. */
  21801. getClassName(): string;
  21802. /**
  21803. * Specifies if updates for the material been locked
  21804. */
  21805. readonly isFrozen: boolean;
  21806. /**
  21807. * Locks updates for the material
  21808. */
  21809. freeze(): void;
  21810. /**
  21811. * Unlocks updates for the material
  21812. */
  21813. unfreeze(): void;
  21814. /**
  21815. * Specifies if the material is ready to be used
  21816. * @param mesh defines the mesh to check
  21817. * @param useInstances specifies if instances should be used
  21818. * @returns a boolean indicating if the material is ready to be used
  21819. */
  21820. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21821. /**
  21822. * Specifies that the submesh is ready to be used
  21823. * @param mesh defines the mesh to check
  21824. * @param subMesh defines which submesh to check
  21825. * @param useInstances specifies that instances should be used
  21826. * @returns a boolean indicating that the submesh is ready or not
  21827. */
  21828. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21829. /**
  21830. * Returns the material effect
  21831. * @returns the effect associated with the material
  21832. */
  21833. getEffect(): Nullable<Effect>;
  21834. /**
  21835. * Returns the current scene
  21836. * @returns a Scene
  21837. */
  21838. getScene(): Scene;
  21839. /**
  21840. * Specifies if the material will require alpha blending
  21841. * @returns a boolean specifying if alpha blending is needed
  21842. */
  21843. needAlphaBlending(): boolean;
  21844. /**
  21845. * Specifies if the mesh will require alpha blending
  21846. * @param mesh defines the mesh to check
  21847. * @returns a boolean specifying if alpha blending is needed for the mesh
  21848. */
  21849. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21850. /**
  21851. * Specifies if this material should be rendered in alpha test mode
  21852. * @returns a boolean specifying if an alpha test is needed.
  21853. */
  21854. needAlphaTesting(): boolean;
  21855. /**
  21856. * Gets the texture used for the alpha test
  21857. * @returns the texture to use for alpha testing
  21858. */
  21859. getAlphaTestTexture(): Nullable<BaseTexture>;
  21860. /**
  21861. * Marks the material to indicate that it needs to be re-calculated
  21862. */
  21863. markDirty(): void;
  21864. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21865. /**
  21866. * Binds the material to the mesh
  21867. * @param world defines the world transformation matrix
  21868. * @param mesh defines the mesh to bind the material to
  21869. */
  21870. bind(world: Matrix, mesh?: Mesh): void;
  21871. /**
  21872. * Binds the submesh to the material
  21873. * @param world defines the world transformation matrix
  21874. * @param mesh defines the mesh containing the submesh
  21875. * @param subMesh defines the submesh to bind the material to
  21876. */
  21877. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21878. /**
  21879. * Binds the world matrix to the material
  21880. * @param world defines the world transformation matrix
  21881. */
  21882. bindOnlyWorldMatrix(world: Matrix): void;
  21883. /**
  21884. * Binds the scene's uniform buffer to the effect.
  21885. * @param effect defines the effect to bind to the scene uniform buffer
  21886. * @param sceneUbo defines the uniform buffer storing scene data
  21887. */
  21888. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21889. /**
  21890. * Binds the view matrix to the effect
  21891. * @param effect defines the effect to bind the view matrix to
  21892. */
  21893. bindView(effect: Effect): void;
  21894. /**
  21895. * Binds the view projection matrix to the effect
  21896. * @param effect defines the effect to bind the view projection matrix to
  21897. */
  21898. bindViewProjection(effect: Effect): void;
  21899. /**
  21900. * Specifies if material alpha testing should be turned on for the mesh
  21901. * @param mesh defines the mesh to check
  21902. */
  21903. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21904. /**
  21905. * Processes to execute after binding the material to a mesh
  21906. * @param mesh defines the rendered mesh
  21907. */
  21908. protected _afterBind(mesh?: Mesh): void;
  21909. /**
  21910. * Unbinds the material from the mesh
  21911. */
  21912. unbind(): void;
  21913. /**
  21914. * Gets the active textures from the material
  21915. * @returns an array of textures
  21916. */
  21917. getActiveTextures(): BaseTexture[];
  21918. /**
  21919. * Specifies if the material uses a texture
  21920. * @param texture defines the texture to check against the material
  21921. * @returns a boolean specifying if the material uses the texture
  21922. */
  21923. hasTexture(texture: BaseTexture): boolean;
  21924. /**
  21925. * Makes a duplicate of the material, and gives it a new name
  21926. * @param name defines the new name for the duplicated material
  21927. * @returns the cloned material
  21928. */
  21929. clone(name: string): Nullable<Material>;
  21930. /**
  21931. * Gets the meshes bound to the material
  21932. * @returns an array of meshes bound to the material
  21933. */
  21934. getBindedMeshes(): AbstractMesh[];
  21935. /**
  21936. * Force shader compilation
  21937. * @param mesh defines the mesh associated with this material
  21938. * @param onCompiled defines a function to execute once the material is compiled
  21939. * @param options defines the options to configure the compilation
  21940. */
  21941. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21942. clipPlane: boolean;
  21943. }>): void;
  21944. /**
  21945. * Force shader compilation
  21946. * @param mesh defines the mesh that will use this material
  21947. * @param options defines additional options for compiling the shaders
  21948. * @returns a promise that resolves when the compilation completes
  21949. */
  21950. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21951. clipPlane: boolean;
  21952. }>): Promise<void>;
  21953. private static readonly _ImageProcessingDirtyCallBack;
  21954. private static readonly _TextureDirtyCallBack;
  21955. private static readonly _FresnelDirtyCallBack;
  21956. private static readonly _MiscDirtyCallBack;
  21957. private static readonly _LightsDirtyCallBack;
  21958. private static readonly _AttributeDirtyCallBack;
  21959. private static _FresnelAndMiscDirtyCallBack;
  21960. private static _TextureAndMiscDirtyCallBack;
  21961. private static readonly _DirtyCallbackArray;
  21962. private static readonly _RunDirtyCallBacks;
  21963. /**
  21964. * Marks a define in the material to indicate that it needs to be re-computed
  21965. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21966. */
  21967. markAsDirty(flag: number): void;
  21968. /**
  21969. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21970. * @param func defines a function which checks material defines against the submeshes
  21971. */
  21972. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21973. /**
  21974. * Indicates that image processing needs to be re-calculated for all submeshes
  21975. */
  21976. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21977. /**
  21978. * Indicates that textures need to be re-calculated for all submeshes
  21979. */
  21980. protected _markAllSubMeshesAsTexturesDirty(): void;
  21981. /**
  21982. * Indicates that fresnel needs to be re-calculated for all submeshes
  21983. */
  21984. protected _markAllSubMeshesAsFresnelDirty(): void;
  21985. /**
  21986. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21987. */
  21988. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21989. /**
  21990. * Indicates that lights need to be re-calculated for all submeshes
  21991. */
  21992. protected _markAllSubMeshesAsLightsDirty(): void;
  21993. /**
  21994. * Indicates that attributes need to be re-calculated for all submeshes
  21995. */
  21996. protected _markAllSubMeshesAsAttributesDirty(): void;
  21997. /**
  21998. * Indicates that misc needs to be re-calculated for all submeshes
  21999. */
  22000. protected _markAllSubMeshesAsMiscDirty(): void;
  22001. /**
  22002. * Indicates that textures and misc need to be re-calculated for all submeshes
  22003. */
  22004. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22005. /**
  22006. * Disposes the material
  22007. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22008. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22009. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22010. */
  22011. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22012. /** @hidden */
  22013. private releaseVertexArrayObject;
  22014. /**
  22015. * Serializes this material
  22016. * @returns the serialized material object
  22017. */
  22018. serialize(): any;
  22019. /**
  22020. * Creates a material from parsed material data
  22021. * @param parsedMaterial defines parsed material data
  22022. * @param scene defines the hosting scene
  22023. * @param rootUrl defines the root URL to use to load textures
  22024. * @returns a new material
  22025. */
  22026. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22027. }
  22028. }
  22029. declare module BABYLON {
  22030. /**
  22031. * Base class for submeshes
  22032. */
  22033. export class BaseSubMesh {
  22034. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  22035. /** @hidden */ materialEffect: Nullable<Effect>;
  22036. /**
  22037. * Gets associated effect
  22038. */
  22039. readonly effect: Nullable<Effect>;
  22040. /**
  22041. * Sets associated effect (effect used to render this submesh)
  22042. * @param effect defines the effect to associate with
  22043. * @param defines defines the set of defines used to compile this effect
  22044. */
  22045. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22046. }
  22047. /**
  22048. * Defines a subdivision inside a mesh
  22049. */
  22050. export class SubMesh extends BaseSubMesh implements ICullable {
  22051. /** the material index to use */
  22052. materialIndex: number;
  22053. /** vertex index start */
  22054. verticesStart: number;
  22055. /** vertices count */
  22056. verticesCount: number;
  22057. /** index start */
  22058. indexStart: number;
  22059. /** indices count */
  22060. indexCount: number;
  22061. /** @hidden */ linesIndexCount: number;
  22062. private _mesh;
  22063. private _renderingMesh;
  22064. private _boundingInfo;
  22065. private _linesIndexBuffer;
  22066. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  22067. /** @hidden */ trianglePlanes: Plane[];
  22068. /** @hidden */ lastColliderTransformMatrix: Nullable<Matrix>;
  22069. /** @hidden */ renderId: number;
  22070. /** @hidden */ alphaIndex: number;
  22071. /** @hidden */ distanceToCamera: number;
  22072. /** @hidden */ id: number;
  22073. private _currentMaterial;
  22074. /**
  22075. * Add a new submesh to a mesh
  22076. * @param materialIndex defines the material index to use
  22077. * @param verticesStart defines vertex index start
  22078. * @param verticesCount defines vertices count
  22079. * @param indexStart defines index start
  22080. * @param indexCount defines indices count
  22081. * @param mesh defines the parent mesh
  22082. * @param renderingMesh defines an optional rendering mesh
  22083. * @param createBoundingBox defines if bounding box should be created for this submesh
  22084. * @returns the new submesh
  22085. */
  22086. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22087. /**
  22088. * Creates a new submesh
  22089. * @param materialIndex defines the material index to use
  22090. * @param verticesStart defines vertex index start
  22091. * @param verticesCount defines vertices count
  22092. * @param indexStart defines index start
  22093. * @param indexCount defines indices count
  22094. * @param mesh defines the parent mesh
  22095. * @param renderingMesh defines an optional rendering mesh
  22096. * @param createBoundingBox defines if bounding box should be created for this submesh
  22097. */
  22098. constructor(
  22099. /** the material index to use */
  22100. materialIndex: number,
  22101. /** vertex index start */
  22102. verticesStart: number,
  22103. /** vertices count */
  22104. verticesCount: number,
  22105. /** index start */
  22106. indexStart: number,
  22107. /** indices count */
  22108. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22109. /**
  22110. * Returns true if this submesh covers the entire parent mesh
  22111. * @ignorenaming
  22112. */
  22113. readonly IsGlobal: boolean;
  22114. /**
  22115. * Returns the submesh BoudingInfo object
  22116. * @returns current bounding info (or mesh's one if the submesh is global)
  22117. */
  22118. getBoundingInfo(): BoundingInfo;
  22119. /**
  22120. * Sets the submesh BoundingInfo
  22121. * @param boundingInfo defines the new bounding info to use
  22122. * @returns the SubMesh
  22123. */
  22124. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22125. /**
  22126. * Returns the mesh of the current submesh
  22127. * @return the parent mesh
  22128. */
  22129. getMesh(): AbstractMesh;
  22130. /**
  22131. * Returns the rendering mesh of the submesh
  22132. * @returns the rendering mesh (could be different from parent mesh)
  22133. */
  22134. getRenderingMesh(): Mesh;
  22135. /**
  22136. * Returns the submesh material
  22137. * @returns null or the current material
  22138. */
  22139. getMaterial(): Nullable<Material>;
  22140. /**
  22141. * Sets a new updated BoundingInfo object to the submesh
  22142. * @param data defines an optional position array to use to determine the bounding info
  22143. * @returns the SubMesh
  22144. */
  22145. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22146. /** @hidden */ checkCollision(collider: Collider): boolean;
  22147. /**
  22148. * Updates the submesh BoundingInfo
  22149. * @param world defines the world matrix to use to update the bounding info
  22150. * @returns the submesh
  22151. */
  22152. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22153. /**
  22154. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22155. * @param frustumPlanes defines the frustum planes
  22156. * @returns true if the submesh is intersecting with the frustum
  22157. */
  22158. isInFrustum(frustumPlanes: Plane[]): boolean;
  22159. /**
  22160. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22161. * @param frustumPlanes defines the frustum planes
  22162. * @returns true if the submesh is inside the frustum
  22163. */
  22164. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22165. /**
  22166. * Renders the submesh
  22167. * @param enableAlphaMode defines if alpha needs to be used
  22168. * @returns the submesh
  22169. */
  22170. render(enableAlphaMode: boolean): SubMesh;
  22171. /**
  22172. * @hidden
  22173. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22174. /**
  22175. * Checks if the submesh intersects with a ray
  22176. * @param ray defines the ray to test
  22177. * @returns true is the passed ray intersects the submesh bounding box
  22178. */
  22179. canIntersects(ray: Ray): boolean;
  22180. /**
  22181. * Intersects current submesh with a ray
  22182. * @param ray defines the ray to test
  22183. * @param positions defines mesh's positions array
  22184. * @param indices defines mesh's indices array
  22185. * @param fastCheck defines if only bounding info should be used
  22186. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22187. * @returns intersection info or null if no intersection
  22188. */
  22189. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22190. /** @hidden */
  22191. private _intersectLines;
  22192. /** @hidden */
  22193. private _intersectTriangles;
  22194. /** @hidden */ rebuild(): void;
  22195. /**
  22196. * Creates a new submesh from the passed mesh
  22197. * @param newMesh defines the new hosting mesh
  22198. * @param newRenderingMesh defines an optional rendering mesh
  22199. * @returns the new submesh
  22200. */
  22201. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22202. /**
  22203. * Release associated resources
  22204. */
  22205. dispose(): void;
  22206. /**
  22207. * Gets the class name
  22208. * @returns the string "SubMesh".
  22209. */
  22210. getClassName(): string;
  22211. /**
  22212. * Creates a new submesh from indices data
  22213. * @param materialIndex the index of the main mesh material
  22214. * @param startIndex the index where to start the copy in the mesh indices array
  22215. * @param indexCount the number of indices to copy then from the startIndex
  22216. * @param mesh the main mesh to create the submesh from
  22217. * @param renderingMesh the optional rendering mesh
  22218. * @returns a new submesh
  22219. */
  22220. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22221. }
  22222. }
  22223. declare module BABYLON {
  22224. /**
  22225. * Class used to store geometry data (vertex buffers + index buffer)
  22226. */
  22227. export class Geometry implements IGetSetVerticesData {
  22228. /**
  22229. * Gets or sets the ID of the geometry
  22230. */
  22231. id: string;
  22232. /**
  22233. * Gets or sets the unique ID of the geometry
  22234. */
  22235. uniqueId: number;
  22236. /**
  22237. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22238. */
  22239. delayLoadState: number;
  22240. /**
  22241. * Gets the file containing the data to load when running in delay load state
  22242. */
  22243. delayLoadingFile: Nullable<string>;
  22244. /**
  22245. * Callback called when the geometry is updated
  22246. */
  22247. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22248. private _scene;
  22249. private _engine;
  22250. private _meshes;
  22251. private _totalVertices;
  22252. /** @hidden */ indices: IndicesArray;
  22253. /** @hidden */ vertexBuffers: {
  22254. [key: string]: VertexBuffer;
  22255. };
  22256. private _isDisposed;
  22257. private _extend;
  22258. private _boundingBias;
  22259. /** @hidden */ delayInfo: Array<string>;
  22260. private _indexBuffer;
  22261. private _indexBufferIsUpdatable;
  22262. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  22263. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22264. /** @hidden */ softwareSkinningFrameId: number;
  22265. private _vertexArrayObjects;
  22266. private _updatable;
  22267. /** @hidden */ positions: Nullable<Vector3[]>;
  22268. /**
  22269. * 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
  22270. */
  22271. /**
  22272. * 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
  22273. */
  22274. boundingBias: Vector2;
  22275. /**
  22276. * Static function used to attach a new empty geometry to a mesh
  22277. * @param mesh defines the mesh to attach the geometry to
  22278. * @returns the new Geometry
  22279. */
  22280. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22281. /**
  22282. * Creates a new geometry
  22283. * @param id defines the unique ID
  22284. * @param scene defines the hosting scene
  22285. * @param vertexData defines the VertexData used to get geometry data
  22286. * @param updatable defines if geometry must be updatable (false by default)
  22287. * @param mesh defines the mesh that will be associated with the geometry
  22288. */
  22289. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22290. /**
  22291. * Gets the current extend of the geometry
  22292. */
  22293. readonly extend: {
  22294. minimum: Vector3;
  22295. maximum: Vector3;
  22296. };
  22297. /**
  22298. * Gets the hosting scene
  22299. * @returns the hosting Scene
  22300. */
  22301. getScene(): Scene;
  22302. /**
  22303. * Gets the hosting engine
  22304. * @returns the hosting Engine
  22305. */
  22306. getEngine(): Engine;
  22307. /**
  22308. * Defines if the geometry is ready to use
  22309. * @returns true if the geometry is ready to be used
  22310. */
  22311. isReady(): boolean;
  22312. /**
  22313. * Gets a value indicating that the geometry should not be serialized
  22314. */
  22315. readonly doNotSerialize: boolean;
  22316. /** @hidden */ rebuild(): void;
  22317. /**
  22318. * Affects all geometry data in one call
  22319. * @param vertexData defines the geometry data
  22320. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22321. */
  22322. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22323. /**
  22324. * Set specific vertex data
  22325. * @param kind defines the data kind (Position, normal, etc...)
  22326. * @param data defines the vertex data to use
  22327. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22328. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22329. */
  22330. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22331. /**
  22332. * Removes a specific vertex data
  22333. * @param kind defines the data kind (Position, normal, etc...)
  22334. */
  22335. removeVerticesData(kind: string): void;
  22336. /**
  22337. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22338. * @param buffer defines the vertex buffer to use
  22339. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22340. */
  22341. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22342. /**
  22343. * Update a specific vertex buffer
  22344. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22345. * It will do nothing if the buffer is not updatable
  22346. * @param kind defines the data kind (Position, normal, etc...)
  22347. * @param data defines the data to use
  22348. * @param offset defines the offset in the target buffer where to store the data
  22349. * @param useBytes set to true if the offset is in bytes
  22350. */
  22351. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22352. /**
  22353. * Update a specific vertex buffer
  22354. * This function will create a new buffer if the current one is not updatable
  22355. * @param kind defines the data kind (Position, normal, etc...)
  22356. * @param data defines the data to use
  22357. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22358. */
  22359. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22360. private _updateBoundingInfo;
  22361. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22362. /**
  22363. * Gets total number of vertices
  22364. * @returns the total number of vertices
  22365. */
  22366. getTotalVertices(): number;
  22367. /**
  22368. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22369. * @param kind defines the data kind (Position, normal, etc...)
  22370. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22371. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22372. * @returns a float array containing vertex data
  22373. */
  22374. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22375. /**
  22376. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22377. * @param kind defines the data kind (Position, normal, etc...)
  22378. * @returns true if the vertex buffer with the specified kind is updatable
  22379. */
  22380. isVertexBufferUpdatable(kind: string): boolean;
  22381. /**
  22382. * Gets a specific vertex buffer
  22383. * @param kind defines the data kind (Position, normal, etc...)
  22384. * @returns a VertexBuffer
  22385. */
  22386. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22387. /**
  22388. * Returns all vertex buffers
  22389. * @return an object holding all vertex buffers indexed by kind
  22390. */
  22391. getVertexBuffers(): Nullable<{
  22392. [key: string]: VertexBuffer;
  22393. }>;
  22394. /**
  22395. * Gets a boolean indicating if specific vertex buffer is present
  22396. * @param kind defines the data kind (Position, normal, etc...)
  22397. * @returns true if data is present
  22398. */
  22399. isVerticesDataPresent(kind: string): boolean;
  22400. /**
  22401. * Gets a list of all attached data kinds (Position, normal, etc...)
  22402. * @returns a list of string containing all kinds
  22403. */
  22404. getVerticesDataKinds(): string[];
  22405. /**
  22406. * Update index buffer
  22407. * @param indices defines the indices to store in the index buffer
  22408. * @param offset defines the offset in the target buffer where to store the data
  22409. * @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)
  22410. */
  22411. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22412. /**
  22413. * Creates a new index buffer
  22414. * @param indices defines the indices to store in the index buffer
  22415. * @param totalVertices defines the total number of vertices (could be null)
  22416. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22417. */
  22418. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22419. /**
  22420. * Return the total number of indices
  22421. * @returns the total number of indices
  22422. */
  22423. getTotalIndices(): number;
  22424. /**
  22425. * Gets the index buffer array
  22426. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22427. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22428. * @returns the index buffer array
  22429. */
  22430. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22431. /**
  22432. * Gets the index buffer
  22433. * @return the index buffer
  22434. */
  22435. getIndexBuffer(): Nullable<WebGLBuffer>;
  22436. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22437. /**
  22438. * Release the associated resources for a specific mesh
  22439. * @param mesh defines the source mesh
  22440. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22441. */
  22442. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22443. /**
  22444. * Apply current geometry to a given mesh
  22445. * @param mesh defines the mesh to apply geometry to
  22446. */
  22447. applyToMesh(mesh: Mesh): void;
  22448. private _updateExtend;
  22449. private _applyToMesh;
  22450. private notifyUpdate;
  22451. /**
  22452. * Load the geometry if it was flagged as delay loaded
  22453. * @param scene defines the hosting scene
  22454. * @param onLoaded defines a callback called when the geometry is loaded
  22455. */
  22456. load(scene: Scene, onLoaded?: () => void): void;
  22457. private _queueLoad;
  22458. /**
  22459. * Invert the geometry to move from a right handed system to a left handed one.
  22460. */
  22461. toLeftHanded(): void;
  22462. /** @hidden */ resetPointsArrayCache(): void;
  22463. /** @hidden */ generatePointsArray(): boolean;
  22464. /**
  22465. * Gets a value indicating if the geometry is disposed
  22466. * @returns true if the geometry was disposed
  22467. */
  22468. isDisposed(): boolean;
  22469. private _disposeVertexArrayObjects;
  22470. /**
  22471. * Free all associated resources
  22472. */
  22473. dispose(): void;
  22474. /**
  22475. * Clone the current geometry into a new geometry
  22476. * @param id defines the unique ID of the new geometry
  22477. * @returns a new geometry object
  22478. */
  22479. copy(id: string): Geometry;
  22480. /**
  22481. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22482. * @return a JSON representation of the current geometry data (without the vertices data)
  22483. */
  22484. serialize(): any;
  22485. private toNumberArray;
  22486. /**
  22487. * Serialize all vertices data into a JSON oject
  22488. * @returns a JSON representation of the current geometry data
  22489. */
  22490. serializeVerticeData(): any;
  22491. /**
  22492. * Extracts a clone of a mesh geometry
  22493. * @param mesh defines the source mesh
  22494. * @param id defines the unique ID of the new geometry object
  22495. * @returns the new geometry object
  22496. */
  22497. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22498. /**
  22499. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22500. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22501. * Be aware Math.random() could cause collisions, but:
  22502. * "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"
  22503. * @returns a string containing a new GUID
  22504. */
  22505. static RandomId(): string;
  22506. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22507. private static _CleanMatricesWeights;
  22508. /**
  22509. * Create a new geometry from persisted data (Using .babylon file format)
  22510. * @param parsedVertexData defines the persisted data
  22511. * @param scene defines the hosting scene
  22512. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22513. * @returns the new geometry object
  22514. */
  22515. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22516. }
  22517. }
  22518. declare module BABYLON {
  22519. /**
  22520. * Define an interface for all classes that will get and set the data on vertices
  22521. */
  22522. export interface IGetSetVerticesData {
  22523. /**
  22524. * Gets a boolean indicating if specific vertex data is present
  22525. * @param kind defines the vertex data kind to use
  22526. * @returns true is data kind is present
  22527. */
  22528. isVerticesDataPresent(kind: string): boolean;
  22529. /**
  22530. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22531. * @param kind defines the data kind (Position, normal, etc...)
  22532. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22533. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22534. * @returns a float array containing vertex data
  22535. */
  22536. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22537. /**
  22538. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22539. * @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.
  22540. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22541. * @returns the indices array or an empty array if the mesh has no geometry
  22542. */
  22543. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22544. /**
  22545. * Set specific vertex data
  22546. * @param kind defines the data kind (Position, normal, etc...)
  22547. * @param data defines the vertex data to use
  22548. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22549. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22550. */
  22551. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22552. /**
  22553. * Update a specific associated vertex buffer
  22554. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22555. * - VertexBuffer.PositionKind
  22556. * - VertexBuffer.UVKind
  22557. * - VertexBuffer.UV2Kind
  22558. * - VertexBuffer.UV3Kind
  22559. * - VertexBuffer.UV4Kind
  22560. * - VertexBuffer.UV5Kind
  22561. * - VertexBuffer.UV6Kind
  22562. * - VertexBuffer.ColorKind
  22563. * - VertexBuffer.MatricesIndicesKind
  22564. * - VertexBuffer.MatricesIndicesExtraKind
  22565. * - VertexBuffer.MatricesWeightsKind
  22566. * - VertexBuffer.MatricesWeightsExtraKind
  22567. * @param data defines the data source
  22568. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22569. * @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)
  22570. */
  22571. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22572. /**
  22573. * Creates a new index buffer
  22574. * @param indices defines the indices to store in the index buffer
  22575. * @param totalVertices defines the total number of vertices (could be null)
  22576. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22577. */
  22578. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22579. }
  22580. /**
  22581. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22582. */
  22583. export class VertexData {
  22584. /**
  22585. * Mesh side orientation : usually the external or front surface
  22586. */
  22587. static readonly FRONTSIDE: number;
  22588. /**
  22589. * Mesh side orientation : usually the internal or back surface
  22590. */
  22591. static readonly BACKSIDE: number;
  22592. /**
  22593. * Mesh side orientation : both internal and external or front and back surfaces
  22594. */
  22595. static readonly DOUBLESIDE: number;
  22596. /**
  22597. * Mesh side orientation : by default, `FRONTSIDE`
  22598. */
  22599. static readonly DEFAULTSIDE: number;
  22600. /**
  22601. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22602. */
  22603. positions: Nullable<FloatArray>;
  22604. /**
  22605. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22606. */
  22607. normals: Nullable<FloatArray>;
  22608. /**
  22609. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22610. */
  22611. tangents: Nullable<FloatArray>;
  22612. /**
  22613. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22614. */
  22615. uvs: Nullable<FloatArray>;
  22616. /**
  22617. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22618. */
  22619. uvs2: Nullable<FloatArray>;
  22620. /**
  22621. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22622. */
  22623. uvs3: Nullable<FloatArray>;
  22624. /**
  22625. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22626. */
  22627. uvs4: Nullable<FloatArray>;
  22628. /**
  22629. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22630. */
  22631. uvs5: Nullable<FloatArray>;
  22632. /**
  22633. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22634. */
  22635. uvs6: Nullable<FloatArray>;
  22636. /**
  22637. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22638. */
  22639. colors: Nullable<FloatArray>;
  22640. /**
  22641. * 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).
  22642. */
  22643. matricesIndices: Nullable<FloatArray>;
  22644. /**
  22645. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22646. */
  22647. matricesWeights: Nullable<FloatArray>;
  22648. /**
  22649. * An array extending the number of possible indices
  22650. */
  22651. matricesIndicesExtra: Nullable<FloatArray>;
  22652. /**
  22653. * An array extending the number of possible weights when the number of indices is extended
  22654. */
  22655. matricesWeightsExtra: Nullable<FloatArray>;
  22656. /**
  22657. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22658. */
  22659. indices: Nullable<IndicesArray>;
  22660. /**
  22661. * Uses the passed data array to set the set the values for the specified kind of data
  22662. * @param data a linear array of floating numbers
  22663. * @param kind the type of data that is being set, eg positions, colors etc
  22664. */
  22665. set(data: FloatArray, kind: string): void;
  22666. /**
  22667. * Associates the vertexData to the passed Mesh.
  22668. * Sets it as updatable or not (default `false`)
  22669. * @param mesh the mesh the vertexData is applied to
  22670. * @param updatable when used and having the value true allows new data to update the vertexData
  22671. * @returns the VertexData
  22672. */
  22673. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22674. /**
  22675. * Associates the vertexData to the passed Geometry.
  22676. * Sets it as updatable or not (default `false`)
  22677. * @param geometry the geometry the vertexData is applied to
  22678. * @param updatable when used and having the value true allows new data to update the vertexData
  22679. * @returns VertexData
  22680. */
  22681. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22682. /**
  22683. * Updates the associated mesh
  22684. * @param mesh the mesh to be updated
  22685. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22686. * @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
  22687. * @returns VertexData
  22688. */
  22689. updateMesh(mesh: Mesh): VertexData;
  22690. /**
  22691. * Updates the associated geometry
  22692. * @param geometry the geometry to be updated
  22693. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22694. * @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
  22695. * @returns VertexData.
  22696. */
  22697. updateGeometry(geometry: Geometry): VertexData;
  22698. private _applyTo;
  22699. private _update;
  22700. /**
  22701. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22702. * @param matrix the transforming matrix
  22703. * @returns the VertexData
  22704. */
  22705. transform(matrix: Matrix): VertexData;
  22706. /**
  22707. * Merges the passed VertexData into the current one
  22708. * @param other the VertexData to be merged into the current one
  22709. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22710. * @returns the modified VertexData
  22711. */
  22712. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22713. private _mergeElement;
  22714. private _validate;
  22715. /**
  22716. * Serializes the VertexData
  22717. * @returns a serialized object
  22718. */
  22719. serialize(): any;
  22720. /**
  22721. * Extracts the vertexData from a mesh
  22722. * @param mesh the mesh from which to extract the VertexData
  22723. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22724. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22725. * @returns the object VertexData associated to the passed mesh
  22726. */
  22727. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22728. /**
  22729. * Extracts the vertexData from the geometry
  22730. * @param geometry the geometry from which to extract the VertexData
  22731. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22732. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22733. * @returns the object VertexData associated to the passed mesh
  22734. */
  22735. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22736. private static _ExtractFrom;
  22737. /**
  22738. * Creates the VertexData for a Ribbon
  22739. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22740. * * pathArray array of paths, each of which an array of successive Vector3
  22741. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22742. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22743. * * 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
  22744. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22745. * * 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)
  22746. * * 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)
  22747. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22748. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22749. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22750. * @returns the VertexData of the ribbon
  22751. */
  22752. static CreateRibbon(options: {
  22753. pathArray: Vector3[][];
  22754. closeArray?: boolean;
  22755. closePath?: boolean;
  22756. offset?: number;
  22757. sideOrientation?: number;
  22758. frontUVs?: Vector4;
  22759. backUVs?: Vector4;
  22760. invertUV?: boolean;
  22761. uvs?: Vector2[];
  22762. colors?: Color4[];
  22763. }): VertexData;
  22764. /**
  22765. * Creates the VertexData for a box
  22766. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22767. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22768. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22769. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22770. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22771. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22772. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22773. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22774. * * 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)
  22775. * * 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)
  22776. * @returns the VertexData of the box
  22777. */
  22778. static CreateBox(options: {
  22779. size?: number;
  22780. width?: number;
  22781. height?: number;
  22782. depth?: number;
  22783. faceUV?: Vector4[];
  22784. faceColors?: Color4[];
  22785. sideOrientation?: number;
  22786. frontUVs?: Vector4;
  22787. backUVs?: Vector4;
  22788. }): VertexData;
  22789. /**
  22790. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22791. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22792. * * segments sets the number of horizontal strips optional, default 32
  22793. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22794. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22795. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22796. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22797. * * 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
  22798. * * 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
  22799. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22800. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22801. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22802. * @returns the VertexData of the ellipsoid
  22803. */
  22804. static CreateSphere(options: {
  22805. segments?: number;
  22806. diameter?: number;
  22807. diameterX?: number;
  22808. diameterY?: number;
  22809. diameterZ?: number;
  22810. arc?: number;
  22811. slice?: number;
  22812. sideOrientation?: number;
  22813. frontUVs?: Vector4;
  22814. backUVs?: Vector4;
  22815. }): VertexData;
  22816. /**
  22817. * Creates the VertexData for a cylinder, cone or prism
  22818. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22819. * * height sets the height (y direction) of the cylinder, optional, default 2
  22820. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22821. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22822. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22823. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22824. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22825. * * 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
  22826. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22827. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22828. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22829. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22830. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22831. * * 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)
  22832. * * 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)
  22833. * @returns the VertexData of the cylinder, cone or prism
  22834. */
  22835. static CreateCylinder(options: {
  22836. height?: number;
  22837. diameterTop?: number;
  22838. diameterBottom?: number;
  22839. diameter?: number;
  22840. tessellation?: number;
  22841. subdivisions?: number;
  22842. arc?: number;
  22843. faceColors?: Color4[];
  22844. faceUV?: Vector4[];
  22845. hasRings?: boolean;
  22846. enclose?: boolean;
  22847. sideOrientation?: number;
  22848. frontUVs?: Vector4;
  22849. backUVs?: Vector4;
  22850. }): VertexData;
  22851. /**
  22852. * Creates the VertexData for a torus
  22853. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22854. * * diameter the diameter of the torus, optional default 1
  22855. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22856. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22857. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22858. * * 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)
  22859. * * 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)
  22860. * @returns the VertexData of the torus
  22861. */
  22862. static CreateTorus(options: {
  22863. diameter?: number;
  22864. thickness?: number;
  22865. tessellation?: number;
  22866. sideOrientation?: number;
  22867. frontUVs?: Vector4;
  22868. backUVs?: Vector4;
  22869. }): VertexData;
  22870. /**
  22871. * Creates the VertexData of the LineSystem
  22872. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22873. * - lines an array of lines, each line being an array of successive Vector3
  22874. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22875. * @returns the VertexData of the LineSystem
  22876. */
  22877. static CreateLineSystem(options: {
  22878. lines: Vector3[][];
  22879. colors?: Nullable<Color4[][]>;
  22880. }): VertexData;
  22881. /**
  22882. * Create the VertexData for a DashedLines
  22883. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22884. * - points an array successive Vector3
  22885. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22886. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22887. * - dashNb the intended total number of dashes, optional, default 200
  22888. * @returns the VertexData for the DashedLines
  22889. */
  22890. static CreateDashedLines(options: {
  22891. points: Vector3[];
  22892. dashSize?: number;
  22893. gapSize?: number;
  22894. dashNb?: number;
  22895. }): VertexData;
  22896. /**
  22897. * Creates the VertexData for a Ground
  22898. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22899. * - width the width (x direction) of the ground, optional, default 1
  22900. * - height the height (z direction) of the ground, optional, default 1
  22901. * - subdivisions the number of subdivisions per side, optional, default 1
  22902. * @returns the VertexData of the Ground
  22903. */
  22904. static CreateGround(options: {
  22905. width?: number;
  22906. height?: number;
  22907. subdivisions?: number;
  22908. subdivisionsX?: number;
  22909. subdivisionsY?: number;
  22910. }): VertexData;
  22911. /**
  22912. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22913. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22914. * * xmin the ground minimum X coordinate, optional, default -1
  22915. * * zmin the ground minimum Z coordinate, optional, default -1
  22916. * * xmax the ground maximum X coordinate, optional, default 1
  22917. * * zmax the ground maximum Z coordinate, optional, default 1
  22918. * * 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}
  22919. * * 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}
  22920. * @returns the VertexData of the TiledGround
  22921. */
  22922. static CreateTiledGround(options: {
  22923. xmin: number;
  22924. zmin: number;
  22925. xmax: number;
  22926. zmax: number;
  22927. subdivisions?: {
  22928. w: number;
  22929. h: number;
  22930. };
  22931. precision?: {
  22932. w: number;
  22933. h: number;
  22934. };
  22935. }): VertexData;
  22936. /**
  22937. * Creates the VertexData of the Ground designed from a heightmap
  22938. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22939. * * width the width (x direction) of the ground
  22940. * * height the height (z direction) of the ground
  22941. * * subdivisions the number of subdivisions per side
  22942. * * minHeight the minimum altitude on the ground, optional, default 0
  22943. * * maxHeight the maximum altitude on the ground, optional default 1
  22944. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22945. * * buffer the array holding the image color data
  22946. * * bufferWidth the width of image
  22947. * * bufferHeight the height of image
  22948. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22949. * @returns the VertexData of the Ground designed from a heightmap
  22950. */
  22951. static CreateGroundFromHeightMap(options: {
  22952. width: number;
  22953. height: number;
  22954. subdivisions: number;
  22955. minHeight: number;
  22956. maxHeight: number;
  22957. colorFilter: Color3;
  22958. buffer: Uint8Array;
  22959. bufferWidth: number;
  22960. bufferHeight: number;
  22961. alphaFilter: number;
  22962. }): VertexData;
  22963. /**
  22964. * Creates the VertexData for a Plane
  22965. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22966. * * size sets the width and height of the plane to the value of size, optional default 1
  22967. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22968. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22969. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22970. * * 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)
  22971. * * 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)
  22972. * @returns the VertexData of the box
  22973. */
  22974. static CreatePlane(options: {
  22975. size?: number;
  22976. width?: number;
  22977. height?: number;
  22978. sideOrientation?: number;
  22979. frontUVs?: Vector4;
  22980. backUVs?: Vector4;
  22981. }): VertexData;
  22982. /**
  22983. * Creates the VertexData of the Disc or regular Polygon
  22984. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22985. * * radius the radius of the disc, optional default 0.5
  22986. * * tessellation the number of polygon sides, optional, default 64
  22987. * * 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
  22988. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22989. * * 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)
  22990. * * 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)
  22991. * @returns the VertexData of the box
  22992. */
  22993. static CreateDisc(options: {
  22994. radius?: number;
  22995. tessellation?: number;
  22996. arc?: number;
  22997. sideOrientation?: number;
  22998. frontUVs?: Vector4;
  22999. backUVs?: Vector4;
  23000. }): VertexData;
  23001. /**
  23002. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23003. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23004. * @param polygon a mesh built from polygonTriangulation.build()
  23005. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23006. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23007. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23008. * @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)
  23009. * @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)
  23010. * @returns the VertexData of the Polygon
  23011. */
  23012. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23013. /**
  23014. * Creates the VertexData of the IcoSphere
  23015. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23016. * * radius the radius of the IcoSphere, optional default 1
  23017. * * radiusX allows stretching in the x direction, optional, default radius
  23018. * * radiusY allows stretching in the y direction, optional, default radius
  23019. * * radiusZ allows stretching in the z direction, optional, default radius
  23020. * * flat when true creates a flat shaded mesh, optional, default true
  23021. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23022. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23023. * * 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)
  23024. * * 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)
  23025. * @returns the VertexData of the IcoSphere
  23026. */
  23027. static CreateIcoSphere(options: {
  23028. radius?: number;
  23029. radiusX?: number;
  23030. radiusY?: number;
  23031. radiusZ?: number;
  23032. flat?: boolean;
  23033. subdivisions?: number;
  23034. sideOrientation?: number;
  23035. frontUVs?: Vector4;
  23036. backUVs?: Vector4;
  23037. }): VertexData;
  23038. /**
  23039. * Creates the VertexData for a Polyhedron
  23040. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23041. * * type provided types are:
  23042. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23043. * * 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)
  23044. * * size the size of the IcoSphere, optional default 1
  23045. * * sizeX allows stretching in the x direction, optional, default size
  23046. * * sizeY allows stretching in the y direction, optional, default size
  23047. * * sizeZ allows stretching in the z direction, optional, default size
  23048. * * 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
  23049. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23050. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23051. * * flat when true creates a flat shaded mesh, optional, default true
  23052. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23053. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23054. * * 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)
  23055. * * 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)
  23056. * @returns the VertexData of the Polyhedron
  23057. */
  23058. static CreatePolyhedron(options: {
  23059. type?: number;
  23060. size?: number;
  23061. sizeX?: number;
  23062. sizeY?: number;
  23063. sizeZ?: number;
  23064. custom?: any;
  23065. faceUV?: Vector4[];
  23066. faceColors?: Color4[];
  23067. flat?: boolean;
  23068. sideOrientation?: number;
  23069. frontUVs?: Vector4;
  23070. backUVs?: Vector4;
  23071. }): VertexData;
  23072. /**
  23073. * Creates the VertexData for a TorusKnot
  23074. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23075. * * radius the radius of the torus knot, optional, default 2
  23076. * * tube the thickness of the tube, optional, default 0.5
  23077. * * radialSegments the number of sides on each tube segments, optional, default 32
  23078. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23079. * * p the number of windings around the z axis, optional, default 2
  23080. * * q the number of windings around the x axis, optional, default 3
  23081. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23082. * * 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)
  23083. * * 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)
  23084. * @returns the VertexData of the Torus Knot
  23085. */
  23086. static CreateTorusKnot(options: {
  23087. radius?: number;
  23088. tube?: number;
  23089. radialSegments?: number;
  23090. tubularSegments?: number;
  23091. p?: number;
  23092. q?: number;
  23093. sideOrientation?: number;
  23094. frontUVs?: Vector4;
  23095. backUVs?: Vector4;
  23096. }): VertexData;
  23097. /**
  23098. * Compute normals for given positions and indices
  23099. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23100. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23101. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23102. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23103. * * facetNormals : optional array of facet normals (vector3)
  23104. * * facetPositions : optional array of facet positions (vector3)
  23105. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23106. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23107. * * bInfo : optional bounding info, required for facetPartitioning computation
  23108. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23109. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23110. * * useRightHandedSystem: optional boolean to for right handed system computation
  23111. * * depthSort : optional boolean to enable the facet depth sort computation
  23112. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23113. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23114. */
  23115. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23116. facetNormals?: any;
  23117. facetPositions?: any;
  23118. facetPartitioning?: any;
  23119. ratio?: number;
  23120. bInfo?: any;
  23121. bbSize?: Vector3;
  23122. subDiv?: any;
  23123. useRightHandedSystem?: boolean;
  23124. depthSort?: boolean;
  23125. distanceTo?: Vector3;
  23126. depthSortedFacets?: any;
  23127. }): void;
  23128. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23129. /**
  23130. * Applies VertexData created from the imported parameters to the geometry
  23131. * @param parsedVertexData the parsed data from an imported file
  23132. * @param geometry the geometry to apply the VertexData to
  23133. */
  23134. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23135. }
  23136. }
  23137. declare module BABYLON {
  23138. /**
  23139. * Class containing static functions to help procedurally build meshes
  23140. */
  23141. export class DiscBuilder {
  23142. /**
  23143. * Creates a plane polygonal mesh. By default, this is a disc
  23144. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23145. * * 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
  23146. * * 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
  23147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23148. * * 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
  23149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23150. * @param name defines the name of the mesh
  23151. * @param options defines the options used to create the mesh
  23152. * @param scene defines the hosting scene
  23153. * @returns the plane polygonal mesh
  23154. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23155. */
  23156. static CreateDisc(name: string, options: {
  23157. radius?: number;
  23158. tessellation?: number;
  23159. arc?: number;
  23160. updatable?: boolean;
  23161. sideOrientation?: number;
  23162. frontUVs?: Vector4;
  23163. backUVs?: Vector4;
  23164. }, scene?: Nullable<Scene>): Mesh;
  23165. }
  23166. }
  23167. declare module BABYLON {
  23168. /**
  23169. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23170. *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.
  23171. * The SPS is also a particle system. It provides some methods to manage the particles.
  23172. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23173. *
  23174. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23175. */
  23176. export class SolidParticleSystem implements IDisposable {
  23177. /**
  23178. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23179. * Example : var p = SPS.particles[i];
  23180. */
  23181. particles: SolidParticle[];
  23182. /**
  23183. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23184. */
  23185. nbParticles: number;
  23186. /**
  23187. * If the particles must ever face the camera (default false). Useful for planar particles.
  23188. */
  23189. billboard: boolean;
  23190. /**
  23191. * Recompute normals when adding a shape
  23192. */
  23193. recomputeNormals: boolean;
  23194. /**
  23195. * This a counter ofr your own usage. It's not set by any SPS functions.
  23196. */
  23197. counter: number;
  23198. /**
  23199. * The SPS name. This name is also given to the underlying mesh.
  23200. */
  23201. name: string;
  23202. /**
  23203. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23204. */
  23205. mesh: Mesh;
  23206. /**
  23207. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23208. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23209. */
  23210. vars: any;
  23211. /**
  23212. * This array is populated when the SPS is set as 'pickable'.
  23213. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23214. * Each element of this array is an object `{idx: int, faceId: int}`.
  23215. * `idx` is the picked particle index in the `SPS.particles` array
  23216. * `faceId` is the picked face index counted within this particle.
  23217. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23218. */
  23219. pickedParticles: {
  23220. idx: number;
  23221. faceId: number;
  23222. }[];
  23223. /**
  23224. * This array is populated when `enableDepthSort` is set to true.
  23225. * Each element of this array is an instance of the class DepthSortedParticle.
  23226. */
  23227. depthSortedParticles: DepthSortedParticle[];
  23228. /**
  23229. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23230. * @hidden
  23231. */ bSphereOnly: boolean;
  23232. /**
  23233. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23234. * @hidden
  23235. */ bSphereRadiusFactor: number;
  23236. private _scene;
  23237. private _positions;
  23238. private _indices;
  23239. private _normals;
  23240. private _colors;
  23241. private _uvs;
  23242. private _indices32;
  23243. private _positions32;
  23244. private _normals32;
  23245. private _fixedNormal32;
  23246. private _colors32;
  23247. private _uvs32;
  23248. private _index;
  23249. private _updatable;
  23250. private _pickable;
  23251. private _isVisibilityBoxLocked;
  23252. private _alwaysVisible;
  23253. private _depthSort;
  23254. private _shapeCounter;
  23255. private _copy;
  23256. private _color;
  23257. private _computeParticleColor;
  23258. private _computeParticleTexture;
  23259. private _computeParticleRotation;
  23260. private _computeParticleVertex;
  23261. private _computeBoundingBox;
  23262. private _depthSortParticles;
  23263. private _camera;
  23264. private _mustUnrotateFixedNormals;
  23265. private _particlesIntersect;
  23266. private _needs32Bits;
  23267. /**
  23268. * Creates a SPS (Solid Particle System) object.
  23269. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23270. * @param scene (Scene) is the scene in which the SPS is added.
  23271. * @param options defines the options of the sps e.g.
  23272. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23273. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23274. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23275. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23276. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23277. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23278. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23279. */
  23280. constructor(name: string, scene: Scene, options?: {
  23281. updatable?: boolean;
  23282. isPickable?: boolean;
  23283. enableDepthSort?: boolean;
  23284. particleIntersection?: boolean;
  23285. boundingSphereOnly?: boolean;
  23286. bSphereRadiusFactor?: number;
  23287. });
  23288. /**
  23289. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23290. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23291. * @returns the created mesh
  23292. */
  23293. buildMesh(): Mesh;
  23294. /**
  23295. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23296. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23297. * Thus the particles generated from `digest()` have their property `position` set yet.
  23298. * @param mesh ( Mesh ) is the mesh to be digested
  23299. * @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
  23300. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23301. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23302. * @returns the current SPS
  23303. */
  23304. digest(mesh: Mesh, options?: {
  23305. facetNb?: number;
  23306. number?: number;
  23307. delta?: number;
  23308. }): SolidParticleSystem;
  23309. private _unrotateFixedNormals;
  23310. private _resetCopy;
  23311. private _meshBuilder;
  23312. private _posToShape;
  23313. private _uvsToShapeUV;
  23314. private _addParticle;
  23315. /**
  23316. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23317. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23318. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23319. * @param nb (positive integer) the number of particles to be created from this model
  23320. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23321. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23322. * @returns the number of shapes in the system
  23323. */
  23324. addShape(mesh: Mesh, nb: number, options?: {
  23325. positionFunction?: any;
  23326. vertexFunction?: any;
  23327. }): number;
  23328. private _rebuildParticle;
  23329. /**
  23330. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23331. * @returns the SPS.
  23332. */
  23333. rebuildMesh(): SolidParticleSystem;
  23334. /**
  23335. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23336. * This method calls `updateParticle()` for each particle of the SPS.
  23337. * For an animated SPS, it is usually called within the render loop.
  23338. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23339. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23340. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23341. * @returns the SPS.
  23342. */
  23343. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23344. /**
  23345. * Disposes the SPS.
  23346. */
  23347. dispose(): void;
  23348. /**
  23349. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23350. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23351. * @returns the SPS.
  23352. */
  23353. refreshVisibleSize(): SolidParticleSystem;
  23354. /**
  23355. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23356. * @param size the size (float) of the visibility box
  23357. * note : this doesn't lock the SPS mesh bounding box.
  23358. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23359. */
  23360. setVisibilityBox(size: number): void;
  23361. /**
  23362. * Gets whether the SPS as always visible or not
  23363. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23364. */
  23365. /**
  23366. * Sets the SPS as always visible or not
  23367. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23368. */
  23369. isAlwaysVisible: boolean;
  23370. /**
  23371. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23372. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23373. */
  23374. /**
  23375. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23376. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23377. */
  23378. isVisibilityBoxLocked: boolean;
  23379. /**
  23380. * Tells to `setParticles()` to compute the particle rotations or not.
  23381. * Default value : true. The SPS is faster when it's set to false.
  23382. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23383. */
  23384. /**
  23385. * Gets if `setParticles()` computes the particle rotations or not.
  23386. * Default value : true. The SPS is faster when it's set to false.
  23387. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23388. */
  23389. computeParticleRotation: boolean;
  23390. /**
  23391. * Tells to `setParticles()` to compute the particle colors or not.
  23392. * Default value : true. The SPS is faster when it's set to false.
  23393. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23394. */
  23395. /**
  23396. * Gets if `setParticles()` computes the particle colors or not.
  23397. * Default value : true. The SPS is faster when it's set to false.
  23398. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23399. */
  23400. computeParticleColor: boolean;
  23401. /**
  23402. * Gets if `setParticles()` computes the particle textures or not.
  23403. * Default value : true. The SPS is faster when it's set to false.
  23404. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23405. */
  23406. computeParticleTexture: boolean;
  23407. /**
  23408. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23409. * Default value : false. The SPS is faster when it's set to false.
  23410. * Note : the particle custom vertex positions aren't stored values.
  23411. */
  23412. /**
  23413. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23414. * Default value : false. The SPS is faster when it's set to false.
  23415. * Note : the particle custom vertex positions aren't stored values.
  23416. */
  23417. computeParticleVertex: boolean;
  23418. /**
  23419. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23420. */
  23421. /**
  23422. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23423. */
  23424. computeBoundingBox: boolean;
  23425. /**
  23426. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23427. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23428. * Default : `true`
  23429. */
  23430. /**
  23431. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23432. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23433. * Default : `true`
  23434. */
  23435. depthSortParticles: boolean;
  23436. /**
  23437. * This function does nothing. It may be overwritten to set all the particle first values.
  23438. * The SPS doesn't call this function, you may have to call it by your own.
  23439. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23440. */
  23441. initParticles(): void;
  23442. /**
  23443. * This function does nothing. It may be overwritten to recycle a particle.
  23444. * The SPS doesn't call this function, you may have to call it by your own.
  23445. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23446. * @param particle The particle to recycle
  23447. * @returns the recycled particle
  23448. */
  23449. recycleParticle(particle: SolidParticle): SolidParticle;
  23450. /**
  23451. * Updates a particle : this function should be overwritten by the user.
  23452. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23453. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23454. * @example : just set a particle position or velocity and recycle conditions
  23455. * @param particle The particle to update
  23456. * @returns the updated particle
  23457. */
  23458. updateParticle(particle: SolidParticle): SolidParticle;
  23459. /**
  23460. * Updates a vertex of a particle : it can be overwritten by the user.
  23461. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23462. * @param particle the current particle
  23463. * @param vertex the current index of the current particle
  23464. * @param pt the index of the current vertex in the particle shape
  23465. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23466. * @example : just set a vertex particle position
  23467. * @returns the updated vertex
  23468. */
  23469. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23470. /**
  23471. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23472. * This does nothing and may be overwritten by the user.
  23473. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23474. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23475. * @param update the boolean update value actually passed to setParticles()
  23476. */
  23477. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23478. /**
  23479. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23480. * This will be passed three parameters.
  23481. * This does nothing and may be overwritten by the user.
  23482. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23483. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23484. * @param update the boolean update value actually passed to setParticles()
  23485. */
  23486. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23487. }
  23488. }
  23489. declare module BABYLON {
  23490. /**
  23491. * Represents one particle of a solid particle system.
  23492. */
  23493. export class SolidParticle {
  23494. /**
  23495. * particle global index
  23496. */
  23497. idx: number;
  23498. /**
  23499. * The color of the particle
  23500. */
  23501. color: Nullable<Color4>;
  23502. /**
  23503. * The world space position of the particle.
  23504. */
  23505. position: Vector3;
  23506. /**
  23507. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23508. */
  23509. rotation: Vector3;
  23510. /**
  23511. * The world space rotation quaternion of the particle.
  23512. */
  23513. rotationQuaternion: Nullable<Quaternion>;
  23514. /**
  23515. * The scaling of the particle.
  23516. */
  23517. scaling: Vector3;
  23518. /**
  23519. * The uvs of the particle.
  23520. */
  23521. uvs: Vector4;
  23522. /**
  23523. * The current speed of the particle.
  23524. */
  23525. velocity: Vector3;
  23526. /**
  23527. * The pivot point in the particle local space.
  23528. */
  23529. pivot: Vector3;
  23530. /**
  23531. * Must the particle be translated from its pivot point in its local space ?
  23532. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23533. * Default : false
  23534. */
  23535. translateFromPivot: boolean;
  23536. /**
  23537. * Is the particle active or not ?
  23538. */
  23539. alive: boolean;
  23540. /**
  23541. * Is the particle visible or not ?
  23542. */
  23543. isVisible: boolean;
  23544. /**
  23545. * Index of this particle in the global "positions" array (Internal use)
  23546. * @hidden
  23547. */ pos: number;
  23548. /**
  23549. * @hidden Index of this particle in the global "indices" array (Internal use)
  23550. */ ind: number;
  23551. /**
  23552. * @hidden ModelShape of this particle (Internal use)
  23553. */ model: ModelShape;
  23554. /**
  23555. * ModelShape id of this particle
  23556. */
  23557. shapeId: number;
  23558. /**
  23559. * Index of the particle in its shape id (Internal use)
  23560. */
  23561. idxInShape: number;
  23562. /**
  23563. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23564. */ modelBoundingInfo: BoundingInfo;
  23565. /**
  23566. * @hidden Particle BoundingInfo object (Internal use)
  23567. */ boundingInfo: BoundingInfo;
  23568. /**
  23569. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23570. */ sps: SolidParticleSystem;
  23571. /**
  23572. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23573. */ stillInvisible: boolean;
  23574. /**
  23575. * @hidden Last computed particle rotation matrix
  23576. */ rotationMatrix: number[];
  23577. /**
  23578. * Parent particle Id, if any.
  23579. * Default null.
  23580. */
  23581. parentId: Nullable<number>;
  23582. /**
  23583. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23584. * The possible values are :
  23585. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23586. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23587. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23588. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23589. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23590. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23591. * */
  23592. cullingStrategy: number;
  23593. /**
  23594. * @hidden Internal global position in the SPS.
  23595. */ globalPosition: Vector3;
  23596. /**
  23597. * Creates a Solid Particle object.
  23598. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23599. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23600. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23601. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23602. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23603. * @param shapeId (integer) is the model shape identifier in the SPS.
  23604. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23605. * @param sps defines the sps it is associated to
  23606. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23607. */
  23608. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23609. /**
  23610. * Legacy support, changed scale to scaling
  23611. */
  23612. /**
  23613. * Legacy support, changed scale to scaling
  23614. */
  23615. scale: Vector3;
  23616. /**
  23617. * Legacy support, changed quaternion to rotationQuaternion
  23618. */
  23619. /**
  23620. * Legacy support, changed quaternion to rotationQuaternion
  23621. */
  23622. quaternion: Nullable<Quaternion>;
  23623. /**
  23624. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23625. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23626. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23627. * @returns true if it intersects
  23628. */
  23629. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23630. /**
  23631. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23632. * A particle is in the frustum if its bounding box intersects the frustum
  23633. * @param frustumPlanes defines the frustum to test
  23634. * @returns true if the particle is in the frustum planes
  23635. */
  23636. isInFrustum(frustumPlanes: Plane[]): boolean;
  23637. /**
  23638. * get the rotation matrix of the particle
  23639. * @hidden
  23640. */
  23641. getRotationMatrix(m: Matrix): void;
  23642. }
  23643. /**
  23644. * Represents the shape of the model used by one particle of a solid particle system.
  23645. * SPS internal tool, don't use it manually.
  23646. */
  23647. export class ModelShape {
  23648. /**
  23649. * The shape id
  23650. * @hidden
  23651. */
  23652. shapeID: number;
  23653. /**
  23654. * flat array of model positions (internal use)
  23655. * @hidden
  23656. */ shape: Vector3[];
  23657. /**
  23658. * flat array of model UVs (internal use)
  23659. * @hidden
  23660. */ shapeUV: number[];
  23661. /**
  23662. * length of the shape in the model indices array (internal use)
  23663. * @hidden
  23664. */ indicesLength: number;
  23665. /**
  23666. * Custom position function (internal use)
  23667. * @hidden
  23668. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23669. /**
  23670. * Custom vertex function (internal use)
  23671. * @hidden
  23672. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23673. /**
  23674. * 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.
  23675. * SPS internal tool, don't use it manually.
  23676. * @hidden
  23677. */
  23678. 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>);
  23679. }
  23680. /**
  23681. * Represents a Depth Sorted Particle in the solid particle system.
  23682. */
  23683. export class DepthSortedParticle {
  23684. /**
  23685. * Index of the particle in the "indices" array
  23686. */
  23687. ind: number;
  23688. /**
  23689. * Length of the particle shape in the "indices" array
  23690. */
  23691. indicesLength: number;
  23692. /**
  23693. * Squared distance from the particle to the camera
  23694. */
  23695. sqDistance: number;
  23696. }
  23697. }
  23698. declare module BABYLON {
  23699. /**
  23700. * Class used to store all common mesh properties
  23701. */
  23702. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23703. /** No occlusion */
  23704. static OCCLUSION_TYPE_NONE: number;
  23705. /** Occlusion set to optimisitic */
  23706. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23707. /** Occlusion set to strict */
  23708. static OCCLUSION_TYPE_STRICT: number;
  23709. /** Use an accurante occlusion algorithm */
  23710. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23711. /** Use a conservative occlusion algorithm */
  23712. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23713. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23714. * Test order :
  23715. * Is the bounding sphere outside the frustum ?
  23716. * If not, are the bounding box vertices outside the frustum ?
  23717. * It not, then the cullable object is in the frustum.
  23718. */
  23719. static readonly CULLINGSTRATEGY_STANDARD: number;
  23720. /** Culling strategy : Bounding Sphere Only.
  23721. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23722. * It's also less accurate than the standard because some not visible objects can still be selected.
  23723. * Test : is the bounding sphere outside the frustum ?
  23724. * If not, then the cullable object is in the frustum.
  23725. */
  23726. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23727. /** Culling strategy : Optimistic Inclusion.
  23728. * This in an inclusion test first, then the standard exclusion test.
  23729. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23730. * 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.
  23731. * Anyway, it's as accurate as the standard strategy.
  23732. * Test :
  23733. * Is the cullable object bounding sphere center in the frustum ?
  23734. * If not, apply the default culling strategy.
  23735. */
  23736. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23737. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23738. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23739. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23740. * 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.
  23741. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23742. * Test :
  23743. * Is the cullable object bounding sphere center in the frustum ?
  23744. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23745. */
  23746. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23747. /**
  23748. * No billboard
  23749. */
  23750. static readonly BILLBOARDMODE_NONE: number;
  23751. /** Billboard on X axis */
  23752. static readonly BILLBOARDMODE_X: number;
  23753. /** Billboard on Y axis */
  23754. static readonly BILLBOARDMODE_Y: number;
  23755. /** Billboard on Z axis */
  23756. static readonly BILLBOARDMODE_Z: number;
  23757. /** Billboard on all axes */
  23758. static readonly BILLBOARDMODE_ALL: number;
  23759. private _facetData;
  23760. /**
  23761. * The culling strategy to use to check whether the mesh must be rendered or not.
  23762. * This value can be changed at any time and will be used on the next render mesh selection.
  23763. * The possible values are :
  23764. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23765. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23766. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23767. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23768. * Please read each static variable documentation to get details about the culling process.
  23769. * */
  23770. cullingStrategy: number;
  23771. /**
  23772. * Gets the number of facets in the mesh
  23773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23774. */
  23775. readonly facetNb: number;
  23776. /**
  23777. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23779. */
  23780. partitioningSubdivisions: number;
  23781. /**
  23782. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23783. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23785. */
  23786. partitioningBBoxRatio: number;
  23787. /**
  23788. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23789. * Works only for updatable meshes.
  23790. * Doesn't work with multi-materials
  23791. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23792. */
  23793. mustDepthSortFacets: boolean;
  23794. /**
  23795. * The location (Vector3) where the facet depth sort must be computed from.
  23796. * By default, the active camera position.
  23797. * Used only when facet depth sort is enabled
  23798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23799. */
  23800. facetDepthSortFrom: Vector3;
  23801. /**
  23802. * gets a boolean indicating if facetData is enabled
  23803. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23804. */
  23805. readonly isFacetDataEnabled: boolean;
  23806. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  23807. /**
  23808. * An event triggered when this mesh collides with another one
  23809. */
  23810. onCollideObservable: Observable<AbstractMesh>;
  23811. private _onCollideObserver;
  23812. /** Set a function to call when this mesh collides with another one */
  23813. onCollide: () => void;
  23814. /**
  23815. * An event triggered when the collision's position changes
  23816. */
  23817. onCollisionPositionChangeObservable: Observable<Vector3>;
  23818. private _onCollisionPositionChangeObserver;
  23819. /** Set a function to call when the collision's position changes */
  23820. onCollisionPositionChange: () => void;
  23821. /**
  23822. * An event triggered when material is changed
  23823. */
  23824. onMaterialChangedObservable: Observable<AbstractMesh>;
  23825. /**
  23826. * Gets or sets the orientation for POV movement & rotation
  23827. */
  23828. definedFacingForward: boolean;
  23829. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  23830. private _visibility;
  23831. /** @hidden */ isActive: boolean;
  23832. /** @hidden */ renderingGroup: Nullable<RenderingGroup>;
  23833. /**
  23834. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23835. */
  23836. /**
  23837. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23838. */
  23839. visibility: number;
  23840. /** Gets or sets the alpha index used to sort transparent meshes
  23841. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23842. */
  23843. alphaIndex: number;
  23844. /**
  23845. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23846. */
  23847. isVisible: boolean;
  23848. /**
  23849. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23850. */
  23851. isPickable: boolean;
  23852. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23853. showSubMeshesBoundingBox: boolean;
  23854. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23855. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23856. */
  23857. isBlocker: boolean;
  23858. /**
  23859. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23860. */
  23861. enablePointerMoveEvents: boolean;
  23862. /**
  23863. * Specifies the rendering group id for this mesh (0 by default)
  23864. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23865. */
  23866. renderingGroupId: number;
  23867. private _material;
  23868. /** Gets or sets current material */
  23869. material: Nullable<Material>;
  23870. private _receiveShadows;
  23871. /**
  23872. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23873. * @see http://doc.babylonjs.com/babylon101/shadows
  23874. */
  23875. receiveShadows: boolean;
  23876. /** Defines color to use when rendering outline */
  23877. outlineColor: Color3;
  23878. /** Define width to use when rendering outline */
  23879. outlineWidth: number;
  23880. /** Defines color to use when rendering overlay */
  23881. overlayColor: Color3;
  23882. /** Defines alpha to use when rendering overlay */
  23883. overlayAlpha: number;
  23884. private _hasVertexAlpha;
  23885. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23886. hasVertexAlpha: boolean;
  23887. private _useVertexColors;
  23888. /** 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) */
  23889. useVertexColors: boolean;
  23890. private _computeBonesUsingShaders;
  23891. /**
  23892. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23893. */
  23894. computeBonesUsingShaders: boolean;
  23895. private _numBoneInfluencers;
  23896. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23897. numBoneInfluencers: number;
  23898. private _applyFog;
  23899. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23900. applyFog: boolean;
  23901. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23902. useOctreeForRenderingSelection: boolean;
  23903. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23904. useOctreeForPicking: boolean;
  23905. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23906. useOctreeForCollisions: boolean;
  23907. private _layerMask;
  23908. /**
  23909. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23910. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23911. */
  23912. layerMask: number;
  23913. /**
  23914. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23915. */
  23916. alwaysSelectAsActiveMesh: boolean;
  23917. /**
  23918. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  23919. */
  23920. doNotSyncBoundingInfo: boolean;
  23921. /**
  23922. * Gets or sets the current action manager
  23923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23924. */
  23925. actionManager: Nullable<AbstractActionManager>;
  23926. private _checkCollisions;
  23927. private _collisionMask;
  23928. private _collisionGroup;
  23929. /**
  23930. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23931. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23932. */
  23933. ellipsoid: Vector3;
  23934. /**
  23935. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23936. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23937. */
  23938. ellipsoidOffset: Vector3;
  23939. private _collider;
  23940. private _oldPositionForCollisions;
  23941. private _diffPositionForCollisions;
  23942. /**
  23943. * Gets or sets a collision mask used to mask collisions (default is -1).
  23944. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23945. */
  23946. collisionMask: number;
  23947. /**
  23948. * Gets or sets the current collision group mask (-1 by default).
  23949. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23950. */
  23951. collisionGroup: number;
  23952. /**
  23953. * Defines edge width used when edgesRenderer is enabled
  23954. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23955. */
  23956. edgesWidth: number;
  23957. /**
  23958. * Defines edge color used when edgesRenderer is enabled
  23959. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23960. */
  23961. edgesColor: Color4;
  23962. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  23963. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  23964. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  23965. /** @hidden */ renderId: number;
  23966. /**
  23967. * Gets or sets the list of subMeshes
  23968. * @see http://doc.babylonjs.com/how_to/multi_materials
  23969. */
  23970. subMeshes: SubMesh[];
  23971. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  23972. /** @hidden */ unIndexed: boolean;
  23973. /** @hidden */ lightSources: Light[];
  23974. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23975. /** @hidden */ waitingActions: Nullable<any>;
  23976. /** @hidden */ waitingFreezeWorldMatrix: Nullable<boolean>;
  23977. private _skeleton;
  23978. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  23979. /**
  23980. * Gets or sets a skeleton to apply skining transformations
  23981. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23982. */
  23983. skeleton: Nullable<Skeleton>;
  23984. /**
  23985. * An event triggered when the mesh is rebuilt.
  23986. */
  23987. onRebuildObservable: Observable<AbstractMesh>;
  23988. /**
  23989. * Creates a new AbstractMesh
  23990. * @param name defines the name of the mesh
  23991. * @param scene defines the hosting scene
  23992. */
  23993. constructor(name: string, scene?: Nullable<Scene>);
  23994. /**
  23995. * Returns the string "AbstractMesh"
  23996. * @returns "AbstractMesh"
  23997. */
  23998. getClassName(): string;
  23999. /**
  24000. * Gets a string representation of the current mesh
  24001. * @param fullDetails defines a boolean indicating if full details must be included
  24002. * @returns a string representation of the current mesh
  24003. */
  24004. toString(fullDetails?: boolean): string;
  24005. /**
  24006. * @hidden
  24007. */
  24008. protected _getEffectiveParent(): Nullable<Node>;
  24009. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24010. /** @hidden */ rebuild(): void;
  24011. /** @hidden */ resyncLightSources(): void;
  24012. /** @hidden */ resyncLighSource(light: Light): void;
  24013. /** @hidden */ unBindEffect(): void;
  24014. /** @hidden */ removeLightSource(light: Light): void;
  24015. private _markSubMeshesAsDirty;
  24016. /** @hidden */ markSubMeshesAsLightDirty(): void;
  24017. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  24018. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  24019. /**
  24020. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24021. */
  24022. scaling: Vector3;
  24023. /**
  24024. * Returns true if the mesh is blocked. Implemented by child classes
  24025. */
  24026. readonly isBlocked: boolean;
  24027. /**
  24028. * Returns the mesh itself by default. Implemented by child classes
  24029. * @param camera defines the camera to use to pick the right LOD level
  24030. * @returns the currentAbstractMesh
  24031. */
  24032. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24033. /**
  24034. * Returns 0 by default. Implemented by child classes
  24035. * @returns an integer
  24036. */
  24037. getTotalVertices(): number;
  24038. /**
  24039. * Returns a positive integer : the total number of indices in this mesh geometry.
  24040. * @returns the numner of indices or zero if the mesh has no geometry.
  24041. */
  24042. getTotalIndices(): number;
  24043. /**
  24044. * Returns null by default. Implemented by child classes
  24045. * @returns null
  24046. */
  24047. getIndices(): Nullable<IndicesArray>;
  24048. /**
  24049. * Returns the array of the requested vertex data kind. Implemented by child classes
  24050. * @param kind defines the vertex data kind to use
  24051. * @returns null
  24052. */
  24053. getVerticesData(kind: string): Nullable<FloatArray>;
  24054. /**
  24055. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24056. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24057. * Note that a new underlying VertexBuffer object is created each call.
  24058. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24059. * @param kind defines vertex data kind:
  24060. * * VertexBuffer.PositionKind
  24061. * * VertexBuffer.UVKind
  24062. * * VertexBuffer.UV2Kind
  24063. * * VertexBuffer.UV3Kind
  24064. * * VertexBuffer.UV4Kind
  24065. * * VertexBuffer.UV5Kind
  24066. * * VertexBuffer.UV6Kind
  24067. * * VertexBuffer.ColorKind
  24068. * * VertexBuffer.MatricesIndicesKind
  24069. * * VertexBuffer.MatricesIndicesExtraKind
  24070. * * VertexBuffer.MatricesWeightsKind
  24071. * * VertexBuffer.MatricesWeightsExtraKind
  24072. * @param data defines the data source
  24073. * @param updatable defines if the data must be flagged as updatable (or static)
  24074. * @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
  24075. * @returns the current mesh
  24076. */
  24077. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24078. /**
  24079. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24080. * If the mesh has no geometry, it is simply returned as it is.
  24081. * @param kind defines vertex data kind:
  24082. * * VertexBuffer.PositionKind
  24083. * * VertexBuffer.UVKind
  24084. * * VertexBuffer.UV2Kind
  24085. * * VertexBuffer.UV3Kind
  24086. * * VertexBuffer.UV4Kind
  24087. * * VertexBuffer.UV5Kind
  24088. * * VertexBuffer.UV6Kind
  24089. * * VertexBuffer.ColorKind
  24090. * * VertexBuffer.MatricesIndicesKind
  24091. * * VertexBuffer.MatricesIndicesExtraKind
  24092. * * VertexBuffer.MatricesWeightsKind
  24093. * * VertexBuffer.MatricesWeightsExtraKind
  24094. * @param data defines the data source
  24095. * @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
  24096. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24097. * @returns the current mesh
  24098. */
  24099. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24100. /**
  24101. * Sets the mesh indices,
  24102. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24103. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24104. * @param totalVertices Defines the total number of vertices
  24105. * @returns the current mesh
  24106. */
  24107. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24108. /**
  24109. * Gets a boolean indicating if specific vertex data is present
  24110. * @param kind defines the vertex data kind to use
  24111. * @returns true is data kind is present
  24112. */
  24113. isVerticesDataPresent(kind: string): boolean;
  24114. /**
  24115. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24116. * @returns a BoundingInfo
  24117. */
  24118. getBoundingInfo(): BoundingInfo;
  24119. /**
  24120. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24121. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24122. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24123. * @returns the current mesh
  24124. */
  24125. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24126. /**
  24127. * Overwrite the current bounding info
  24128. * @param boundingInfo defines the new bounding info
  24129. * @returns the current mesh
  24130. */
  24131. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24132. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24133. readonly useBones: boolean;
  24134. /** @hidden */ preActivate(): void;
  24135. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  24136. /** @hidden */ activate(renderId: number): boolean;
  24137. /** @hidden */ freeze(): void;
  24138. /** @hidden */ unFreeze(): void;
  24139. /**
  24140. * Gets the current world matrix
  24141. * @returns a Matrix
  24142. */
  24143. getWorldMatrix(): Matrix;
  24144. /** @hidden */ getWorldMatrixDeterminant(): number;
  24145. /**
  24146. * Perform relative position change from the point of view of behind the front of the mesh.
  24147. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24148. * Supports definition of mesh facing forward or backward
  24149. * @param amountRight defines the distance on the right axis
  24150. * @param amountUp defines the distance on the up axis
  24151. * @param amountForward defines the distance on the forward axis
  24152. * @returns the current mesh
  24153. */
  24154. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24155. /**
  24156. * Calculate relative position change from the point of view of behind the front of the mesh.
  24157. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24158. * Supports definition of mesh facing forward or backward
  24159. * @param amountRight defines the distance on the right axis
  24160. * @param amountUp defines the distance on the up axis
  24161. * @param amountForward defines the distance on the forward axis
  24162. * @returns the new displacement vector
  24163. */
  24164. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24165. /**
  24166. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24167. * Supports definition of mesh facing forward or backward
  24168. * @param flipBack defines the flip
  24169. * @param twirlClockwise defines the twirl
  24170. * @param tiltRight defines the tilt
  24171. * @returns the current mesh
  24172. */
  24173. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24174. /**
  24175. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24176. * Supports definition of mesh facing forward or backward.
  24177. * @param flipBack defines the flip
  24178. * @param twirlClockwise defines the twirl
  24179. * @param tiltRight defines the tilt
  24180. * @returns the new rotation vector
  24181. */
  24182. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24183. /**
  24184. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24185. * This means the mesh underlying bounding box and sphere are recomputed.
  24186. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24187. * @returns the current mesh
  24188. */
  24189. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24190. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24191. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24192. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  24193. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24194. /** @hidden */
  24195. protected _afterComputeWorldMatrix(): void;
  24196. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  24197. /**
  24198. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24199. * A mesh is in the frustum if its bounding box intersects the frustum
  24200. * @param frustumPlanes defines the frustum to test
  24201. * @returns true if the mesh is in the frustum planes
  24202. */
  24203. isInFrustum(frustumPlanes: Plane[]): boolean;
  24204. /**
  24205. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24206. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24207. * @param frustumPlanes defines the frustum to test
  24208. * @returns true if the mesh is completely in the frustum planes
  24209. */
  24210. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24211. /**
  24212. * True if the mesh intersects another mesh or a SolidParticle object
  24213. * @param mesh defines a target mesh or SolidParticle to test
  24214. * @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)
  24215. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24216. * @returns true if there is an intersection
  24217. */
  24218. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24219. /**
  24220. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24221. * @param point defines the point to test
  24222. * @returns true if there is an intersection
  24223. */
  24224. intersectsPoint(point: Vector3): boolean;
  24225. /**
  24226. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24227. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24228. */
  24229. checkCollisions: boolean;
  24230. /**
  24231. * Gets Collider object used to compute collisions (not physics)
  24232. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24233. */
  24234. readonly collider: Nullable<Collider>;
  24235. /**
  24236. * Move the mesh using collision engine
  24237. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24238. * @param displacement defines the requested displacement vector
  24239. * @returns the current mesh
  24240. */
  24241. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24242. private _onCollisionPositionChange;
  24243. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24244. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24245. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  24246. /** @hidden */ generatePointsArray(): boolean;
  24247. /**
  24248. * Checks if the passed Ray intersects with the mesh
  24249. * @param ray defines the ray to use
  24250. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24251. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24252. * @returns the picking info
  24253. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24254. */
  24255. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24256. /**
  24257. * Clones the current mesh
  24258. * @param name defines the mesh name
  24259. * @param newParent defines the new mesh parent
  24260. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24261. * @returns the new mesh
  24262. */
  24263. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24264. /**
  24265. * Disposes all the submeshes of the current meshnp
  24266. * @returns the current mesh
  24267. */
  24268. releaseSubMeshes(): AbstractMesh;
  24269. /**
  24270. * Releases resources associated with this abstract mesh.
  24271. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24272. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24273. */
  24274. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24275. /**
  24276. * Adds the passed mesh as a child to the current mesh
  24277. * @param mesh defines the child mesh
  24278. * @returns the current mesh
  24279. */
  24280. addChild(mesh: AbstractMesh): AbstractMesh;
  24281. /**
  24282. * Removes the passed mesh from the current mesh children list
  24283. * @param mesh defines the child mesh
  24284. * @returns the current mesh
  24285. */
  24286. removeChild(mesh: AbstractMesh): AbstractMesh;
  24287. /** @hidden */
  24288. private _initFacetData;
  24289. /**
  24290. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24291. * This method can be called within the render loop.
  24292. * 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
  24293. * @returns the current mesh
  24294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24295. */
  24296. updateFacetData(): AbstractMesh;
  24297. /**
  24298. * Returns the facetLocalNormals array.
  24299. * The normals are expressed in the mesh local spac
  24300. * @returns an array of Vector3
  24301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24302. */
  24303. getFacetLocalNormals(): Vector3[];
  24304. /**
  24305. * Returns the facetLocalPositions array.
  24306. * The facet positions are expressed in the mesh local space
  24307. * @returns an array of Vector3
  24308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24309. */
  24310. getFacetLocalPositions(): Vector3[];
  24311. /**
  24312. * Returns the facetLocalPartioning array
  24313. * @returns an array of array of numbers
  24314. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24315. */
  24316. getFacetLocalPartitioning(): number[][];
  24317. /**
  24318. * Returns the i-th facet position in the world system.
  24319. * This method allocates a new Vector3 per call
  24320. * @param i defines the facet index
  24321. * @returns a new Vector3
  24322. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24323. */
  24324. getFacetPosition(i: number): Vector3;
  24325. /**
  24326. * Sets the reference Vector3 with the i-th facet position in the world system
  24327. * @param i defines the facet index
  24328. * @param ref defines the target vector
  24329. * @returns the current mesh
  24330. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24331. */
  24332. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24333. /**
  24334. * Returns the i-th facet normal in the world system.
  24335. * This method allocates a new Vector3 per call
  24336. * @param i defines the facet index
  24337. * @returns a new Vector3
  24338. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24339. */
  24340. getFacetNormal(i: number): Vector3;
  24341. /**
  24342. * Sets the reference Vector3 with the i-th facet normal in the world system
  24343. * @param i defines the facet index
  24344. * @param ref defines the target vector
  24345. * @returns the current mesh
  24346. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24347. */
  24348. getFacetNormalToRef(i: number, ref: Vector3): this;
  24349. /**
  24350. * 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)
  24351. * @param x defines x coordinate
  24352. * @param y defines y coordinate
  24353. * @param z defines z coordinate
  24354. * @returns the array of facet indexes
  24355. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24356. */
  24357. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24358. /**
  24359. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24360. * @param projected sets as the (x,y,z) world projection on the facet
  24361. * @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
  24362. * @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
  24363. * @param x defines x coordinate
  24364. * @param y defines y coordinate
  24365. * @param z defines z coordinate
  24366. * @returns the face index if found (or null instead)
  24367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24368. */
  24369. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24370. /**
  24371. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24372. * @param projected sets as the (x,y,z) local projection on the facet
  24373. * @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
  24374. * @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
  24375. * @param x defines x coordinate
  24376. * @param y defines y coordinate
  24377. * @param z defines z coordinate
  24378. * @returns the face index if found (or null instead)
  24379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24380. */
  24381. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24382. /**
  24383. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24384. * @returns the parameters
  24385. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24386. */
  24387. getFacetDataParameters(): any;
  24388. /**
  24389. * Disables the feature FacetData and frees the related memory
  24390. * @returns the current mesh
  24391. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24392. */
  24393. disableFacetData(): AbstractMesh;
  24394. /**
  24395. * Updates the AbstractMesh indices array
  24396. * @param indices defines the data source
  24397. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24398. * @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)
  24399. * @returns the current mesh
  24400. */
  24401. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24402. /**
  24403. * Creates new normals data for the mesh
  24404. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24405. * @returns the current mesh
  24406. */
  24407. createNormals(updatable: boolean): AbstractMesh;
  24408. /**
  24409. * Align the mesh with a normal
  24410. * @param normal defines the normal to use
  24411. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24412. * @returns the current mesh
  24413. */
  24414. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24415. /** @hidden */ checkOcclusionQuery(): boolean;
  24416. }
  24417. }
  24418. declare module BABYLON {
  24419. /**
  24420. * Interface used to define ActionEvent
  24421. */
  24422. export interface IActionEvent {
  24423. /** The mesh or sprite that triggered the action */
  24424. source: any;
  24425. /** The X mouse cursor position at the time of the event */
  24426. pointerX: number;
  24427. /** The Y mouse cursor position at the time of the event */
  24428. pointerY: number;
  24429. /** The mesh that is currently pointed at (can be null) */
  24430. meshUnderPointer: Nullable<AbstractMesh>;
  24431. /** the original (browser) event that triggered the ActionEvent */
  24432. sourceEvent?: any;
  24433. /** additional data for the event */
  24434. additionalData?: any;
  24435. }
  24436. /**
  24437. * ActionEvent is the event being sent when an action is triggered.
  24438. */
  24439. export class ActionEvent implements IActionEvent {
  24440. /** The mesh or sprite that triggered the action */
  24441. source: any;
  24442. /** The X mouse cursor position at the time of the event */
  24443. pointerX: number;
  24444. /** The Y mouse cursor position at the time of the event */
  24445. pointerY: number;
  24446. /** The mesh that is currently pointed at (can be null) */
  24447. meshUnderPointer: Nullable<AbstractMesh>;
  24448. /** the original (browser) event that triggered the ActionEvent */
  24449. sourceEvent?: any;
  24450. /** additional data for the event */
  24451. additionalData?: any;
  24452. /**
  24453. * Creates a new ActionEvent
  24454. * @param source The mesh or sprite that triggered the action
  24455. * @param pointerX The X mouse cursor position at the time of the event
  24456. * @param pointerY The Y mouse cursor position at the time of the event
  24457. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24458. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24459. * @param additionalData additional data for the event
  24460. */
  24461. constructor(
  24462. /** The mesh or sprite that triggered the action */
  24463. source: any,
  24464. /** The X mouse cursor position at the time of the event */
  24465. pointerX: number,
  24466. /** The Y mouse cursor position at the time of the event */
  24467. pointerY: number,
  24468. /** The mesh that is currently pointed at (can be null) */
  24469. meshUnderPointer: Nullable<AbstractMesh>,
  24470. /** the original (browser) event that triggered the ActionEvent */
  24471. sourceEvent?: any,
  24472. /** additional data for the event */
  24473. additionalData?: any);
  24474. /**
  24475. * Helper function to auto-create an ActionEvent from a source mesh.
  24476. * @param source The source mesh that triggered the event
  24477. * @param evt The original (browser) event
  24478. * @param additionalData additional data for the event
  24479. * @returns the new ActionEvent
  24480. */
  24481. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24482. /**
  24483. * Helper function to auto-create an ActionEvent from a source sprite
  24484. * @param source The source sprite that triggered the event
  24485. * @param scene Scene associated with the sprite
  24486. * @param evt The original (browser) event
  24487. * @param additionalData additional data for the event
  24488. * @returns the new ActionEvent
  24489. */
  24490. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24491. /**
  24492. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24493. * @param scene the scene where the event occurred
  24494. * @param evt The original (browser) event
  24495. * @returns the new ActionEvent
  24496. */
  24497. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24498. /**
  24499. * Helper function to auto-create an ActionEvent from a primitive
  24500. * @param prim defines the target primitive
  24501. * @param pointerPos defines the pointer position
  24502. * @param evt The original (browser) event
  24503. * @param additionalData additional data for the event
  24504. * @returns the new ActionEvent
  24505. */
  24506. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24507. }
  24508. }
  24509. declare module BABYLON {
  24510. /**
  24511. * Abstract class used to decouple action Manager from scene and meshes.
  24512. * Do not instantiate.
  24513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24514. */
  24515. export abstract class AbstractActionManager implements IDisposable {
  24516. /** Gets the list of active triggers */
  24517. static Triggers: {
  24518. [key: string]: number;
  24519. };
  24520. /** Gets the cursor to use when hovering items */
  24521. hoverCursor: string;
  24522. /** Gets the list of actions */
  24523. actions: IAction[];
  24524. /**
  24525. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24526. */
  24527. isRecursive: boolean;
  24528. /**
  24529. * Releases all associated resources
  24530. */
  24531. abstract dispose(): void;
  24532. /**
  24533. * Does this action manager has pointer triggers
  24534. */
  24535. abstract readonly hasPointerTriggers: boolean;
  24536. /**
  24537. * Does this action manager has pick triggers
  24538. */
  24539. abstract readonly hasPickTriggers: boolean;
  24540. /**
  24541. * Process a specific trigger
  24542. * @param trigger defines the trigger to process
  24543. * @param evt defines the event details to be processed
  24544. */
  24545. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24546. /**
  24547. * Does this action manager handles actions of any of the given triggers
  24548. * @param triggers defines the triggers to be tested
  24549. * @return a boolean indicating whether one (or more) of the triggers is handled
  24550. */
  24551. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24552. /**
  24553. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24554. * speed.
  24555. * @param triggerA defines the trigger to be tested
  24556. * @param triggerB defines the trigger to be tested
  24557. * @return a boolean indicating whether one (or more) of the triggers is handled
  24558. */
  24559. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24560. /**
  24561. * Does this action manager handles actions of a given trigger
  24562. * @param trigger defines the trigger to be tested
  24563. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24564. * @return whether the trigger is handled
  24565. */
  24566. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24567. /**
  24568. * Serialize this manager to a JSON object
  24569. * @param name defines the property name to store this manager
  24570. * @returns a JSON representation of this manager
  24571. */
  24572. abstract serialize(name: string): any;
  24573. /**
  24574. * Registers an action to this action manager
  24575. * @param action defines the action to be registered
  24576. * @return the action amended (prepared) after registration
  24577. */
  24578. abstract registerAction(action: IAction): Nullable<IAction>;
  24579. /**
  24580. * Unregisters an action to this action manager
  24581. * @param action defines the action to be unregistered
  24582. * @return a boolean indicating whether the action has been unregistered
  24583. */
  24584. abstract unregisterAction(action: IAction): Boolean;
  24585. /**
  24586. * Does exist one action manager with at least one trigger
  24587. **/
  24588. static readonly HasTriggers: boolean;
  24589. /**
  24590. * Does exist one action manager with at least one pick trigger
  24591. **/
  24592. static readonly HasPickTriggers: boolean;
  24593. /**
  24594. * Does exist one action manager that handles actions of a given trigger
  24595. * @param trigger defines the trigger to be tested
  24596. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24597. **/
  24598. static HasSpecificTrigger(trigger: number): boolean;
  24599. }
  24600. }
  24601. declare module BABYLON {
  24602. /**
  24603. * Defines how a node can be built from a string name.
  24604. */
  24605. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24606. /**
  24607. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24608. */
  24609. export class Node implements IBehaviorAware<Node> {
  24610. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24611. private static _NodeConstructors;
  24612. /**
  24613. * Add a new node constructor
  24614. * @param type defines the type name of the node to construct
  24615. * @param constructorFunc defines the constructor function
  24616. */
  24617. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24618. /**
  24619. * Returns a node constructor based on type name
  24620. * @param type defines the type name
  24621. * @param name defines the new node name
  24622. * @param scene defines the hosting scene
  24623. * @param options defines optional options to transmit to constructors
  24624. * @returns the new constructor or null
  24625. */
  24626. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24627. /**
  24628. * Gets or sets the name of the node
  24629. */
  24630. name: string;
  24631. /**
  24632. * Gets or sets the id of the node
  24633. */
  24634. id: string;
  24635. /**
  24636. * Gets or sets the unique id of the node
  24637. */
  24638. uniqueId: number;
  24639. /**
  24640. * Gets or sets a string used to store user defined state for the node
  24641. */
  24642. state: string;
  24643. /**
  24644. * Gets or sets an object used to store user defined information for the node
  24645. */
  24646. metadata: any;
  24647. /**
  24648. * For internal use only. Please do not use.
  24649. */
  24650. reservedDataStore: any;
  24651. /**
  24652. * List of inspectable custom properties (used by the Inspector)
  24653. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24654. */
  24655. inspectableCustomProperties: IInspectable[];
  24656. /**
  24657. * Gets or sets a boolean used to define if the node must be serialized
  24658. */
  24659. doNotSerialize: boolean;
  24660. /** @hidden */ isDisposed: boolean;
  24661. /**
  24662. * Gets a list of Animations associated with the node
  24663. */
  24664. animations: Animation[];
  24665. protected _ranges: {
  24666. [name: string]: Nullable<AnimationRange>;
  24667. };
  24668. /**
  24669. * Callback raised when the node is ready to be used
  24670. */
  24671. onReady: Nullable<(node: Node) => void>;
  24672. private _isEnabled;
  24673. private _isParentEnabled;
  24674. private _isReady;
  24675. /** @hidden */ currentRenderId: number;
  24676. private _parentUpdateId;
  24677. /** @hidden */ childUpdateId: number;
  24678. /** @hidden */ waitingParentId: Nullable<string>;
  24679. /** @hidden */ scene: Scene;
  24680. /** @hidden */ cache: any;
  24681. private _parentNode;
  24682. private _children;
  24683. /** @hidden */ worldMatrix: Matrix;
  24684. /** @hidden */ worldMatrixDeterminant: number;
  24685. /** @hidden */ worldMatrixDeterminantIsDirty: boolean;
  24686. /** @hidden */
  24687. private _sceneRootNodesIndex;
  24688. /**
  24689. * Gets a boolean indicating if the node has been disposed
  24690. * @returns true if the node was disposed
  24691. */
  24692. isDisposed(): boolean;
  24693. /**
  24694. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24695. * @see https://doc.babylonjs.com/how_to/parenting
  24696. */
  24697. parent: Nullable<Node>;
  24698. private addToSceneRootNodes;
  24699. private removeFromSceneRootNodes;
  24700. private _animationPropertiesOverride;
  24701. /**
  24702. * Gets or sets the animation properties override
  24703. */
  24704. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24705. /**
  24706. * Gets a string idenfifying the name of the class
  24707. * @returns "Node" string
  24708. */
  24709. getClassName(): string;
  24710. /** @hidden */ protected readonly _isNode: boolean;
  24711. /**
  24712. * An event triggered when the mesh is disposed
  24713. */
  24714. onDisposeObservable: Observable<Node>;
  24715. private _onDisposeObserver;
  24716. /**
  24717. * Sets a callback that will be raised when the node will be disposed
  24718. */
  24719. onDispose: () => void;
  24720. /**
  24721. * Creates a new Node
  24722. * @param name the name and id to be given to this node
  24723. * @param scene the scene this node will be added to
  24724. * @param addToRootNodes the node will be added to scene.rootNodes
  24725. */
  24726. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24727. /**
  24728. * Gets the scene of the node
  24729. * @returns a scene
  24730. */
  24731. getScene(): Scene;
  24732. /**
  24733. * Gets the engine of the node
  24734. * @returns a Engine
  24735. */
  24736. getEngine(): Engine;
  24737. private _behaviors;
  24738. /**
  24739. * Attach a behavior to the node
  24740. * @see http://doc.babylonjs.com/features/behaviour
  24741. * @param behavior defines the behavior to attach
  24742. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24743. * @returns the current Node
  24744. */
  24745. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24746. /**
  24747. * Remove an attached behavior
  24748. * @see http://doc.babylonjs.com/features/behaviour
  24749. * @param behavior defines the behavior to attach
  24750. * @returns the current Node
  24751. */
  24752. removeBehavior(behavior: Behavior<Node>): Node;
  24753. /**
  24754. * Gets the list of attached behaviors
  24755. * @see http://doc.babylonjs.com/features/behaviour
  24756. */
  24757. readonly behaviors: Behavior<Node>[];
  24758. /**
  24759. * Gets an attached behavior by name
  24760. * @param name defines the name of the behavior to look for
  24761. * @see http://doc.babylonjs.com/features/behaviour
  24762. * @returns null if behavior was not found else the requested behavior
  24763. */
  24764. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24765. /**
  24766. * Returns the latest update of the World matrix
  24767. * @returns a Matrix
  24768. */
  24769. getWorldMatrix(): Matrix;
  24770. /** @hidden */ getWorldMatrixDeterminant(): number;
  24771. /**
  24772. * Returns directly the latest state of the mesh World matrix.
  24773. * A Matrix is returned.
  24774. */
  24775. readonly worldMatrixFromCache: Matrix;
  24776. /** @hidden */ initCache(): void;
  24777. /** @hidden */
  24778. updateCache(force?: boolean): void;
  24779. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24780. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  24781. /** @hidden */ isSynchronized(): boolean;
  24782. /** @hidden */ markSyncedWithParent(): void;
  24783. /** @hidden */
  24784. isSynchronizedWithParent(): boolean;
  24785. /** @hidden */
  24786. isSynchronized(): boolean;
  24787. /**
  24788. * Is this node ready to be used/rendered
  24789. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24790. * @return true if the node is ready
  24791. */
  24792. isReady(completeCheck?: boolean): boolean;
  24793. /**
  24794. * Is this node enabled?
  24795. * 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
  24796. * @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
  24797. * @return whether this node (and its parent) is enabled
  24798. */
  24799. isEnabled(checkAncestors?: boolean): boolean;
  24800. /** @hidden */
  24801. protected _syncParentEnabledState(): void;
  24802. /**
  24803. * Set the enabled state of this node
  24804. * @param value defines the new enabled state
  24805. */
  24806. setEnabled(value: boolean): void;
  24807. /**
  24808. * Is this node a descendant of the given node?
  24809. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24810. * @param ancestor defines the parent node to inspect
  24811. * @returns a boolean indicating if this node is a descendant of the given node
  24812. */
  24813. isDescendantOf(ancestor: Node): boolean;
  24814. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24815. /**
  24816. * Will return all nodes that have this node as ascendant
  24817. * @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
  24818. * @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
  24819. * @return all children nodes of all types
  24820. */
  24821. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24822. /**
  24823. * Get all child-meshes of this node
  24824. * @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)
  24825. * @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
  24826. * @returns an array of AbstractMesh
  24827. */
  24828. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24829. /**
  24830. * Get all direct children of this node
  24831. * @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
  24832. * @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)
  24833. * @returns an array of Node
  24834. */
  24835. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24836. /** @hidden */ setReady(state: boolean): void;
  24837. /**
  24838. * Get an animation by name
  24839. * @param name defines the name of the animation to look for
  24840. * @returns null if not found else the requested animation
  24841. */
  24842. getAnimationByName(name: string): Nullable<Animation>;
  24843. /**
  24844. * Creates an animation range for this node
  24845. * @param name defines the name of the range
  24846. * @param from defines the starting key
  24847. * @param to defines the end key
  24848. */
  24849. createAnimationRange(name: string, from: number, to: number): void;
  24850. /**
  24851. * Delete a specific animation range
  24852. * @param name defines the name of the range to delete
  24853. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24854. */
  24855. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24856. /**
  24857. * Get an animation range by name
  24858. * @param name defines the name of the animation range to look for
  24859. * @returns null if not found else the requested animation range
  24860. */
  24861. getAnimationRange(name: string): Nullable<AnimationRange>;
  24862. /**
  24863. * Gets the list of all animation ranges defined on this node
  24864. * @returns an array
  24865. */
  24866. getAnimationRanges(): Nullable<AnimationRange>[];
  24867. /**
  24868. * Will start the animation sequence
  24869. * @param name defines the range frames for animation sequence
  24870. * @param loop defines if the animation should loop (false by default)
  24871. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24872. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24873. * @returns the object created for this animation. If range does not exist, it will return null
  24874. */
  24875. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24876. /**
  24877. * Serialize animation ranges into a JSON compatible object
  24878. * @returns serialization object
  24879. */
  24880. serializeAnimationRanges(): any;
  24881. /**
  24882. * Computes the world matrix of the node
  24883. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24884. * @returns the world matrix
  24885. */
  24886. computeWorldMatrix(force?: boolean): Matrix;
  24887. /**
  24888. * Releases resources associated with this node.
  24889. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24890. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24891. */
  24892. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24893. /**
  24894. * Parse animation range data from a serialization object and store them into a given node
  24895. * @param node defines where to store the animation ranges
  24896. * @param parsedNode defines the serialization object to read data from
  24897. * @param scene defines the hosting scene
  24898. */
  24899. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24900. /**
  24901. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  24902. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24903. * @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
  24904. * @returns the new bounding vectors
  24905. */
  24906. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24907. min: Vector3;
  24908. max: Vector3;
  24909. };
  24910. }
  24911. }
  24912. declare module BABYLON {
  24913. /**
  24914. * @hidden
  24915. */
  24916. export class _IAnimationState {
  24917. key: number;
  24918. repeatCount: number;
  24919. workValue?: any;
  24920. loopMode?: number;
  24921. offsetValue?: any;
  24922. highLimitValue?: any;
  24923. }
  24924. /**
  24925. * Class used to store any kind of animation
  24926. */
  24927. export class Animation {
  24928. /**Name of the animation */
  24929. name: string;
  24930. /**Property to animate */
  24931. targetProperty: string;
  24932. /**The frames per second of the animation */
  24933. framePerSecond: number;
  24934. /**The data type of the animation */
  24935. dataType: number;
  24936. /**The loop mode of the animation */
  24937. loopMode?: number | undefined;
  24938. /**Specifies if blending should be enabled */
  24939. enableBlending?: boolean | undefined;
  24940. /**
  24941. * Use matrix interpolation instead of using direct key value when animating matrices
  24942. */
  24943. static AllowMatricesInterpolation: boolean;
  24944. /**
  24945. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24946. */
  24947. static AllowMatrixDecomposeForInterpolation: boolean;
  24948. /**
  24949. * Stores the key frames of the animation
  24950. */
  24951. private _keys;
  24952. /**
  24953. * Stores the easing function of the animation
  24954. */
  24955. private _easingFunction;
  24956. /**
  24957. * @hidden Internal use only
  24958. */ runtimeAnimations: RuntimeAnimation[];
  24959. /**
  24960. * The set of event that will be linked to this animation
  24961. */
  24962. private _events;
  24963. /**
  24964. * Stores an array of target property paths
  24965. */
  24966. targetPropertyPath: string[];
  24967. /**
  24968. * Stores the blending speed of the animation
  24969. */
  24970. blendingSpeed: number;
  24971. /**
  24972. * Stores the animation ranges for the animation
  24973. */
  24974. private _ranges;
  24975. /**
  24976. * @hidden Internal use
  24977. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24978. /**
  24979. * Sets up an animation
  24980. * @param property The property to animate
  24981. * @param animationType The animation type to apply
  24982. * @param framePerSecond The frames per second of the animation
  24983. * @param easingFunction The easing function used in the animation
  24984. * @returns The created animation
  24985. */
  24986. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24987. /**
  24988. * Create and start an animation on a node
  24989. * @param name defines the name of the global animation that will be run on all nodes
  24990. * @param node defines the root node where the animation will take place
  24991. * @param targetProperty defines property to animate
  24992. * @param framePerSecond defines the number of frame per second yo use
  24993. * @param totalFrame defines the number of frames in total
  24994. * @param from defines the initial value
  24995. * @param to defines the final value
  24996. * @param loopMode defines which loop mode you want to use (off by default)
  24997. * @param easingFunction defines the easing function to use (linear by default)
  24998. * @param onAnimationEnd defines the callback to call when animation end
  24999. * @returns the animatable created for this animation
  25000. */
  25001. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25002. /**
  25003. * Create and start an animation on a node and its descendants
  25004. * @param name defines the name of the global animation that will be run on all nodes
  25005. * @param node defines the root node where the animation will take place
  25006. * @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
  25007. * @param targetProperty defines property to animate
  25008. * @param framePerSecond defines the number of frame per second to use
  25009. * @param totalFrame defines the number of frames in total
  25010. * @param from defines the initial value
  25011. * @param to defines the final value
  25012. * @param loopMode defines which loop mode you want to use (off by default)
  25013. * @param easingFunction defines the easing function to use (linear by default)
  25014. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25015. * @returns the list of animatables created for all nodes
  25016. * @example https://www.babylonjs-playground.com/#MH0VLI
  25017. */
  25018. 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[]>;
  25019. /**
  25020. * Creates a new animation, merges it with the existing animations and starts it
  25021. * @param name Name of the animation
  25022. * @param node Node which contains the scene that begins the animations
  25023. * @param targetProperty Specifies which property to animate
  25024. * @param framePerSecond The frames per second of the animation
  25025. * @param totalFrame The total number of frames
  25026. * @param from The frame at the beginning of the animation
  25027. * @param to The frame at the end of the animation
  25028. * @param loopMode Specifies the loop mode of the animation
  25029. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25030. * @param onAnimationEnd Callback to run once the animation is complete
  25031. * @returns Nullable animation
  25032. */
  25033. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25034. /**
  25035. * Transition property of an host to the target Value
  25036. * @param property The property to transition
  25037. * @param targetValue The target Value of the property
  25038. * @param host The object where the property to animate belongs
  25039. * @param scene Scene used to run the animation
  25040. * @param frameRate Framerate (in frame/s) to use
  25041. * @param transition The transition type we want to use
  25042. * @param duration The duration of the animation, in milliseconds
  25043. * @param onAnimationEnd Callback trigger at the end of the animation
  25044. * @returns Nullable animation
  25045. */
  25046. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25047. /**
  25048. * Return the array of runtime animations currently using this animation
  25049. */
  25050. readonly runtimeAnimations: RuntimeAnimation[];
  25051. /**
  25052. * Specifies if any of the runtime animations are currently running
  25053. */
  25054. readonly hasRunningRuntimeAnimations: boolean;
  25055. /**
  25056. * Initializes the animation
  25057. * @param name Name of the animation
  25058. * @param targetProperty Property to animate
  25059. * @param framePerSecond The frames per second of the animation
  25060. * @param dataType The data type of the animation
  25061. * @param loopMode The loop mode of the animation
  25062. * @param enableBlending Specifies if blending should be enabled
  25063. */
  25064. constructor(
  25065. /**Name of the animation */
  25066. name: string,
  25067. /**Property to animate */
  25068. targetProperty: string,
  25069. /**The frames per second of the animation */
  25070. framePerSecond: number,
  25071. /**The data type of the animation */
  25072. dataType: number,
  25073. /**The loop mode of the animation */
  25074. loopMode?: number | undefined,
  25075. /**Specifies if blending should be enabled */
  25076. enableBlending?: boolean | undefined);
  25077. /**
  25078. * Converts the animation to a string
  25079. * @param fullDetails support for multiple levels of logging within scene loading
  25080. * @returns String form of the animation
  25081. */
  25082. toString(fullDetails?: boolean): string;
  25083. /**
  25084. * Add an event to this animation
  25085. * @param event Event to add
  25086. */
  25087. addEvent(event: AnimationEvent): void;
  25088. /**
  25089. * Remove all events found at the given frame
  25090. * @param frame The frame to remove events from
  25091. */
  25092. removeEvents(frame: number): void;
  25093. /**
  25094. * Retrieves all the events from the animation
  25095. * @returns Events from the animation
  25096. */
  25097. getEvents(): AnimationEvent[];
  25098. /**
  25099. * Creates an animation range
  25100. * @param name Name of the animation range
  25101. * @param from Starting frame of the animation range
  25102. * @param to Ending frame of the animation
  25103. */
  25104. createRange(name: string, from: number, to: number): void;
  25105. /**
  25106. * Deletes an animation range by name
  25107. * @param name Name of the animation range to delete
  25108. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25109. */
  25110. deleteRange(name: string, deleteFrames?: boolean): void;
  25111. /**
  25112. * Gets the animation range by name, or null if not defined
  25113. * @param name Name of the animation range
  25114. * @returns Nullable animation range
  25115. */
  25116. getRange(name: string): Nullable<AnimationRange>;
  25117. /**
  25118. * Gets the key frames from the animation
  25119. * @returns The key frames of the animation
  25120. */
  25121. getKeys(): Array<IAnimationKey>;
  25122. /**
  25123. * Gets the highest frame rate of the animation
  25124. * @returns Highest frame rate of the animation
  25125. */
  25126. getHighestFrame(): number;
  25127. /**
  25128. * Gets the easing function of the animation
  25129. * @returns Easing function of the animation
  25130. */
  25131. getEasingFunction(): IEasingFunction;
  25132. /**
  25133. * Sets the easing function of the animation
  25134. * @param easingFunction A custom mathematical formula for animation
  25135. */
  25136. setEasingFunction(easingFunction: EasingFunction): void;
  25137. /**
  25138. * Interpolates a scalar linearly
  25139. * @param startValue Start value of the animation curve
  25140. * @param endValue End value of the animation curve
  25141. * @param gradient Scalar amount to interpolate
  25142. * @returns Interpolated scalar value
  25143. */
  25144. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25145. /**
  25146. * Interpolates a scalar cubically
  25147. * @param startValue Start value of the animation curve
  25148. * @param outTangent End tangent of the animation
  25149. * @param endValue End value of the animation curve
  25150. * @param inTangent Start tangent of the animation curve
  25151. * @param gradient Scalar amount to interpolate
  25152. * @returns Interpolated scalar value
  25153. */
  25154. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25155. /**
  25156. * Interpolates a quaternion using a spherical linear interpolation
  25157. * @param startValue Start value of the animation curve
  25158. * @param endValue End value of the animation curve
  25159. * @param gradient Scalar amount to interpolate
  25160. * @returns Interpolated quaternion value
  25161. */
  25162. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25163. /**
  25164. * Interpolates a quaternion cubically
  25165. * @param startValue Start value of the animation curve
  25166. * @param outTangent End tangent of the animation curve
  25167. * @param endValue End value of the animation curve
  25168. * @param inTangent Start tangent of the animation curve
  25169. * @param gradient Scalar amount to interpolate
  25170. * @returns Interpolated quaternion value
  25171. */
  25172. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25173. /**
  25174. * Interpolates a Vector3 linearl
  25175. * @param startValue Start value of the animation curve
  25176. * @param endValue End value of the animation curve
  25177. * @param gradient Scalar amount to interpolate
  25178. * @returns Interpolated scalar value
  25179. */
  25180. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25181. /**
  25182. * Interpolates a Vector3 cubically
  25183. * @param startValue Start value of the animation curve
  25184. * @param outTangent End tangent of the animation
  25185. * @param endValue End value of the animation curve
  25186. * @param inTangent Start tangent of the animation curve
  25187. * @param gradient Scalar amount to interpolate
  25188. * @returns InterpolatedVector3 value
  25189. */
  25190. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25191. /**
  25192. * Interpolates a Vector2 linearly
  25193. * @param startValue Start value of the animation curve
  25194. * @param endValue End value of the animation curve
  25195. * @param gradient Scalar amount to interpolate
  25196. * @returns Interpolated Vector2 value
  25197. */
  25198. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25199. /**
  25200. * Interpolates a Vector2 cubically
  25201. * @param startValue Start value of the animation curve
  25202. * @param outTangent End tangent of the animation
  25203. * @param endValue End value of the animation curve
  25204. * @param inTangent Start tangent of the animation curve
  25205. * @param gradient Scalar amount to interpolate
  25206. * @returns Interpolated Vector2 value
  25207. */
  25208. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25209. /**
  25210. * Interpolates a size linearly
  25211. * @param startValue Start value of the animation curve
  25212. * @param endValue End value of the animation curve
  25213. * @param gradient Scalar amount to interpolate
  25214. * @returns Interpolated Size value
  25215. */
  25216. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25217. /**
  25218. * Interpolates a Color3 linearly
  25219. * @param startValue Start value of the animation curve
  25220. * @param endValue End value of the animation curve
  25221. * @param gradient Scalar amount to interpolate
  25222. * @returns Interpolated Color3 value
  25223. */
  25224. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25225. /**
  25226. * @hidden Internal use only
  25227. */ getKeyValue(value: any): any;
  25228. /**
  25229. * @hidden Internal use only
  25230. */ interpolate(currentFrame: number, state: _IAnimationState): any;
  25231. /**
  25232. * Defines the function to use to interpolate matrices
  25233. * @param startValue defines the start matrix
  25234. * @param endValue defines the end matrix
  25235. * @param gradient defines the gradient between both matrices
  25236. * @param result defines an optional target matrix where to store the interpolation
  25237. * @returns the interpolated matrix
  25238. */
  25239. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25240. /**
  25241. * Makes a copy of the animation
  25242. * @returns Cloned animation
  25243. */
  25244. clone(): Animation;
  25245. /**
  25246. * Sets the key frames of the animation
  25247. * @param values The animation key frames to set
  25248. */
  25249. setKeys(values: Array<IAnimationKey>): void;
  25250. /**
  25251. * Serializes the animation to an object
  25252. * @returns Serialized object
  25253. */
  25254. serialize(): any;
  25255. /**
  25256. * Float animation type
  25257. */
  25258. private static _ANIMATIONTYPE_FLOAT;
  25259. /**
  25260. * Vector3 animation type
  25261. */
  25262. private static _ANIMATIONTYPE_VECTOR3;
  25263. /**
  25264. * Quaternion animation type
  25265. */
  25266. private static _ANIMATIONTYPE_QUATERNION;
  25267. /**
  25268. * Matrix animation type
  25269. */
  25270. private static _ANIMATIONTYPE_MATRIX;
  25271. /**
  25272. * Color3 animation type
  25273. */
  25274. private static _ANIMATIONTYPE_COLOR3;
  25275. /**
  25276. * Vector2 animation type
  25277. */
  25278. private static _ANIMATIONTYPE_VECTOR2;
  25279. /**
  25280. * Size animation type
  25281. */
  25282. private static _ANIMATIONTYPE_SIZE;
  25283. /**
  25284. * Relative Loop Mode
  25285. */
  25286. private static _ANIMATIONLOOPMODE_RELATIVE;
  25287. /**
  25288. * Cycle Loop Mode
  25289. */
  25290. private static _ANIMATIONLOOPMODE_CYCLE;
  25291. /**
  25292. * Constant Loop Mode
  25293. */
  25294. private static _ANIMATIONLOOPMODE_CONSTANT;
  25295. /**
  25296. * Get the float animation type
  25297. */
  25298. static readonly ANIMATIONTYPE_FLOAT: number;
  25299. /**
  25300. * Get the Vector3 animation type
  25301. */
  25302. static readonly ANIMATIONTYPE_VECTOR3: number;
  25303. /**
  25304. * Get the Vector2 animation type
  25305. */
  25306. static readonly ANIMATIONTYPE_VECTOR2: number;
  25307. /**
  25308. * Get the Size animation type
  25309. */
  25310. static readonly ANIMATIONTYPE_SIZE: number;
  25311. /**
  25312. * Get the Quaternion animation type
  25313. */
  25314. static readonly ANIMATIONTYPE_QUATERNION: number;
  25315. /**
  25316. * Get the Matrix animation type
  25317. */
  25318. static readonly ANIMATIONTYPE_MATRIX: number;
  25319. /**
  25320. * Get the Color3 animation type
  25321. */
  25322. static readonly ANIMATIONTYPE_COLOR3: number;
  25323. /**
  25324. * Get the Relative Loop Mode
  25325. */
  25326. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25327. /**
  25328. * Get the Cycle Loop Mode
  25329. */
  25330. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25331. /**
  25332. * Get the Constant Loop Mode
  25333. */
  25334. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25335. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25336. /**
  25337. * Parses an animation object and creates an animation
  25338. * @param parsedAnimation Parsed animation object
  25339. * @returns Animation object
  25340. */
  25341. static Parse(parsedAnimation: any): Animation;
  25342. /**
  25343. * Appends the serialized animations from the source animations
  25344. * @param source Source containing the animations
  25345. * @param destination Target to store the animations
  25346. */
  25347. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25348. }
  25349. }
  25350. declare module BABYLON {
  25351. /**
  25352. * Base class of all the textures in babylon.
  25353. * It groups all the common properties the materials, post process, lights... might need
  25354. * in order to make a correct use of the texture.
  25355. */
  25356. export class BaseTexture implements IAnimatable {
  25357. /**
  25358. * Default anisotropic filtering level for the application.
  25359. * It is set to 4 as a good tradeoff between perf and quality.
  25360. */
  25361. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25362. /**
  25363. * Gets or sets the unique id of the texture
  25364. */
  25365. uniqueId: number;
  25366. /**
  25367. * Define the name of the texture.
  25368. */
  25369. name: string;
  25370. /**
  25371. * Gets or sets an object used to store user defined information.
  25372. */
  25373. metadata: any;
  25374. /**
  25375. * For internal use only. Please do not use.
  25376. */
  25377. reservedDataStore: any;
  25378. private _hasAlpha;
  25379. /**
  25380. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25381. */
  25382. hasAlpha: boolean;
  25383. /**
  25384. * Defines if the alpha value should be determined via the rgb values.
  25385. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25386. */
  25387. getAlphaFromRGB: boolean;
  25388. /**
  25389. * Intensity or strength of the texture.
  25390. * It is commonly used by materials to fine tune the intensity of the texture
  25391. */
  25392. level: number;
  25393. /**
  25394. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25395. * This is part of the texture as textures usually maps to one uv set.
  25396. */
  25397. coordinatesIndex: number;
  25398. private _coordinatesMode;
  25399. /**
  25400. * How a texture is mapped.
  25401. *
  25402. * | Value | Type | Description |
  25403. * | ----- | ----------------------------------- | ----------- |
  25404. * | 0 | EXPLICIT_MODE | |
  25405. * | 1 | SPHERICAL_MODE | |
  25406. * | 2 | PLANAR_MODE | |
  25407. * | 3 | CUBIC_MODE | |
  25408. * | 4 | PROJECTION_MODE | |
  25409. * | 5 | SKYBOX_MODE | |
  25410. * | 6 | INVCUBIC_MODE | |
  25411. * | 7 | EQUIRECTANGULAR_MODE | |
  25412. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25413. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25414. */
  25415. coordinatesMode: number;
  25416. /**
  25417. * | Value | Type | Description |
  25418. * | ----- | ------------------ | ----------- |
  25419. * | 0 | CLAMP_ADDRESSMODE | |
  25420. * | 1 | WRAP_ADDRESSMODE | |
  25421. * | 2 | MIRROR_ADDRESSMODE | |
  25422. */
  25423. wrapU: number;
  25424. /**
  25425. * | Value | Type | Description |
  25426. * | ----- | ------------------ | ----------- |
  25427. * | 0 | CLAMP_ADDRESSMODE | |
  25428. * | 1 | WRAP_ADDRESSMODE | |
  25429. * | 2 | MIRROR_ADDRESSMODE | |
  25430. */
  25431. wrapV: number;
  25432. /**
  25433. * | Value | Type | Description |
  25434. * | ----- | ------------------ | ----------- |
  25435. * | 0 | CLAMP_ADDRESSMODE | |
  25436. * | 1 | WRAP_ADDRESSMODE | |
  25437. * | 2 | MIRROR_ADDRESSMODE | |
  25438. */
  25439. wrapR: number;
  25440. /**
  25441. * With compliant hardware and browser (supporting anisotropic filtering)
  25442. * this defines the level of anisotropic filtering in the texture.
  25443. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25444. */
  25445. anisotropicFilteringLevel: number;
  25446. /**
  25447. * Define if the texture is a cube texture or if false a 2d texture.
  25448. */
  25449. isCube: boolean;
  25450. /**
  25451. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25452. */
  25453. is3D: boolean;
  25454. /**
  25455. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25456. * HDR texture are usually stored in linear space.
  25457. * This only impacts the PBR and Background materials
  25458. */
  25459. gammaSpace: boolean;
  25460. /**
  25461. * Gets whether or not the texture contains RGBD data.
  25462. */
  25463. readonly isRGBD: boolean;
  25464. /**
  25465. * Is Z inverted in the texture (useful in a cube texture).
  25466. */
  25467. invertZ: boolean;
  25468. /**
  25469. * Are mip maps generated for this texture or not.
  25470. */
  25471. readonly noMipmap: boolean;
  25472. /**
  25473. * @hidden
  25474. */
  25475. lodLevelInAlpha: boolean;
  25476. /**
  25477. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25478. */
  25479. lodGenerationOffset: number;
  25480. /**
  25481. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25482. */
  25483. lodGenerationScale: number;
  25484. /**
  25485. * Define if the texture is a render target.
  25486. */
  25487. isRenderTarget: boolean;
  25488. /**
  25489. * Define the unique id of the texture in the scene.
  25490. */
  25491. readonly uid: string;
  25492. /**
  25493. * Return a string representation of the texture.
  25494. * @returns the texture as a string
  25495. */
  25496. toString(): string;
  25497. /**
  25498. * Get the class name of the texture.
  25499. * @returns "BaseTexture"
  25500. */
  25501. getClassName(): string;
  25502. /**
  25503. * Define the list of animation attached to the texture.
  25504. */
  25505. animations: Animation[];
  25506. /**
  25507. * An event triggered when the texture is disposed.
  25508. */
  25509. onDisposeObservable: Observable<BaseTexture>;
  25510. private _onDisposeObserver;
  25511. /**
  25512. * Callback triggered when the texture has been disposed.
  25513. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25514. */
  25515. onDispose: () => void;
  25516. /**
  25517. * Define the current state of the loading sequence when in delayed load mode.
  25518. */
  25519. delayLoadState: number;
  25520. private _scene;
  25521. /** @hidden */ texture: Nullable<InternalTexture>;
  25522. private _uid;
  25523. /**
  25524. * Define if the texture is preventinga material to render or not.
  25525. * If not and the texture is not ready, the engine will use a default black texture instead.
  25526. */
  25527. readonly isBlocking: boolean;
  25528. /**
  25529. * Instantiates a new BaseTexture.
  25530. * Base class of all the textures in babylon.
  25531. * It groups all the common properties the materials, post process, lights... might need
  25532. * in order to make a correct use of the texture.
  25533. * @param scene Define the scene the texture blongs to
  25534. */
  25535. constructor(scene: Nullable<Scene>);
  25536. /**
  25537. * Get the scene the texture belongs to.
  25538. * @returns the scene or null if undefined
  25539. */
  25540. getScene(): Nullable<Scene>;
  25541. /**
  25542. * Get the texture transform matrix used to offset tile the texture for istance.
  25543. * @returns the transformation matrix
  25544. */
  25545. getTextureMatrix(): Matrix;
  25546. /**
  25547. * Get the texture reflection matrix used to rotate/transform the reflection.
  25548. * @returns the reflection matrix
  25549. */
  25550. getReflectionTextureMatrix(): Matrix;
  25551. /**
  25552. * Get the underlying lower level texture from Babylon.
  25553. * @returns the insternal texture
  25554. */
  25555. getInternalTexture(): Nullable<InternalTexture>;
  25556. /**
  25557. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25558. * @returns true if ready or not blocking
  25559. */
  25560. isReadyOrNotBlocking(): boolean;
  25561. /**
  25562. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25563. * @returns true if fully ready
  25564. */
  25565. isReady(): boolean;
  25566. private _cachedSize;
  25567. /**
  25568. * Get the size of the texture.
  25569. * @returns the texture size.
  25570. */
  25571. getSize(): ISize;
  25572. /**
  25573. * Get the base size of the texture.
  25574. * It can be different from the size if the texture has been resized for POT for instance
  25575. * @returns the base size
  25576. */
  25577. getBaseSize(): ISize;
  25578. /**
  25579. * Update the sampling mode of the texture.
  25580. * Default is Trilinear mode.
  25581. *
  25582. * | Value | Type | Description |
  25583. * | ----- | ------------------ | ----------- |
  25584. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25585. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25586. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25587. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25588. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25589. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25590. * | 7 | NEAREST_LINEAR | |
  25591. * | 8 | NEAREST_NEAREST | |
  25592. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25593. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25594. * | 11 | LINEAR_LINEAR | |
  25595. * | 12 | LINEAR_NEAREST | |
  25596. *
  25597. * > _mag_: magnification filter (close to the viewer)
  25598. * > _min_: minification filter (far from the viewer)
  25599. * > _mip_: filter used between mip map levels
  25600. *@param samplingMode Define the new sampling mode of the texture
  25601. */
  25602. updateSamplingMode(samplingMode: number): void;
  25603. /**
  25604. * Scales the texture if is `canRescale()`
  25605. * @param ratio the resize factor we want to use to rescale
  25606. */
  25607. scale(ratio: number): void;
  25608. /**
  25609. * Get if the texture can rescale.
  25610. */
  25611. readonly canRescale: boolean;
  25612. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25613. /** @hidden */ rebuild(): void;
  25614. /**
  25615. * Triggers the load sequence in delayed load mode.
  25616. */
  25617. delayLoad(): void;
  25618. /**
  25619. * Clones the texture.
  25620. * @returns the cloned texture
  25621. */
  25622. clone(): Nullable<BaseTexture>;
  25623. /**
  25624. * Get the texture underlying type (INT, FLOAT...)
  25625. */
  25626. readonly textureType: number;
  25627. /**
  25628. * Get the texture underlying format (RGB, RGBA...)
  25629. */
  25630. readonly textureFormat: number;
  25631. /**
  25632. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25633. * This will returns an RGBA array buffer containing either in values (0-255) or
  25634. * float values (0-1) depending of the underlying buffer type.
  25635. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25636. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25637. * @param buffer defines a user defined buffer to fill with data (can be null)
  25638. * @returns The Array buffer containing the pixels data.
  25639. */
  25640. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25641. /**
  25642. * Release and destroy the underlying lower level texture aka internalTexture.
  25643. */
  25644. releaseInternalTexture(): void;
  25645. /**
  25646. * Get the polynomial representation of the texture data.
  25647. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25648. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25649. */
  25650. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25651. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  25652. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  25653. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  25654. /**
  25655. * Dispose the texture and release its associated resources.
  25656. */
  25657. dispose(): void;
  25658. /**
  25659. * Serialize the texture into a JSON representation that can be parsed later on.
  25660. * @returns the JSON representation of the texture
  25661. */
  25662. serialize(): any;
  25663. /**
  25664. * Helper function to be called back once a list of texture contains only ready textures.
  25665. * @param textures Define the list of textures to wait for
  25666. * @param callback Define the callback triggered once the entire list will be ready
  25667. */
  25668. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25669. }
  25670. }
  25671. declare module BABYLON {
  25672. /**
  25673. * Uniform buffer objects.
  25674. *
  25675. * Handles blocks of uniform on the GPU.
  25676. *
  25677. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25678. *
  25679. * For more information, please refer to :
  25680. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25681. */
  25682. export class UniformBuffer {
  25683. private _engine;
  25684. private _buffer;
  25685. private _data;
  25686. private _bufferData;
  25687. private _dynamic?;
  25688. private _uniformLocations;
  25689. private _uniformSizes;
  25690. private _uniformLocationPointer;
  25691. private _needSync;
  25692. private _noUBO;
  25693. private _currentEffect;
  25694. private static _MAX_UNIFORM_SIZE;
  25695. private static _tempBuffer;
  25696. /**
  25697. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25698. * This is dynamic to allow compat with webgl 1 and 2.
  25699. * You will need to pass the name of the uniform as well as the value.
  25700. */
  25701. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25702. /**
  25703. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25704. * This is dynamic to allow compat with webgl 1 and 2.
  25705. * You will need to pass the name of the uniform as well as the value.
  25706. */
  25707. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25708. /**
  25709. * Lambda to Update a single float in a uniform buffer.
  25710. * This is dynamic to allow compat with webgl 1 and 2.
  25711. * You will need to pass the name of the uniform as well as the value.
  25712. */
  25713. updateFloat: (name: string, x: number) => void;
  25714. /**
  25715. * Lambda to Update a vec2 of float in a uniform buffer.
  25716. * This is dynamic to allow compat with webgl 1 and 2.
  25717. * You will need to pass the name of the uniform as well as the value.
  25718. */
  25719. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25720. /**
  25721. * Lambda to Update a vec3 of float in a uniform buffer.
  25722. * This is dynamic to allow compat with webgl 1 and 2.
  25723. * You will need to pass the name of the uniform as well as the value.
  25724. */
  25725. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25726. /**
  25727. * Lambda to Update a vec4 of float in a uniform buffer.
  25728. * This is dynamic to allow compat with webgl 1 and 2.
  25729. * You will need to pass the name of the uniform as well as the value.
  25730. */
  25731. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25732. /**
  25733. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25734. * This is dynamic to allow compat with webgl 1 and 2.
  25735. * You will need to pass the name of the uniform as well as the value.
  25736. */
  25737. updateMatrix: (name: string, mat: Matrix) => void;
  25738. /**
  25739. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25740. * This is dynamic to allow compat with webgl 1 and 2.
  25741. * You will need to pass the name of the uniform as well as the value.
  25742. */
  25743. updateVector3: (name: string, vector: Vector3) => void;
  25744. /**
  25745. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25746. * This is dynamic to allow compat with webgl 1 and 2.
  25747. * You will need to pass the name of the uniform as well as the value.
  25748. */
  25749. updateVector4: (name: string, vector: Vector4) => void;
  25750. /**
  25751. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25752. * This is dynamic to allow compat with webgl 1 and 2.
  25753. * You will need to pass the name of the uniform as well as the value.
  25754. */
  25755. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25756. /**
  25757. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25758. * This is dynamic to allow compat with webgl 1 and 2.
  25759. * You will need to pass the name of the uniform as well as the value.
  25760. */
  25761. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25762. /**
  25763. * Instantiates a new Uniform buffer objects.
  25764. *
  25765. * Handles blocks of uniform on the GPU.
  25766. *
  25767. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25768. *
  25769. * For more information, please refer to :
  25770. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25771. * @param engine Define the engine the buffer is associated with
  25772. * @param data Define the data contained in the buffer
  25773. * @param dynamic Define if the buffer is updatable
  25774. */
  25775. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25776. /**
  25777. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25778. * or just falling back on setUniformXXX calls.
  25779. */
  25780. readonly useUbo: boolean;
  25781. /**
  25782. * Indicates if the WebGL underlying uniform buffer is in sync
  25783. * with the javascript cache data.
  25784. */
  25785. readonly isSync: boolean;
  25786. /**
  25787. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25788. * Also, a dynamic UniformBuffer will disable cache verification and always
  25789. * update the underlying WebGL uniform buffer to the GPU.
  25790. * @returns if Dynamic, otherwise false
  25791. */
  25792. isDynamic(): boolean;
  25793. /**
  25794. * The data cache on JS side.
  25795. * @returns the underlying data as a float array
  25796. */
  25797. getData(): Float32Array;
  25798. /**
  25799. * The underlying WebGL Uniform buffer.
  25800. * @returns the webgl buffer
  25801. */
  25802. getBuffer(): Nullable<WebGLBuffer>;
  25803. /**
  25804. * std140 layout specifies how to align data within an UBO structure.
  25805. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25806. * for specs.
  25807. */
  25808. private _fillAlignment;
  25809. /**
  25810. * Adds an uniform in the buffer.
  25811. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25812. * for the layout to be correct !
  25813. * @param name Name of the uniform, as used in the uniform block in the shader.
  25814. * @param size Data size, or data directly.
  25815. */
  25816. addUniform(name: string, size: number | number[]): void;
  25817. /**
  25818. * Adds a Matrix 4x4 to the uniform buffer.
  25819. * @param name Name of the uniform, as used in the uniform block in the shader.
  25820. * @param mat A 4x4 matrix.
  25821. */
  25822. addMatrix(name: string, mat: Matrix): void;
  25823. /**
  25824. * Adds a vec2 to the uniform buffer.
  25825. * @param name Name of the uniform, as used in the uniform block in the shader.
  25826. * @param x Define the x component value of the vec2
  25827. * @param y Define the y component value of the vec2
  25828. */
  25829. addFloat2(name: string, x: number, y: number): void;
  25830. /**
  25831. * Adds a vec3 to the uniform buffer.
  25832. * @param name Name of the uniform, as used in the uniform block in the shader.
  25833. * @param x Define the x component value of the vec3
  25834. * @param y Define the y component value of the vec3
  25835. * @param z Define the z component value of the vec3
  25836. */
  25837. addFloat3(name: string, x: number, y: number, z: number): void;
  25838. /**
  25839. * Adds a vec3 to the uniform buffer.
  25840. * @param name Name of the uniform, as used in the uniform block in the shader.
  25841. * @param color Define the vec3 from a Color
  25842. */
  25843. addColor3(name: string, color: Color3): void;
  25844. /**
  25845. * Adds a vec4 to the uniform buffer.
  25846. * @param name Name of the uniform, as used in the uniform block in the shader.
  25847. * @param color Define the rgb components from a Color
  25848. * @param alpha Define the a component of the vec4
  25849. */
  25850. addColor4(name: string, color: Color3, alpha: number): void;
  25851. /**
  25852. * Adds a vec3 to the uniform buffer.
  25853. * @param name Name of the uniform, as used in the uniform block in the shader.
  25854. * @param vector Define the vec3 components from a Vector
  25855. */
  25856. addVector3(name: string, vector: Vector3): void;
  25857. /**
  25858. * Adds a Matrix 3x3 to the uniform buffer.
  25859. * @param name Name of the uniform, as used in the uniform block in the shader.
  25860. */
  25861. addMatrix3x3(name: string): void;
  25862. /**
  25863. * Adds a Matrix 2x2 to the uniform buffer.
  25864. * @param name Name of the uniform, as used in the uniform block in the shader.
  25865. */
  25866. addMatrix2x2(name: string): void;
  25867. /**
  25868. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25869. */
  25870. create(): void;
  25871. /** @hidden */ rebuild(): void;
  25872. /**
  25873. * Updates the WebGL Uniform Buffer on the GPU.
  25874. * If the `dynamic` flag is set to true, no cache comparison is done.
  25875. * Otherwise, the buffer will be updated only if the cache differs.
  25876. */
  25877. update(): void;
  25878. /**
  25879. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25880. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25881. * @param data Define the flattened data
  25882. * @param size Define the size of the data.
  25883. */
  25884. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25885. private _updateMatrix3x3ForUniform;
  25886. private _updateMatrix3x3ForEffect;
  25887. private _updateMatrix2x2ForEffect;
  25888. private _updateMatrix2x2ForUniform;
  25889. private _updateFloatForEffect;
  25890. private _updateFloatForUniform;
  25891. private _updateFloat2ForEffect;
  25892. private _updateFloat2ForUniform;
  25893. private _updateFloat3ForEffect;
  25894. private _updateFloat3ForUniform;
  25895. private _updateFloat4ForEffect;
  25896. private _updateFloat4ForUniform;
  25897. private _updateMatrixForEffect;
  25898. private _updateMatrixForUniform;
  25899. private _updateVector3ForEffect;
  25900. private _updateVector3ForUniform;
  25901. private _updateVector4ForEffect;
  25902. private _updateVector4ForUniform;
  25903. private _updateColor3ForEffect;
  25904. private _updateColor3ForUniform;
  25905. private _updateColor4ForEffect;
  25906. private _updateColor4ForUniform;
  25907. /**
  25908. * Sets a sampler uniform on the effect.
  25909. * @param name Define the name of the sampler.
  25910. * @param texture Define the texture to set in the sampler
  25911. */
  25912. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25913. /**
  25914. * Directly updates the value of the uniform in the cache AND on the GPU.
  25915. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25916. * @param data Define the flattened data
  25917. */
  25918. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25919. /**
  25920. * Binds this uniform buffer to an effect.
  25921. * @param effect Define the effect to bind the buffer to
  25922. * @param name Name of the uniform block in the shader.
  25923. */
  25924. bindToEffect(effect: Effect, name: string): void;
  25925. /**
  25926. * Disposes the uniform buffer.
  25927. */
  25928. dispose(): void;
  25929. }
  25930. }
  25931. declare module BABYLON {
  25932. /**
  25933. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25935. */
  25936. export class Analyser {
  25937. /**
  25938. * Gets or sets the smoothing
  25939. * @ignorenaming
  25940. */
  25941. SMOOTHING: number;
  25942. /**
  25943. * Gets or sets the FFT table size
  25944. * @ignorenaming
  25945. */
  25946. FFT_SIZE: number;
  25947. /**
  25948. * Gets or sets the bar graph amplitude
  25949. * @ignorenaming
  25950. */
  25951. BARGRAPHAMPLITUDE: number;
  25952. /**
  25953. * Gets or sets the position of the debug canvas
  25954. * @ignorenaming
  25955. */
  25956. DEBUGCANVASPOS: {
  25957. x: number;
  25958. y: number;
  25959. };
  25960. /**
  25961. * Gets or sets the debug canvas size
  25962. * @ignorenaming
  25963. */
  25964. DEBUGCANVASSIZE: {
  25965. width: number;
  25966. height: number;
  25967. };
  25968. private _byteFreqs;
  25969. private _byteTime;
  25970. private _floatFreqs;
  25971. private _webAudioAnalyser;
  25972. private _debugCanvas;
  25973. private _debugCanvasContext;
  25974. private _scene;
  25975. private _registerFunc;
  25976. private _audioEngine;
  25977. /**
  25978. * Creates a new analyser
  25979. * @param scene defines hosting scene
  25980. */
  25981. constructor(scene: Scene);
  25982. /**
  25983. * Get the number of data values you will have to play with for the visualization
  25984. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  25985. * @returns a number
  25986. */
  25987. getFrequencyBinCount(): number;
  25988. /**
  25989. * Gets the current frequency data as a byte array
  25990. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25991. * @returns a Uint8Array
  25992. */
  25993. getByteFrequencyData(): Uint8Array;
  25994. /**
  25995. * Gets the current waveform as a byte array
  25996. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  25997. * @returns a Uint8Array
  25998. */
  25999. getByteTimeDomainData(): Uint8Array;
  26000. /**
  26001. * Gets the current frequency data as a float array
  26002. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26003. * @returns a Float32Array
  26004. */
  26005. getFloatFrequencyData(): Float32Array;
  26006. /**
  26007. * Renders the debug canvas
  26008. */
  26009. drawDebugCanvas(): void;
  26010. /**
  26011. * Stops rendering the debug canvas and removes it
  26012. */
  26013. stopDebugCanvas(): void;
  26014. /**
  26015. * Connects two audio nodes
  26016. * @param inputAudioNode defines first node to connect
  26017. * @param outputAudioNode defines second node to connect
  26018. */
  26019. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26020. /**
  26021. * Releases all associated resources
  26022. */
  26023. dispose(): void;
  26024. }
  26025. }
  26026. declare module BABYLON {
  26027. /**
  26028. * This represents an audio engine and it is responsible
  26029. * to play, synchronize and analyse sounds throughout the application.
  26030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26031. */
  26032. export interface IAudioEngine extends IDisposable {
  26033. /**
  26034. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26035. */
  26036. readonly canUseWebAudio: boolean;
  26037. /**
  26038. * Gets the current AudioContext if available.
  26039. */
  26040. readonly audioContext: Nullable<AudioContext>;
  26041. /**
  26042. * The master gain node defines the global audio volume of your audio engine.
  26043. */
  26044. readonly masterGain: GainNode;
  26045. /**
  26046. * Gets whether or not mp3 are supported by your browser.
  26047. */
  26048. readonly isMP3supported: boolean;
  26049. /**
  26050. * Gets whether or not ogg are supported by your browser.
  26051. */
  26052. readonly isOGGsupported: boolean;
  26053. /**
  26054. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26055. * @ignoreNaming
  26056. */
  26057. WarnedWebAudioUnsupported: boolean;
  26058. /**
  26059. * Defines if the audio engine relies on a custom unlocked button.
  26060. * In this case, the embedded button will not be displayed.
  26061. */
  26062. useCustomUnlockedButton: boolean;
  26063. /**
  26064. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26065. */
  26066. readonly unlocked: boolean;
  26067. /**
  26068. * Event raised when audio has been unlocked on the browser.
  26069. */
  26070. onAudioUnlockedObservable: Observable<AudioEngine>;
  26071. /**
  26072. * Event raised when audio has been locked on the browser.
  26073. */
  26074. onAudioLockedObservable: Observable<AudioEngine>;
  26075. /**
  26076. * Flags the audio engine in Locked state.
  26077. * This happens due to new browser policies preventing audio to autoplay.
  26078. */
  26079. lock(): void;
  26080. /**
  26081. * Unlocks the audio engine once a user action has been done on the dom.
  26082. * This is helpful to resume play once browser policies have been satisfied.
  26083. */
  26084. unlock(): void;
  26085. }
  26086. /**
  26087. * This represents the default audio engine used in babylon.
  26088. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26090. */
  26091. export class AudioEngine implements IAudioEngine {
  26092. private _audioContext;
  26093. private _audioContextInitialized;
  26094. private _muteButton;
  26095. private _hostElement;
  26096. /**
  26097. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26098. */
  26099. canUseWebAudio: boolean;
  26100. /**
  26101. * The master gain node defines the global audio volume of your audio engine.
  26102. */
  26103. masterGain: GainNode;
  26104. /**
  26105. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26106. * @ignoreNaming
  26107. */
  26108. WarnedWebAudioUnsupported: boolean;
  26109. /**
  26110. * Gets whether or not mp3 are supported by your browser.
  26111. */
  26112. isMP3supported: boolean;
  26113. /**
  26114. * Gets whether or not ogg are supported by your browser.
  26115. */
  26116. isOGGsupported: boolean;
  26117. /**
  26118. * Gets whether audio has been unlocked on the device.
  26119. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26120. * a user interaction has happened.
  26121. */
  26122. unlocked: boolean;
  26123. /**
  26124. * Defines if the audio engine relies on a custom unlocked button.
  26125. * In this case, the embedded button will not be displayed.
  26126. */
  26127. useCustomUnlockedButton: boolean;
  26128. /**
  26129. * Event raised when audio has been unlocked on the browser.
  26130. */
  26131. onAudioUnlockedObservable: Observable<AudioEngine>;
  26132. /**
  26133. * Event raised when audio has been locked on the browser.
  26134. */
  26135. onAudioLockedObservable: Observable<AudioEngine>;
  26136. /**
  26137. * Gets the current AudioContext if available.
  26138. */
  26139. readonly audioContext: Nullable<AudioContext>;
  26140. private _connectedAnalyser;
  26141. /**
  26142. * Instantiates a new audio engine.
  26143. *
  26144. * There should be only one per page as some browsers restrict the number
  26145. * of audio contexts you can create.
  26146. * @param hostElement defines the host element where to display the mute icon if necessary
  26147. */
  26148. constructor(hostElement?: Nullable<HTMLElement>);
  26149. /**
  26150. * Flags the audio engine in Locked state.
  26151. * This happens due to new browser policies preventing audio to autoplay.
  26152. */
  26153. lock(): void;
  26154. /**
  26155. * Unlocks the audio engine once a user action has been done on the dom.
  26156. * This is helpful to resume play once browser policies have been satisfied.
  26157. */
  26158. unlock(): void;
  26159. private _resumeAudioContext;
  26160. private _initializeAudioContext;
  26161. private _tryToRun;
  26162. private _triggerRunningState;
  26163. private _triggerSuspendedState;
  26164. private _displayMuteButton;
  26165. private _moveButtonToTopLeft;
  26166. private _onResize;
  26167. private _hideMuteButton;
  26168. /**
  26169. * Destroy and release the resources associated with the audio ccontext.
  26170. */
  26171. dispose(): void;
  26172. /**
  26173. * Gets the global volume sets on the master gain.
  26174. * @returns the global volume if set or -1 otherwise
  26175. */
  26176. getGlobalVolume(): number;
  26177. /**
  26178. * Sets the global volume of your experience (sets on the master gain).
  26179. * @param newVolume Defines the new global volume of the application
  26180. */
  26181. setGlobalVolume(newVolume: number): void;
  26182. /**
  26183. * Connect the audio engine to an audio analyser allowing some amazing
  26184. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26186. * @param analyser The analyser to connect to the engine
  26187. */
  26188. connectToAnalyser(analyser: Analyser): void;
  26189. }
  26190. }
  26191. declare module BABYLON {
  26192. /**
  26193. * Interface used to present a loading screen while loading a scene
  26194. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26195. */
  26196. export interface ILoadingScreen {
  26197. /**
  26198. * Function called to display the loading screen
  26199. */
  26200. displayLoadingUI: () => void;
  26201. /**
  26202. * Function called to hide the loading screen
  26203. */
  26204. hideLoadingUI: () => void;
  26205. /**
  26206. * Gets or sets the color to use for the background
  26207. */
  26208. loadingUIBackgroundColor: string;
  26209. /**
  26210. * Gets or sets the text to display while loading
  26211. */
  26212. loadingUIText: string;
  26213. }
  26214. /**
  26215. * Class used for the default loading screen
  26216. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26217. */
  26218. export class DefaultLoadingScreen implements ILoadingScreen {
  26219. private _renderingCanvas;
  26220. private _loadingText;
  26221. private _loadingDivBackgroundColor;
  26222. private _loadingDiv;
  26223. private _loadingTextDiv;
  26224. /**
  26225. * Creates a new default loading screen
  26226. * @param _renderingCanvas defines the canvas used to render the scene
  26227. * @param _loadingText defines the default text to display
  26228. * @param _loadingDivBackgroundColor defines the default background color
  26229. */
  26230. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26231. /**
  26232. * Function called to display the loading screen
  26233. */
  26234. displayLoadingUI(): void;
  26235. /**
  26236. * Function called to hide the loading screen
  26237. */
  26238. hideLoadingUI(): void;
  26239. /**
  26240. * Gets or sets the text to display while loading
  26241. */
  26242. loadingUIText: string;
  26243. /**
  26244. * Gets or sets the color to use for the background
  26245. */
  26246. loadingUIBackgroundColor: string;
  26247. private _resizeLoadingUI;
  26248. }
  26249. }
  26250. declare module BABYLON {
  26251. /**
  26252. * Settings for finer control over video usage
  26253. */
  26254. export interface VideoTextureSettings {
  26255. /**
  26256. * Applies `autoplay` to video, if specified
  26257. */
  26258. autoPlay?: boolean;
  26259. /**
  26260. * Applies `loop` to video, if specified
  26261. */
  26262. loop?: boolean;
  26263. /**
  26264. * Automatically updates internal texture from video at every frame in the render loop
  26265. */
  26266. autoUpdateTexture: boolean;
  26267. /**
  26268. * Image src displayed during the video loading or until the user interacts with the video.
  26269. */
  26270. poster?: string;
  26271. }
  26272. /**
  26273. * If you want to display a video in your scene, this is the special texture for that.
  26274. * This special texture works similar to other textures, with the exception of a few parameters.
  26275. * @see https://doc.babylonjs.com/how_to/video_texture
  26276. */
  26277. export class VideoTexture extends Texture {
  26278. /**
  26279. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26280. */
  26281. readonly autoUpdateTexture: boolean;
  26282. /**
  26283. * The video instance used by the texture internally
  26284. */
  26285. readonly video: HTMLVideoElement;
  26286. private _onUserActionRequestedObservable;
  26287. /**
  26288. * Event triggerd when a dom action is required by the user to play the video.
  26289. * This happens due to recent changes in browser policies preventing video to auto start.
  26290. */
  26291. readonly onUserActionRequestedObservable: Observable<Texture>;
  26292. private _generateMipMaps;
  26293. private _engine;
  26294. private _stillImageCaptured;
  26295. private _displayingPosterTexture;
  26296. private _settings;
  26297. private _createInternalTextureOnEvent;
  26298. /**
  26299. * Creates a video texture.
  26300. * If you want to display a video in your scene, this is the special texture for that.
  26301. * This special texture works similar to other textures, with the exception of a few parameters.
  26302. * @see https://doc.babylonjs.com/how_to/video_texture
  26303. * @param name optional name, will detect from video source, if not defined
  26304. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26305. * @param scene is obviously the current scene.
  26306. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26307. * @param invertY is false by default but can be used to invert video on Y axis
  26308. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26309. * @param settings allows finer control over video usage
  26310. */
  26311. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26312. private _getName;
  26313. private _getVideo;
  26314. private _createInternalTexture;
  26315. private reset;
  26316. /**
  26317. * @hidden Internal method to initiate `update`.
  26318. */ rebuild(): void;
  26319. /**
  26320. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26321. */
  26322. update(): void;
  26323. /**
  26324. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26325. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26326. */
  26327. updateTexture(isVisible: boolean): void;
  26328. protected _updateInternalTexture: () => void;
  26329. /**
  26330. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26331. * @param url New url.
  26332. */
  26333. updateURL(url: string): void;
  26334. /**
  26335. * Dispose the texture and release its associated resources.
  26336. */
  26337. dispose(): void;
  26338. /**
  26339. * Creates a video texture straight from a stream.
  26340. * @param scene Define the scene the texture should be created in
  26341. * @param stream Define the stream the texture should be created from
  26342. * @returns The created video texture as a promise
  26343. */
  26344. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26345. /**
  26346. * Creates a video texture straight from your WebCam video feed.
  26347. * @param scene Define the scene the texture should be created in
  26348. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26349. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26350. * @returns The created video texture as a promise
  26351. */
  26352. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26353. minWidth: number;
  26354. maxWidth: number;
  26355. minHeight: number;
  26356. maxHeight: number;
  26357. deviceId: string;
  26358. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26359. /**
  26360. * Creates a video texture straight from your WebCam video feed.
  26361. * @param scene Define the scene the texture should be created in
  26362. * @param onReady Define a callback to triggered once the texture will be ready
  26363. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26364. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26365. */
  26366. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26367. minWidth: number;
  26368. maxWidth: number;
  26369. minHeight: number;
  26370. maxHeight: number;
  26371. deviceId: string;
  26372. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26373. }
  26374. }
  26375. declare module BABYLON {
  26376. /**
  26377. * Interface for attribute information associated with buffer instanciation
  26378. */
  26379. export class InstancingAttributeInfo {
  26380. /**
  26381. * Index/offset of the attribute in the vertex shader
  26382. */
  26383. index: number;
  26384. /**
  26385. * size of the attribute, 1, 2, 3 or 4
  26386. */
  26387. attributeSize: number;
  26388. /**
  26389. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26390. * default is FLOAT
  26391. */
  26392. attribyteType: number;
  26393. /**
  26394. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26395. */
  26396. normalized: boolean;
  26397. /**
  26398. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26399. */
  26400. offset: number;
  26401. /**
  26402. * Name of the GLSL attribute, for debugging purpose only
  26403. */
  26404. attributeName: string;
  26405. }
  26406. /**
  26407. * Define options used to create a depth texture
  26408. */
  26409. export class DepthTextureCreationOptions {
  26410. /** Specifies whether or not a stencil should be allocated in the texture */
  26411. generateStencil?: boolean;
  26412. /** Specifies whether or not bilinear filtering is enable on the texture */
  26413. bilinearFiltering?: boolean;
  26414. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26415. comparisonFunction?: number;
  26416. /** Specifies if the created texture is a cube texture */
  26417. isCube?: boolean;
  26418. }
  26419. /**
  26420. * Class used to describe the capabilities of the engine relatively to the current browser
  26421. */
  26422. export class EngineCapabilities {
  26423. /** Maximum textures units per fragment shader */
  26424. maxTexturesImageUnits: number;
  26425. /** Maximum texture units per vertex shader */
  26426. maxVertexTextureImageUnits: number;
  26427. /** Maximum textures units in the entire pipeline */
  26428. maxCombinedTexturesImageUnits: number;
  26429. /** Maximum texture size */
  26430. maxTextureSize: number;
  26431. /** Maximum cube texture size */
  26432. maxCubemapTextureSize: number;
  26433. /** Maximum render texture size */
  26434. maxRenderTextureSize: number;
  26435. /** Maximum number of vertex attributes */
  26436. maxVertexAttribs: number;
  26437. /** Maximum number of varyings */
  26438. maxVaryingVectors: number;
  26439. /** Maximum number of uniforms per vertex shader */
  26440. maxVertexUniformVectors: number;
  26441. /** Maximum number of uniforms per fragment shader */
  26442. maxFragmentUniformVectors: number;
  26443. /** Defines if standard derivates (dx/dy) are supported */
  26444. standardDerivatives: boolean;
  26445. /** Defines if s3tc texture compression is supported */
  26446. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26447. /** Defines if pvrtc texture compression is supported */
  26448. pvrtc: any;
  26449. /** Defines if etc1 texture compression is supported */
  26450. etc1: any;
  26451. /** Defines if etc2 texture compression is supported */
  26452. etc2: any;
  26453. /** Defines if astc texture compression is supported */
  26454. astc: any;
  26455. /** Defines if float textures are supported */
  26456. textureFloat: boolean;
  26457. /** Defines if vertex array objects are supported */
  26458. vertexArrayObject: boolean;
  26459. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26460. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26461. /** Gets the maximum level of anisotropy supported */
  26462. maxAnisotropy: number;
  26463. /** Defines if instancing is supported */
  26464. instancedArrays: boolean;
  26465. /** Defines if 32 bits indices are supported */
  26466. uintIndices: boolean;
  26467. /** Defines if high precision shaders are supported */
  26468. highPrecisionShaderSupported: boolean;
  26469. /** Defines if depth reading in the fragment shader is supported */
  26470. fragmentDepthSupported: boolean;
  26471. /** Defines if float texture linear filtering is supported*/
  26472. textureFloatLinearFiltering: boolean;
  26473. /** Defines if rendering to float textures is supported */
  26474. textureFloatRender: boolean;
  26475. /** Defines if half float textures are supported*/
  26476. textureHalfFloat: boolean;
  26477. /** Defines if half float texture linear filtering is supported*/
  26478. textureHalfFloatLinearFiltering: boolean;
  26479. /** Defines if rendering to half float textures is supported */
  26480. textureHalfFloatRender: boolean;
  26481. /** Defines if textureLOD shader command is supported */
  26482. textureLOD: boolean;
  26483. /** Defines if draw buffers extension is supported */
  26484. drawBuffersExtension: boolean;
  26485. /** Defines if depth textures are supported */
  26486. depthTextureExtension: boolean;
  26487. /** Defines if float color buffer are supported */
  26488. colorBufferFloat: boolean;
  26489. /** Gets disjoint timer query extension (null if not supported) */
  26490. timerQuery: EXT_disjoint_timer_query;
  26491. /** Defines if timestamp can be used with timer query */
  26492. canUseTimestampForTimerQuery: boolean;
  26493. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26494. multiview: any;
  26495. /** Function used to let the system compiles shaders in background */
  26496. parallelShaderCompile: {
  26497. COMPLETION_STATUS_KHR: number;
  26498. };
  26499. }
  26500. /** Interface defining initialization parameters for Engine class */
  26501. export interface EngineOptions extends WebGLContextAttributes {
  26502. /**
  26503. * Defines if the engine should no exceed a specified device ratio
  26504. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26505. */
  26506. limitDeviceRatio?: number;
  26507. /**
  26508. * Defines if webvr should be enabled automatically
  26509. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26510. */
  26511. autoEnableWebVR?: boolean;
  26512. /**
  26513. * Defines if webgl2 should be turned off even if supported
  26514. * @see http://doc.babylonjs.com/features/webgl2
  26515. */
  26516. disableWebGL2Support?: boolean;
  26517. /**
  26518. * Defines if webaudio should be initialized as well
  26519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26520. */
  26521. audioEngine?: boolean;
  26522. /**
  26523. * Defines if animations should run using a deterministic lock step
  26524. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26525. */
  26526. deterministicLockstep?: boolean;
  26527. /** Defines the maximum steps to use with deterministic lock step mode */
  26528. lockstepMaxSteps?: number;
  26529. /**
  26530. * Defines that engine should ignore context lost events
  26531. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26532. */
  26533. doNotHandleContextLost?: boolean;
  26534. /**
  26535. * Defines that engine should ignore modifying touch action attribute and style
  26536. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26537. */
  26538. doNotHandleTouchAction?: boolean;
  26539. /**
  26540. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26541. */
  26542. useHighPrecisionFloats?: boolean;
  26543. }
  26544. /**
  26545. * Defines the interface used by display changed events
  26546. */
  26547. export interface IDisplayChangedEventArgs {
  26548. /** Gets the vrDisplay object (if any) */
  26549. vrDisplay: Nullable<any>;
  26550. /** Gets a boolean indicating if webVR is supported */
  26551. vrSupported: boolean;
  26552. }
  26553. /**
  26554. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26555. */
  26556. export class Engine {
  26557. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26558. static ExceptionList: ({
  26559. key: string;
  26560. capture: string;
  26561. captureConstraint: number;
  26562. targets: string[];
  26563. } | {
  26564. key: string;
  26565. capture: null;
  26566. captureConstraint: null;
  26567. targets: string[];
  26568. })[];
  26569. /** Gets the list of created engines */
  26570. static readonly Instances: Engine[];
  26571. /**
  26572. * Gets the latest created engine
  26573. */
  26574. static readonly LastCreatedEngine: Nullable<Engine>;
  26575. /**
  26576. * Gets the latest created scene
  26577. */
  26578. static readonly LastCreatedScene: Nullable<Scene>;
  26579. /**
  26580. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26581. * @param flag defines which part of the materials must be marked as dirty
  26582. * @param predicate defines a predicate used to filter which materials should be affected
  26583. */
  26584. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26585. /**
  26586. * Hidden
  26587. */ private static _TextureLoaders: IInternalTextureLoader[];
  26588. /** Defines that alpha blending is disabled */
  26589. static readonly ALPHA_DISABLE: number;
  26590. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26591. static readonly ALPHA_ADD: number;
  26592. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26593. static readonly ALPHA_COMBINE: number;
  26594. /** Defines that alpha blending to DEST - SRC * DEST */
  26595. static readonly ALPHA_SUBTRACT: number;
  26596. /** Defines that alpha blending to SRC * DEST */
  26597. static readonly ALPHA_MULTIPLY: number;
  26598. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26599. static readonly ALPHA_MAXIMIZED: number;
  26600. /** Defines that alpha blending to SRC + DEST */
  26601. static readonly ALPHA_ONEONE: number;
  26602. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26603. static readonly ALPHA_PREMULTIPLIED: number;
  26604. /**
  26605. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26607. */
  26608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26609. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26610. static readonly ALPHA_INTERPOLATE: number;
  26611. /**
  26612. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26614. */
  26615. static readonly ALPHA_SCREENMODE: number;
  26616. /** Defines that the ressource is not delayed*/
  26617. static readonly DELAYLOADSTATE_NONE: number;
  26618. /** Defines that the ressource was successfully delay loaded */
  26619. static readonly DELAYLOADSTATE_LOADED: number;
  26620. /** Defines that the ressource is currently delay loading */
  26621. static readonly DELAYLOADSTATE_LOADING: number;
  26622. /** Defines that the ressource is delayed and has not started loading */
  26623. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26625. static readonly NEVER: number;
  26626. /** 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 */
  26627. static readonly ALWAYS: number;
  26628. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26629. static readonly LESS: number;
  26630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26631. static readonly EQUAL: number;
  26632. /** 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 */
  26633. static readonly LEQUAL: number;
  26634. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26635. static readonly GREATER: number;
  26636. /** 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 */
  26637. static readonly GEQUAL: number;
  26638. /** 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 */
  26639. static readonly NOTEQUAL: number;
  26640. /** Passed to stencilOperation to specify that stencil value must be kept */
  26641. static readonly KEEP: number;
  26642. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26643. static readonly REPLACE: number;
  26644. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26645. static readonly INCR: number;
  26646. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26647. static readonly DECR: number;
  26648. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26649. static readonly INVERT: number;
  26650. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26651. static readonly INCR_WRAP: number;
  26652. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26653. static readonly DECR_WRAP: number;
  26654. /** Texture is not repeating outside of 0..1 UVs */
  26655. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26656. /** Texture is repeating outside of 0..1 UVs */
  26657. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26658. /** Texture is repeating and mirrored */
  26659. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26660. /** ALPHA */
  26661. static readonly TEXTUREFORMAT_ALPHA: number;
  26662. /** LUMINANCE */
  26663. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26664. /** LUMINANCE_ALPHA */
  26665. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26666. /** RGB */
  26667. static readonly TEXTUREFORMAT_RGB: number;
  26668. /** RGBA */
  26669. static readonly TEXTUREFORMAT_RGBA: number;
  26670. /** RED */
  26671. static readonly TEXTUREFORMAT_RED: number;
  26672. /** RED (2nd reference) */
  26673. static readonly TEXTUREFORMAT_R: number;
  26674. /** RG */
  26675. static readonly TEXTUREFORMAT_RG: number;
  26676. /** RED_INTEGER */
  26677. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26678. /** RED_INTEGER (2nd reference) */
  26679. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26680. /** RG_INTEGER */
  26681. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26682. /** RGB_INTEGER */
  26683. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26684. /** RGBA_INTEGER */
  26685. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26686. /** UNSIGNED_BYTE */
  26687. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26688. /** UNSIGNED_BYTE (2nd reference) */
  26689. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26690. /** FLOAT */
  26691. static readonly TEXTURETYPE_FLOAT: number;
  26692. /** HALF_FLOAT */
  26693. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26694. /** BYTE */
  26695. static readonly TEXTURETYPE_BYTE: number;
  26696. /** SHORT */
  26697. static readonly TEXTURETYPE_SHORT: number;
  26698. /** UNSIGNED_SHORT */
  26699. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26700. /** INT */
  26701. static readonly TEXTURETYPE_INT: number;
  26702. /** UNSIGNED_INT */
  26703. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26704. /** UNSIGNED_SHORT_4_4_4_4 */
  26705. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26706. /** UNSIGNED_SHORT_5_5_5_1 */
  26707. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26708. /** UNSIGNED_SHORT_5_6_5 */
  26709. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26710. /** UNSIGNED_INT_2_10_10_10_REV */
  26711. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26712. /** UNSIGNED_INT_24_8 */
  26713. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26714. /** UNSIGNED_INT_10F_11F_11F_REV */
  26715. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26716. /** UNSIGNED_INT_5_9_9_9_REV */
  26717. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26718. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26719. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26720. /** nearest is mag = nearest and min = nearest and mip = linear */
  26721. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26722. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26723. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26724. /** Trilinear is mag = linear and min = linear and mip = linear */
  26725. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26726. /** nearest is mag = nearest and min = nearest and mip = linear */
  26727. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26728. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26729. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26730. /** Trilinear is mag = linear and min = linear and mip = linear */
  26731. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26732. /** mag = nearest and min = nearest and mip = nearest */
  26733. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26734. /** mag = nearest and min = linear and mip = nearest */
  26735. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26736. /** mag = nearest and min = linear and mip = linear */
  26737. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26738. /** mag = nearest and min = linear and mip = none */
  26739. static readonly TEXTURE_NEAREST_LINEAR: number;
  26740. /** mag = nearest and min = nearest and mip = none */
  26741. static readonly TEXTURE_NEAREST_NEAREST: number;
  26742. /** mag = linear and min = nearest and mip = nearest */
  26743. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26744. /** mag = linear and min = nearest and mip = linear */
  26745. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26746. /** mag = linear and min = linear and mip = none */
  26747. static readonly TEXTURE_LINEAR_LINEAR: number;
  26748. /** mag = linear and min = nearest and mip = none */
  26749. static readonly TEXTURE_LINEAR_NEAREST: number;
  26750. /** Explicit coordinates mode */
  26751. static readonly TEXTURE_EXPLICIT_MODE: number;
  26752. /** Spherical coordinates mode */
  26753. static readonly TEXTURE_SPHERICAL_MODE: number;
  26754. /** Planar coordinates mode */
  26755. static readonly TEXTURE_PLANAR_MODE: number;
  26756. /** Cubic coordinates mode */
  26757. static readonly TEXTURE_CUBIC_MODE: number;
  26758. /** Projection coordinates mode */
  26759. static readonly TEXTURE_PROJECTION_MODE: number;
  26760. /** Skybox coordinates mode */
  26761. static readonly TEXTURE_SKYBOX_MODE: number;
  26762. /** Inverse Cubic coordinates mode */
  26763. static readonly TEXTURE_INVCUBIC_MODE: number;
  26764. /** Equirectangular coordinates mode */
  26765. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26766. /** Equirectangular Fixed coordinates mode */
  26767. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26768. /** Equirectangular Fixed Mirrored coordinates mode */
  26769. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26770. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26771. static readonly SCALEMODE_FLOOR: number;
  26772. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26773. static readonly SCALEMODE_NEAREST: number;
  26774. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26775. static readonly SCALEMODE_CEILING: number;
  26776. /**
  26777. * Returns the current npm package of the sdk
  26778. */
  26779. static readonly NpmPackage: string;
  26780. /**
  26781. * Returns the current version of the framework
  26782. */
  26783. static readonly Version: string;
  26784. /**
  26785. * Returns a string describing the current engine
  26786. */
  26787. readonly description: string;
  26788. /**
  26789. * Gets or sets the epsilon value used by collision engine
  26790. */
  26791. static CollisionsEpsilon: number;
  26792. /**
  26793. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26794. */
  26795. static ShadersRepository: string;
  26796. /**
  26797. * Method called to create the default loading screen.
  26798. * This can be overriden in your own app.
  26799. * @param canvas The rendering canvas element
  26800. * @returns The loading screen
  26801. */
  26802. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26803. /**
  26804. * Method called to create the default rescale post process on each engine.
  26805. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26806. /**
  26807. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26808. */
  26809. forcePOTTextures: boolean;
  26810. /**
  26811. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26812. */
  26813. isFullscreen: boolean;
  26814. /**
  26815. * Gets a boolean indicating if the pointer is currently locked
  26816. */
  26817. isPointerLock: boolean;
  26818. /**
  26819. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26820. */
  26821. cullBackFaces: boolean;
  26822. /**
  26823. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26824. */
  26825. renderEvenInBackground: boolean;
  26826. /**
  26827. * Gets or sets a boolean indicating that cache can be kept between frames
  26828. */
  26829. preventCacheWipeBetweenFrames: boolean;
  26830. /**
  26831. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26832. **/
  26833. enableOfflineSupport: boolean;
  26834. /**
  26835. * 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)
  26836. **/
  26837. disableManifestCheck: boolean;
  26838. /**
  26839. * Gets the list of created scenes
  26840. */
  26841. scenes: Scene[];
  26842. /**
  26843. * Event raised when a new scene is created
  26844. */
  26845. onNewSceneAddedObservable: Observable<Scene>;
  26846. /**
  26847. * Gets the list of created postprocesses
  26848. */
  26849. postProcesses: PostProcess[];
  26850. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26851. validateShaderPrograms: boolean;
  26852. /**
  26853. * Observable event triggered each time the rendering canvas is resized
  26854. */
  26855. onResizeObservable: Observable<Engine>;
  26856. /**
  26857. * Observable event triggered each time the canvas loses focus
  26858. */
  26859. onCanvasBlurObservable: Observable<Engine>;
  26860. /**
  26861. * Observable event triggered each time the canvas gains focus
  26862. */
  26863. onCanvasFocusObservable: Observable<Engine>;
  26864. /**
  26865. * Observable event triggered each time the canvas receives pointerout event
  26866. */
  26867. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26868. /**
  26869. * Observable event triggered before each texture is initialized
  26870. */
  26871. onBeforeTextureInitObservable: Observable<Texture>;
  26872. private _vrDisplay;
  26873. private _vrSupported;
  26874. private _oldSize;
  26875. private _oldHardwareScaleFactor;
  26876. private _vrExclusivePointerMode;
  26877. private _webVRInitPromise;
  26878. /**
  26879. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26880. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26881. */
  26882. readonly isInVRExclusivePointerMode: boolean;
  26883. /**
  26884. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26885. */
  26886. disableUniformBuffers: boolean;
  26887. /** @hidden */ uniformBuffers: UniformBuffer[];
  26888. /**
  26889. * Gets a boolean indicating that the engine supports uniform buffers
  26890. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26891. */
  26892. readonly supportsUniformBuffers: boolean;
  26893. /**
  26894. * Observable raised when the engine begins a new frame
  26895. */
  26896. onBeginFrameObservable: Observable<Engine>;
  26897. /**
  26898. * If set, will be used to request the next animation frame for the render loop
  26899. */
  26900. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26901. /**
  26902. * Observable raised when the engine ends the current frame
  26903. */
  26904. onEndFrameObservable: Observable<Engine>;
  26905. /**
  26906. * Observable raised when the engine is about to compile a shader
  26907. */
  26908. onBeforeShaderCompilationObservable: Observable<Engine>;
  26909. /**
  26910. * Observable raised when the engine has jsut compiled a shader
  26911. */
  26912. onAfterShaderCompilationObservable: Observable<Engine>;
  26913. /** @hidden */ gl: WebGLRenderingContext;
  26914. private _renderingCanvas;
  26915. private _windowIsBackground;
  26916. private _webGLVersion;
  26917. protected _highPrecisionShadersAllowed: boolean;
  26918. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  26919. /**
  26920. * Gets a boolean indicating that only power of 2 textures are supported
  26921. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26922. */
  26923. readonly needPOTTextures: boolean;
  26924. /** @hidden */ badOS: boolean;
  26925. /** @hidden */ badDesktopOS: boolean;
  26926. /**
  26927. * Gets the audio engine
  26928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26929. * @ignorenaming
  26930. */
  26931. static audioEngine: IAudioEngine;
  26932. /**
  26933. * Default AudioEngine factory responsible of creating the Audio Engine.
  26934. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26935. */
  26936. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  26937. /**
  26938. * Default offline support factory responsible of creating a tool used to store data locally.
  26939. * By default, this will create a Database object if the workload has been embedded.
  26940. */
  26941. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  26942. private _onFocus;
  26943. private _onBlur;
  26944. private _onCanvasPointerOut;
  26945. private _onCanvasBlur;
  26946. private _onCanvasFocus;
  26947. private _onFullscreenChange;
  26948. private _onPointerLockChange;
  26949. private _onVRDisplayPointerRestricted;
  26950. private _onVRDisplayPointerUnrestricted;
  26951. private _onVrDisplayConnect;
  26952. private _onVrDisplayDisconnect;
  26953. private _onVrDisplayPresentChange;
  26954. /**
  26955. * Observable signaled when VR display mode changes
  26956. */
  26957. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26958. /**
  26959. * Observable signaled when VR request present is complete
  26960. */
  26961. onVRRequestPresentComplete: Observable<boolean>;
  26962. /**
  26963. * Observable signaled when VR request present starts
  26964. */
  26965. onVRRequestPresentStart: Observable<Engine>;
  26966. private _hardwareScalingLevel;
  26967. /** @hidden */ caps: EngineCapabilities;
  26968. private _pointerLockRequested;
  26969. private _isStencilEnable;
  26970. private _colorWrite;
  26971. private _loadingScreen;
  26972. /** @hidden */ drawCalls: PerfCounter;
  26973. private _glVersion;
  26974. private _glRenderer;
  26975. private _glVendor;
  26976. private _videoTextureSupported;
  26977. private _renderingQueueLaunched;
  26978. private _activeRenderLoops;
  26979. private _deterministicLockstep;
  26980. private _lockstepMaxSteps;
  26981. /**
  26982. * Observable signaled when a context lost event is raised
  26983. */
  26984. onContextLostObservable: Observable<Engine>;
  26985. /**
  26986. * Observable signaled when a context restored event is raised
  26987. */
  26988. onContextRestoredObservable: Observable<Engine>;
  26989. private _onContextLost;
  26990. private _onContextRestored;
  26991. private _contextWasLost;
  26992. /** @hidden */ doNotHandleContextLost: boolean;
  26993. /**
  26994. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  26995. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  26996. */
  26997. doNotHandleContextLost: boolean;
  26998. private _performanceMonitor;
  26999. private _fps;
  27000. private _deltaTime;
  27001. /**
  27002. * Turn this value on if you want to pause FPS computation when in background
  27003. */
  27004. disablePerformanceMonitorInBackground: boolean;
  27005. /**
  27006. * Gets the performance monitor attached to this engine
  27007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27008. */
  27009. readonly performanceMonitor: PerformanceMonitor;
  27010. /**
  27011. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27012. */
  27013. disableVertexArrayObjects: boolean;
  27014. /** @hidden */
  27015. protected _depthCullingState: _DepthCullingState;
  27016. /** @hidden */
  27017. protected _stencilState: _StencilState;
  27018. /** @hidden */
  27019. protected _alphaState: _AlphaState;
  27020. /** @hidden */
  27021. protected _alphaMode: number;
  27022. /** @hidden */ internalTexturesCache: InternalTexture[];
  27023. /** @hidden */
  27024. protected _activeChannel: number;
  27025. private _currentTextureChannel;
  27026. /** @hidden */
  27027. protected _boundTexturesCache: {
  27028. [key: string]: Nullable<InternalTexture>;
  27029. };
  27030. /** @hidden */
  27031. protected _currentEffect: Nullable<Effect>;
  27032. /** @hidden */
  27033. protected _currentProgram: Nullable<WebGLProgram>;
  27034. private _compiledEffects;
  27035. private _vertexAttribArraysEnabled;
  27036. /** @hidden */
  27037. protected _cachedViewport: Nullable<Viewport>;
  27038. private _cachedVertexArrayObject;
  27039. /** @hidden */
  27040. protected _cachedVertexBuffers: any;
  27041. /** @hidden */
  27042. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27043. /** @hidden */
  27044. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27045. /** @hidden */ currentRenderTarget: Nullable<InternalTexture>;
  27046. private _uintIndicesCurrentlySet;
  27047. private _currentBoundBuffer;
  27048. /** @hidden */
  27049. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27050. private _currentBufferPointers;
  27051. private _currentInstanceLocations;
  27052. private _currentInstanceBuffers;
  27053. private _textureUnits;
  27054. /** @hidden */ workingCanvas: Nullable<HTMLCanvasElement>;
  27055. /** @hidden */ workingContext: Nullable<CanvasRenderingContext2D>;
  27056. private _rescalePostProcess;
  27057. private _dummyFramebuffer;
  27058. private _externalData;
  27059. private _bindedRenderFunction;
  27060. private _vaoRecordInProgress;
  27061. private _mustWipeVertexAttributes;
  27062. private _emptyTexture;
  27063. private _emptyCubeTexture;
  27064. private _emptyTexture3D;
  27065. /** @hidden */ frameHandler: number;
  27066. private _nextFreeTextureSlots;
  27067. private _maxSimultaneousTextures;
  27068. private _activeRequests;
  27069. private _texturesSupported;
  27070. /** @hidden */ textureFormatInUse: Nullable<string>;
  27071. /**
  27072. * Gets the list of texture formats supported
  27073. */
  27074. readonly texturesSupported: Array<string>;
  27075. /**
  27076. * Gets the list of texture formats in use
  27077. */
  27078. readonly textureFormatInUse: Nullable<string>;
  27079. /**
  27080. * Gets the current viewport
  27081. */
  27082. readonly currentViewport: Nullable<Viewport>;
  27083. /**
  27084. * Gets the default empty texture
  27085. */
  27086. readonly emptyTexture: InternalTexture;
  27087. /**
  27088. * Gets the default empty 3D texture
  27089. */
  27090. readonly emptyTexture3D: InternalTexture;
  27091. /**
  27092. * Gets the default empty cube texture
  27093. */
  27094. readonly emptyCubeTexture: InternalTexture;
  27095. /**
  27096. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27097. */
  27098. readonly premultipliedAlpha: boolean;
  27099. /**
  27100. * Creates a new engine
  27101. * @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
  27102. * @param antialias defines enable antialiasing (default: false)
  27103. * @param options defines further options to be sent to the getContext() function
  27104. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27105. */
  27106. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27107. private _disableTouchAction;
  27108. private _rebuildInternalTextures;
  27109. private _rebuildEffects;
  27110. /**
  27111. * Gets a boolean indicating if all created effects are ready
  27112. * @returns true if all effects are ready
  27113. */
  27114. areAllEffectsReady(): boolean;
  27115. private _rebuildBuffers;
  27116. private _initGLContext;
  27117. /**
  27118. * Gets version of the current webGL context
  27119. */
  27120. readonly webGLVersion: number;
  27121. /**
  27122. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27123. */
  27124. readonly isStencilEnable: boolean;
  27125. /** @hidden */ prepareWorkingCanvas(): void;
  27126. /**
  27127. * Reset the texture cache to empty state
  27128. */
  27129. resetTextureCache(): void;
  27130. /**
  27131. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27132. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27133. * @returns true if engine is in deterministic lock step mode
  27134. */
  27135. isDeterministicLockStep(): boolean;
  27136. /**
  27137. * Gets the max steps when engine is running in deterministic lock step
  27138. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27139. * @returns the max steps
  27140. */
  27141. getLockstepMaxSteps(): number;
  27142. /**
  27143. * Gets an object containing information about the current webGL context
  27144. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27145. */
  27146. getGlInfo(): {
  27147. vendor: string;
  27148. renderer: string;
  27149. version: string;
  27150. };
  27151. /**
  27152. * Gets current aspect ratio
  27153. * @param camera defines the camera to use to get the aspect ratio
  27154. * @param useScreen defines if screen size must be used (or the current render target if any)
  27155. * @returns a number defining the aspect ratio
  27156. */
  27157. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27158. /**
  27159. * Gets current screen aspect ratio
  27160. * @returns a number defining the aspect ratio
  27161. */
  27162. getScreenAspectRatio(): number;
  27163. /**
  27164. * Gets the current render width
  27165. * @param useScreen defines if screen size must be used (or the current render target if any)
  27166. * @returns a number defining the current render width
  27167. */
  27168. getRenderWidth(useScreen?: boolean): number;
  27169. /**
  27170. * Gets the current render height
  27171. * @param useScreen defines if screen size must be used (or the current render target if any)
  27172. * @returns a number defining the current render height
  27173. */
  27174. getRenderHeight(useScreen?: boolean): number;
  27175. /**
  27176. * Gets the HTML canvas attached with the current webGL context
  27177. * @returns a HTML canvas
  27178. */
  27179. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27180. /**
  27181. * Gets the client rect of the HTML canvas attached with the current webGL context
  27182. * @returns a client rectanglee
  27183. */
  27184. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27185. /**
  27186. * Defines the hardware scaling level.
  27187. * By default the hardware scaling level is computed from the window device ratio.
  27188. * 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.
  27189. * @param level defines the level to use
  27190. */
  27191. setHardwareScalingLevel(level: number): void;
  27192. /**
  27193. * Gets the current hardware scaling level.
  27194. * By default the hardware scaling level is computed from the window device ratio.
  27195. * 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.
  27196. * @returns a number indicating the current hardware scaling level
  27197. */
  27198. getHardwareScalingLevel(): number;
  27199. /**
  27200. * Gets the list of loaded textures
  27201. * @returns an array containing all loaded textures
  27202. */
  27203. getLoadedTexturesCache(): InternalTexture[];
  27204. /**
  27205. * Gets the object containing all engine capabilities
  27206. * @returns the EngineCapabilities object
  27207. */
  27208. getCaps(): EngineCapabilities;
  27209. /**
  27210. * Gets the current depth function
  27211. * @returns a number defining the depth function
  27212. */
  27213. getDepthFunction(): Nullable<number>;
  27214. /**
  27215. * Sets the current depth function
  27216. * @param depthFunc defines the function to use
  27217. */
  27218. setDepthFunction(depthFunc: number): void;
  27219. /**
  27220. * Sets the current depth function to GREATER
  27221. */
  27222. setDepthFunctionToGreater(): void;
  27223. /**
  27224. * Sets the current depth function to GEQUAL
  27225. */
  27226. setDepthFunctionToGreaterOrEqual(): void;
  27227. /**
  27228. * Sets the current depth function to LESS
  27229. */
  27230. setDepthFunctionToLess(): void;
  27231. private _cachedStencilBuffer;
  27232. private _cachedStencilFunction;
  27233. private _cachedStencilMask;
  27234. private _cachedStencilOperationPass;
  27235. private _cachedStencilOperationFail;
  27236. private _cachedStencilOperationDepthFail;
  27237. private _cachedStencilReference;
  27238. /**
  27239. * Caches the the state of the stencil buffer
  27240. */
  27241. cacheStencilState(): void;
  27242. /**
  27243. * Restores the state of the stencil buffer
  27244. */
  27245. restoreStencilState(): void;
  27246. /**
  27247. * Sets the current depth function to LEQUAL
  27248. */
  27249. setDepthFunctionToLessOrEqual(): void;
  27250. /**
  27251. * Gets a boolean indicating if stencil buffer is enabled
  27252. * @returns the current stencil buffer state
  27253. */
  27254. getStencilBuffer(): boolean;
  27255. /**
  27256. * Enable or disable the stencil buffer
  27257. * @param enable defines if the stencil buffer must be enabled or disabled
  27258. */
  27259. setStencilBuffer(enable: boolean): void;
  27260. /**
  27261. * Gets the current stencil mask
  27262. * @returns a number defining the new stencil mask to use
  27263. */
  27264. getStencilMask(): number;
  27265. /**
  27266. * Sets the current stencil mask
  27267. * @param mask defines the new stencil mask to use
  27268. */
  27269. setStencilMask(mask: number): void;
  27270. /**
  27271. * Gets the current stencil function
  27272. * @returns a number defining the stencil function to use
  27273. */
  27274. getStencilFunction(): number;
  27275. /**
  27276. * Gets the current stencil reference value
  27277. * @returns a number defining the stencil reference value to use
  27278. */
  27279. getStencilFunctionReference(): number;
  27280. /**
  27281. * Gets the current stencil mask
  27282. * @returns a number defining the stencil mask to use
  27283. */
  27284. getStencilFunctionMask(): number;
  27285. /**
  27286. * Sets the current stencil function
  27287. * @param stencilFunc defines the new stencil function to use
  27288. */
  27289. setStencilFunction(stencilFunc: number): void;
  27290. /**
  27291. * Sets the current stencil reference
  27292. * @param reference defines the new stencil reference to use
  27293. */
  27294. setStencilFunctionReference(reference: number): void;
  27295. /**
  27296. * Sets the current stencil mask
  27297. * @param mask defines the new stencil mask to use
  27298. */
  27299. setStencilFunctionMask(mask: number): void;
  27300. /**
  27301. * Gets the current stencil operation when stencil fails
  27302. * @returns a number defining stencil operation to use when stencil fails
  27303. */
  27304. getStencilOperationFail(): number;
  27305. /**
  27306. * Gets the current stencil operation when depth fails
  27307. * @returns a number defining stencil operation to use when depth fails
  27308. */
  27309. getStencilOperationDepthFail(): number;
  27310. /**
  27311. * Gets the current stencil operation when stencil passes
  27312. * @returns a number defining stencil operation to use when stencil passes
  27313. */
  27314. getStencilOperationPass(): number;
  27315. /**
  27316. * Sets the stencil operation to use when stencil fails
  27317. * @param operation defines the stencil operation to use when stencil fails
  27318. */
  27319. setStencilOperationFail(operation: number): void;
  27320. /**
  27321. * Sets the stencil operation to use when depth fails
  27322. * @param operation defines the stencil operation to use when depth fails
  27323. */
  27324. setStencilOperationDepthFail(operation: number): void;
  27325. /**
  27326. * Sets the stencil operation to use when stencil passes
  27327. * @param operation defines the stencil operation to use when stencil passes
  27328. */
  27329. setStencilOperationPass(operation: number): void;
  27330. /**
  27331. * Sets a boolean indicating if the dithering state is enabled or disabled
  27332. * @param value defines the dithering state
  27333. */
  27334. setDitheringState(value: boolean): void;
  27335. /**
  27336. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27337. * @param value defines the rasterizer state
  27338. */
  27339. setRasterizerState(value: boolean): void;
  27340. /**
  27341. * stop executing a render loop function and remove it from the execution array
  27342. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27343. */
  27344. stopRenderLoop(renderFunction?: () => void): void;
  27345. /** @hidden */ renderLoop(): void;
  27346. /**
  27347. * Register and execute a render loop. The engine can have more than one render function
  27348. * @param renderFunction defines the function to continuously execute
  27349. */
  27350. runRenderLoop(renderFunction: () => void): void;
  27351. /**
  27352. * Toggle full screen mode
  27353. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27354. */
  27355. switchFullscreen(requestPointerLock: boolean): void;
  27356. /**
  27357. * Enters full screen mode
  27358. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27359. */
  27360. enterFullscreen(requestPointerLock: boolean): void;
  27361. /**
  27362. * Exits full screen mode
  27363. */
  27364. exitFullscreen(): void;
  27365. /**
  27366. * Clear the current render buffer or the current render target (if any is set up)
  27367. * @param color defines the color to use
  27368. * @param backBuffer defines if the back buffer must be cleared
  27369. * @param depth defines if the depth buffer must be cleared
  27370. * @param stencil defines if the stencil buffer must be cleared
  27371. */
  27372. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27373. /**
  27374. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27375. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27376. * @param y defines the y-coordinate of the corner of the clear rectangle
  27377. * @param width defines the width of the clear rectangle
  27378. * @param height defines the height of the clear rectangle
  27379. * @param clearColor defines the clear color
  27380. */
  27381. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27382. /**
  27383. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27384. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27385. * @param y defines the y-coordinate of the corner of the clear rectangle
  27386. * @param width defines the width of the clear rectangle
  27387. * @param height defines the height of the clear rectangle
  27388. */
  27389. enableScissor(x: number, y: number, width: number, height: number): void;
  27390. /**
  27391. * Disable previously set scissor test rectangle
  27392. */
  27393. disableScissor(): void;
  27394. private _viewportCached;
  27395. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  27396. /**
  27397. * Set the WebGL's viewport
  27398. * @param viewport defines the viewport element to be used
  27399. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27400. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27401. */
  27402. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27403. /**
  27404. * Directly set the WebGL Viewport
  27405. * @param x defines the x coordinate of the viewport (in screen space)
  27406. * @param y defines the y coordinate of the viewport (in screen space)
  27407. * @param width defines the width of the viewport (in screen space)
  27408. * @param height defines the height of the viewport (in screen space)
  27409. * @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
  27410. */
  27411. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27412. /**
  27413. * Begin a new frame
  27414. */
  27415. beginFrame(): void;
  27416. /**
  27417. * Enf the current frame
  27418. */
  27419. endFrame(): void;
  27420. /**
  27421. * Resize the view according to the canvas' size
  27422. */
  27423. resize(): void;
  27424. /**
  27425. * Force a specific size of the canvas
  27426. * @param width defines the new canvas' width
  27427. * @param height defines the new canvas' height
  27428. */
  27429. setSize(width: number, height: number): void;
  27430. /**
  27431. * Gets a boolean indicating if a webVR device was detected
  27432. * @returns true if a webVR device was detected
  27433. */
  27434. isVRDevicePresent(): boolean;
  27435. /**
  27436. * Gets the current webVR device
  27437. * @returns the current webVR device (or null)
  27438. */
  27439. getVRDevice(): any;
  27440. /**
  27441. * Initializes a webVR display and starts listening to display change events
  27442. * The onVRDisplayChangedObservable will be notified upon these changes
  27443. * @returns The onVRDisplayChangedObservable
  27444. */
  27445. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27446. /**
  27447. * Initializes a webVR display and starts listening to display change events
  27448. * The onVRDisplayChangedObservable will be notified upon these changes
  27449. * @returns A promise containing a VRDisplay and if vr is supported
  27450. */
  27451. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27452. /**
  27453. * Call this function to switch to webVR mode
  27454. * Will do nothing if webVR is not supported or if there is no webVR device
  27455. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27456. */
  27457. enableVR(): void;
  27458. /**
  27459. * Call this function to leave webVR mode
  27460. * Will do nothing if webVR is not supported or if there is no webVR device
  27461. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27462. */
  27463. disableVR(): void;
  27464. private _onVRFullScreenTriggered;
  27465. private _getVRDisplaysAsync;
  27466. /**
  27467. * Binds the frame buffer to the specified texture.
  27468. * @param texture The texture to render to or null for the default canvas
  27469. * @param faceIndex The face of the texture to render to in case of cube texture
  27470. * @param requiredWidth The width of the target to render to
  27471. * @param requiredHeight The height of the target to render to
  27472. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27473. * @param depthStencilTexture The depth stencil texture to use to render
  27474. * @param lodLevel defines le lod level to bind to the frame buffer
  27475. */
  27476. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27477. /** @hidden */ bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  27478. /**
  27479. * Unbind the current render target texture from the webGL context
  27480. * @param texture defines the render target texture to unbind
  27481. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27482. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27483. */
  27484. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27485. /**
  27486. * Force the mipmap generation for the given render target texture
  27487. * @param texture defines the render target texture to use
  27488. */
  27489. generateMipMapsForCubemap(texture: InternalTexture): void;
  27490. /**
  27491. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27492. */
  27493. flushFramebuffer(): void;
  27494. /**
  27495. * Unbind the current render target and bind the default framebuffer
  27496. */
  27497. restoreDefaultFramebuffer(): void;
  27498. /**
  27499. * Create an uniform buffer
  27500. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27501. * @param elements defines the content of the uniform buffer
  27502. * @returns the webGL uniform buffer
  27503. */
  27504. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27505. /**
  27506. * Create a dynamic uniform buffer
  27507. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27508. * @param elements defines the content of the uniform buffer
  27509. * @returns the webGL uniform buffer
  27510. */
  27511. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27512. /**
  27513. * Update an existing uniform buffer
  27514. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27515. * @param uniformBuffer defines the target uniform buffer
  27516. * @param elements defines the content to update
  27517. * @param offset defines the offset in the uniform buffer where update should start
  27518. * @param count defines the size of the data to update
  27519. */
  27520. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27521. private _resetVertexBufferBinding;
  27522. /**
  27523. * Creates a vertex buffer
  27524. * @param data the data for the vertex buffer
  27525. * @returns the new WebGL static buffer
  27526. */
  27527. createVertexBuffer(data: DataArray): WebGLBuffer;
  27528. /**
  27529. * Creates a dynamic vertex buffer
  27530. * @param data the data for the dynamic vertex buffer
  27531. * @returns the new WebGL dynamic buffer
  27532. */
  27533. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27534. /**
  27535. * Update a dynamic index buffer
  27536. * @param indexBuffer defines the target index buffer
  27537. * @param indices defines the data to update
  27538. * @param offset defines the offset in the target index buffer where update should start
  27539. */
  27540. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27541. /**
  27542. * Updates a dynamic vertex buffer.
  27543. * @param vertexBuffer the vertex buffer to update
  27544. * @param data the data used to update the vertex buffer
  27545. * @param byteOffset the byte offset of the data
  27546. * @param byteLength the byte length of the data
  27547. */
  27548. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27549. private _resetIndexBufferBinding;
  27550. /**
  27551. * Creates a new index buffer
  27552. * @param indices defines the content of the index buffer
  27553. * @param updatable defines if the index buffer must be updatable
  27554. * @returns a new webGL buffer
  27555. */
  27556. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27557. /**
  27558. * Bind a webGL buffer to the webGL context
  27559. * @param buffer defines the buffer to bind
  27560. */
  27561. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27562. /**
  27563. * Bind an uniform buffer to the current webGL context
  27564. * @param buffer defines the buffer to bind
  27565. */
  27566. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27567. /**
  27568. * Bind a buffer to the current webGL context at a given location
  27569. * @param buffer defines the buffer to bind
  27570. * @param location defines the index where to bind the buffer
  27571. */
  27572. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27573. /**
  27574. * Bind a specific block at a given index in a specific shader program
  27575. * @param shaderProgram defines the shader program
  27576. * @param blockName defines the block name
  27577. * @param index defines the index where to bind the block
  27578. */
  27579. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27580. private bindIndexBuffer;
  27581. private bindBuffer;
  27582. /**
  27583. * update the bound buffer with the given data
  27584. * @param data defines the data to update
  27585. */
  27586. updateArrayBuffer(data: Float32Array): void;
  27587. private _vertexAttribPointer;
  27588. private _bindIndexBufferWithCache;
  27589. private _bindVertexBuffersAttributes;
  27590. /**
  27591. * Records a vertex array object
  27592. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27593. * @param vertexBuffers defines the list of vertex buffers to store
  27594. * @param indexBuffer defines the index buffer to store
  27595. * @param effect defines the effect to store
  27596. * @returns the new vertex array object
  27597. */
  27598. recordVertexArrayObject(vertexBuffers: {
  27599. [key: string]: VertexBuffer;
  27600. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27601. /**
  27602. * Bind a specific vertex array object
  27603. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27604. * @param vertexArrayObject defines the vertex array object to bind
  27605. * @param indexBuffer defines the index buffer to bind
  27606. */
  27607. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27608. /**
  27609. * Bind webGl buffers directly to the webGL context
  27610. * @param vertexBuffer defines the vertex buffer to bind
  27611. * @param indexBuffer defines the index buffer to bind
  27612. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27613. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27614. * @param effect defines the effect associated with the vertex buffer
  27615. */
  27616. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27617. private _unbindVertexArrayObject;
  27618. /**
  27619. * Bind a list of vertex buffers to the webGL context
  27620. * @param vertexBuffers defines the list of vertex buffers to bind
  27621. * @param indexBuffer defines the index buffer to bind
  27622. * @param effect defines the effect associated with the vertex buffers
  27623. */
  27624. bindBuffers(vertexBuffers: {
  27625. [key: string]: Nullable<VertexBuffer>;
  27626. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27627. /**
  27628. * Unbind all instance attributes
  27629. */
  27630. unbindInstanceAttributes(): void;
  27631. /**
  27632. * Release and free the memory of a vertex array object
  27633. * @param vao defines the vertex array object to delete
  27634. */
  27635. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27636. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  27637. /**
  27638. * Creates a webGL buffer to use with instanciation
  27639. * @param capacity defines the size of the buffer
  27640. * @returns the webGL buffer
  27641. */
  27642. createInstancesBuffer(capacity: number): WebGLBuffer;
  27643. /**
  27644. * Delete a webGL buffer used with instanciation
  27645. * @param buffer defines the webGL buffer to delete
  27646. */
  27647. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27648. /**
  27649. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27650. * @param instancesBuffer defines the webGL buffer to update and bind
  27651. * @param data defines the data to store in the buffer
  27652. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27653. */
  27654. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27655. /**
  27656. * Apply all cached states (depth, culling, stencil and alpha)
  27657. */
  27658. applyStates(): void;
  27659. /**
  27660. * Send a draw order
  27661. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27662. * @param indexStart defines the starting index
  27663. * @param indexCount defines the number of index to draw
  27664. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27665. */
  27666. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27667. /**
  27668. * Draw a list of points
  27669. * @param verticesStart defines the index of first vertex to draw
  27670. * @param verticesCount defines the count of vertices to draw
  27671. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27672. */
  27673. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27674. /**
  27675. * Draw a list of unindexed primitives
  27676. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27677. * @param verticesStart defines the index of first vertex to draw
  27678. * @param verticesCount defines the count of vertices to draw
  27679. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27680. */
  27681. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27682. /**
  27683. * Draw a list of indexed primitives
  27684. * @param fillMode defines the primitive to use
  27685. * @param indexStart defines the starting index
  27686. * @param indexCount defines the number of index to draw
  27687. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27688. */
  27689. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27690. /**
  27691. * Draw a list of unindexed primitives
  27692. * @param fillMode defines the primitive to use
  27693. * @param verticesStart defines the index of first vertex to draw
  27694. * @param verticesCount defines the count of vertices to draw
  27695. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27696. */
  27697. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27698. private _drawMode;
  27699. /** @hidden */ releaseEffect(effect: Effect): void;
  27700. /** @hidden */ deleteProgram(program: WebGLProgram): void;
  27701. /**
  27702. * Create a new effect (used to store vertex/fragment shaders)
  27703. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27704. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27705. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27706. * @param samplers defines an array of string used to represent textures
  27707. * @param defines defines the string containing the defines to use to compile the shaders
  27708. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27709. * @param onCompiled defines a function to call when the effect creation is successful
  27710. * @param onError defines a function to call when the effect creation has failed
  27711. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27712. * @returns the new Effect
  27713. */
  27714. 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;
  27715. private _compileShader;
  27716. private _compileRawShader;
  27717. /**
  27718. * Directly creates a webGL program
  27719. * @param vertexCode defines the vertex shader code to use
  27720. * @param fragmentCode defines the fragment shader code to use
  27721. * @param context defines the webGL context to use (if not set, the current one will be used)
  27722. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27723. * @returns the new webGL program
  27724. */
  27725. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27726. /**
  27727. * Creates a webGL program
  27728. * @param vertexCode defines the vertex shader code to use
  27729. * @param fragmentCode defines the fragment shader code to use
  27730. * @param defines defines the string containing the defines to use to compile the shaders
  27731. * @param context defines the webGL context to use (if not set, the current one will be used)
  27732. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27733. * @returns the new webGL program
  27734. */
  27735. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27736. private _createShaderProgram;
  27737. private _finalizeProgram;
  27738. /** @hidden */ isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  27739. /** @hidden */ executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  27740. /**
  27741. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27742. * @param shaderProgram defines the webGL program to use
  27743. * @param uniformsNames defines the list of uniform names
  27744. * @returns an array of webGL uniform locations
  27745. */
  27746. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27747. /**
  27748. * Gets the lsit of active attributes for a given webGL program
  27749. * @param shaderProgram defines the webGL program to use
  27750. * @param attributesNames defines the list of attribute names to get
  27751. * @returns an array of indices indicating the offset of each attribute
  27752. */
  27753. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  27754. /**
  27755. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27756. * @param effect defines the effect to activate
  27757. */
  27758. enableEffect(effect: Nullable<Effect>): void;
  27759. /**
  27760. * Set the value of an uniform to an array of int32
  27761. * @param uniform defines the webGL uniform location where to store the value
  27762. * @param array defines the array of int32 to store
  27763. */
  27764. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27765. /**
  27766. * Set the value of an uniform to an array of int32 (stored as vec2)
  27767. * @param uniform defines the webGL uniform location where to store the value
  27768. * @param array defines the array of int32 to store
  27769. */
  27770. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27771. /**
  27772. * Set the value of an uniform to an array of int32 (stored as vec3)
  27773. * @param uniform defines the webGL uniform location where to store the value
  27774. * @param array defines the array of int32 to store
  27775. */
  27776. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27777. /**
  27778. * Set the value of an uniform to an array of int32 (stored as vec4)
  27779. * @param uniform defines the webGL uniform location where to store the value
  27780. * @param array defines the array of int32 to store
  27781. */
  27782. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27783. /**
  27784. * Set the value of an uniform to an array of float32
  27785. * @param uniform defines the webGL uniform location where to store the value
  27786. * @param array defines the array of float32 to store
  27787. */
  27788. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27789. /**
  27790. * Set the value of an uniform to an array of float32 (stored as vec2)
  27791. * @param uniform defines the webGL uniform location where to store the value
  27792. * @param array defines the array of float32 to store
  27793. */
  27794. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27795. /**
  27796. * Set the value of an uniform to an array of float32 (stored as vec3)
  27797. * @param uniform defines the webGL uniform location where to store the value
  27798. * @param array defines the array of float32 to store
  27799. */
  27800. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27801. /**
  27802. * Set the value of an uniform to an array of float32 (stored as vec4)
  27803. * @param uniform defines the webGL uniform location where to store the value
  27804. * @param array defines the array of float32 to store
  27805. */
  27806. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27807. /**
  27808. * Set the value of an uniform to an array of number
  27809. * @param uniform defines the webGL uniform location where to store the value
  27810. * @param array defines the array of number to store
  27811. */
  27812. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27813. /**
  27814. * Set the value of an uniform to an array of number (stored as vec2)
  27815. * @param uniform defines the webGL uniform location where to store the value
  27816. * @param array defines the array of number to store
  27817. */
  27818. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27819. /**
  27820. * Set the value of an uniform to an array of number (stored as vec3)
  27821. * @param uniform defines the webGL uniform location where to store the value
  27822. * @param array defines the array of number to store
  27823. */
  27824. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27825. /**
  27826. * Set the value of an uniform to an array of number (stored as vec4)
  27827. * @param uniform defines the webGL uniform location where to store the value
  27828. * @param array defines the array of number to store
  27829. */
  27830. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27831. /**
  27832. * Set the value of an uniform to an array of float32 (stored as matrices)
  27833. * @param uniform defines the webGL uniform location where to store the value
  27834. * @param matrices defines the array of float32 to store
  27835. */
  27836. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27837. /**
  27838. * Set the value of an uniform to a matrix
  27839. * @param uniform defines the webGL uniform location where to store the value
  27840. * @param matrix defines the matrix to store
  27841. */
  27842. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27843. /**
  27844. * Set the value of an uniform to a matrix (3x3)
  27845. * @param uniform defines the webGL uniform location where to store the value
  27846. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27847. */
  27848. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27849. /**
  27850. * Set the value of an uniform to a matrix (2x2)
  27851. * @param uniform defines the webGL uniform location where to store the value
  27852. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27853. */
  27854. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27855. /**
  27856. * Set the value of an uniform to a number (int)
  27857. * @param uniform defines the webGL uniform location where to store the value
  27858. * @param value defines the int number to store
  27859. */
  27860. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27861. /**
  27862. * Set the value of an uniform to a number (float)
  27863. * @param uniform defines the webGL uniform location where to store the value
  27864. * @param value defines the float number to store
  27865. */
  27866. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27867. /**
  27868. * Set the value of an uniform to a vec2
  27869. * @param uniform defines the webGL uniform location where to store the value
  27870. * @param x defines the 1st component of the value
  27871. * @param y defines the 2nd component of the value
  27872. */
  27873. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27874. /**
  27875. * Set the value of an uniform to a vec3
  27876. * @param uniform defines the webGL uniform location where to store the value
  27877. * @param x defines the 1st component of the value
  27878. * @param y defines the 2nd component of the value
  27879. * @param z defines the 3rd component of the value
  27880. */
  27881. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27882. /**
  27883. * Set the value of an uniform to a boolean
  27884. * @param uniform defines the webGL uniform location where to store the value
  27885. * @param bool defines the boolean to store
  27886. */
  27887. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27888. /**
  27889. * Set the value of an uniform to a vec4
  27890. * @param uniform defines the webGL uniform location where to store the value
  27891. * @param x defines the 1st component of the value
  27892. * @param y defines the 2nd component of the value
  27893. * @param z defines the 3rd component of the value
  27894. * @param w defines the 4th component of the value
  27895. */
  27896. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27897. /**
  27898. * Set the value of an uniform to a Color3
  27899. * @param uniform defines the webGL uniform location where to store the value
  27900. * @param color3 defines the color to store
  27901. */
  27902. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27903. /**
  27904. * Set the value of an uniform to a Color3 and an alpha value
  27905. * @param uniform defines the webGL uniform location where to store the value
  27906. * @param color3 defines the color to store
  27907. * @param alpha defines the alpha component to store
  27908. */
  27909. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27910. /**
  27911. * Sets a Color4 on a uniform variable
  27912. * @param uniform defines the uniform location
  27913. * @param color4 defines the value to be set
  27914. */
  27915. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27916. /**
  27917. * Set various states to the webGL context
  27918. * @param culling defines backface culling state
  27919. * @param zOffset defines the value to apply to zOffset (0 by default)
  27920. * @param force defines if states must be applied even if cache is up to date
  27921. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27922. */
  27923. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27924. /**
  27925. * Set the z offset to apply to current rendering
  27926. * @param value defines the offset to apply
  27927. */
  27928. setZOffset(value: number): void;
  27929. /**
  27930. * Gets the current value of the zOffset
  27931. * @returns the current zOffset state
  27932. */
  27933. getZOffset(): number;
  27934. /**
  27935. * Enable or disable depth buffering
  27936. * @param enable defines the state to set
  27937. */
  27938. setDepthBuffer(enable: boolean): void;
  27939. /**
  27940. * Gets a boolean indicating if depth writing is enabled
  27941. * @returns the current depth writing state
  27942. */
  27943. getDepthWrite(): boolean;
  27944. /**
  27945. * Enable or disable depth writing
  27946. * @param enable defines the state to set
  27947. */
  27948. setDepthWrite(enable: boolean): void;
  27949. /**
  27950. * Enable or disable color writing
  27951. * @param enable defines the state to set
  27952. */
  27953. setColorWrite(enable: boolean): void;
  27954. /**
  27955. * Gets a boolean indicating if color writing is enabled
  27956. * @returns the current color writing state
  27957. */
  27958. getColorWrite(): boolean;
  27959. /**
  27960. * Sets alpha constants used by some alpha blending modes
  27961. * @param r defines the red component
  27962. * @param g defines the green component
  27963. * @param b defines the blue component
  27964. * @param a defines the alpha component
  27965. */
  27966. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  27967. /**
  27968. * Sets the current alpha mode
  27969. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  27970. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  27971. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27972. */
  27973. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  27974. /**
  27975. * Gets the current alpha mode
  27976. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27977. * @returns the current alpha mode
  27978. */
  27979. getAlphaMode(): number;
  27980. /**
  27981. * Clears the list of texture accessible through engine.
  27982. * This can help preventing texture load conflict due to name collision.
  27983. */
  27984. clearInternalTexturesCache(): void;
  27985. /**
  27986. * Force the entire cache to be cleared
  27987. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  27988. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  27989. */
  27990. wipeCaches(bruteForce?: boolean): void;
  27991. /**
  27992. * Set the compressed texture format to use, based on the formats you have, and the formats
  27993. * supported by the hardware / browser.
  27994. *
  27995. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  27996. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  27997. * to API arguments needed to compressed textures. This puts the burden on the container
  27998. * generator to house the arcane code for determining these for current & future formats.
  27999. *
  28000. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28001. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28002. *
  28003. * Note: The result of this call is not taken into account when a texture is base64.
  28004. *
  28005. * @param formatsAvailable defines the list of those format families you have created
  28006. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28007. *
  28008. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28009. * @returns The extension selected.
  28010. */
  28011. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28012. /** @hidden */ getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28013. min: number;
  28014. mag: number;
  28015. };
  28016. /** @hidden */ createTexture(): WebGLTexture;
  28017. /**
  28018. * Usually called from Texture.ts.
  28019. * Passed information to create a WebGLTexture
  28020. * @param urlArg defines a value which contains one of the following:
  28021. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28022. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28023. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28024. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28025. * @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)
  28026. * @param scene needed for loading to the correct scene
  28027. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28028. * @param onLoad optional callback to be called upon successful completion
  28029. * @param onError optional callback to be called upon failure
  28030. * @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
  28031. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28032. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28033. * @param forcedExtension defines the extension to use to pick the right loader
  28034. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28035. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28036. */
  28037. 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;
  28038. private _rescaleTexture;
  28039. private _unpackFlipYCached;
  28040. /**
  28041. * In case you are sharing the context with other applications, it might
  28042. * be interested to not cache the unpack flip y state to ensure a consistent
  28043. * value would be set.
  28044. */
  28045. enableUnpackFlipYCached: boolean;
  28046. /** @hidden */ unpackFlipY(value: boolean): void;
  28047. /** @hidden */ getUnpackAlignement(): number;
  28048. /**
  28049. * Creates a dynamic texture
  28050. * @param width defines the width of the texture
  28051. * @param height defines the height of the texture
  28052. * @param generateMipMaps defines if the engine should generate the mip levels
  28053. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28054. * @returns the dynamic texture inside an InternalTexture
  28055. */
  28056. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28057. /**
  28058. * Update the sampling mode of a given texture
  28059. * @param samplingMode defines the required sampling mode
  28060. * @param texture defines the texture to update
  28061. */
  28062. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28063. /**
  28064. * Update the content of a dynamic texture
  28065. * @param texture defines the texture to update
  28066. * @param canvas defines the canvas containing the source
  28067. * @param invertY defines if data must be stored with Y axis inverted
  28068. * @param premulAlpha defines if alpha is stored as premultiplied
  28069. * @param format defines the format of the data
  28070. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28071. */
  28072. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28073. /**
  28074. * Update a video texture
  28075. * @param texture defines the texture to update
  28076. * @param video defines the video element to use
  28077. * @param invertY defines if data must be stored with Y axis inverted
  28078. */
  28079. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28080. /**
  28081. * Updates a depth texture Comparison Mode and Function.
  28082. * If the comparison Function is equal to 0, the mode will be set to none.
  28083. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28084. * @param texture The texture to set the comparison function for
  28085. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28086. */
  28087. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28088. /** @hidden */ setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28089. width: number;
  28090. height: number;
  28091. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28092. /**
  28093. * Creates a depth stencil texture.
  28094. * This is only available in WebGL 2 or with the depth texture extension available.
  28095. * @param size The size of face edge in the texture.
  28096. * @param options The options defining the texture.
  28097. * @returns The texture
  28098. */
  28099. createDepthStencilTexture(size: number | {
  28100. width: number;
  28101. height: number;
  28102. }, options: DepthTextureCreationOptions): InternalTexture;
  28103. /**
  28104. * Creates a depth stencil texture.
  28105. * This is only available in WebGL 2 or with the depth texture extension available.
  28106. * @param size The size of face edge in the texture.
  28107. * @param options The options defining the texture.
  28108. * @returns The texture
  28109. */
  28110. private _createDepthStencilTexture;
  28111. /**
  28112. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28113. * @param renderTarget The render target to set the frame buffer for
  28114. */
  28115. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28116. /**
  28117. * Creates a new render target texture
  28118. * @param size defines the size of the texture
  28119. * @param options defines the options used to create the texture
  28120. * @returns a new render target texture stored in an InternalTexture
  28121. */
  28122. createRenderTargetTexture(size: number | {
  28123. width: number;
  28124. height: number;
  28125. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28126. /** @hidden */ setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28127. /**
  28128. * Updates the sample count of a render target texture
  28129. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28130. * @param texture defines the texture to update
  28131. * @param samples defines the sample count to set
  28132. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28133. */
  28134. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28135. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28136. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28137. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28138. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28139. /**
  28140. * @hidden
  28141. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  28142. private _prepareWebGLTextureContinuation;
  28143. private _prepareWebGLTexture;
  28144. /** @hidden */ convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28145. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  28146. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  28147. private setProgram;
  28148. private _boundUniforms;
  28149. /**
  28150. * Binds an effect to the webGL context
  28151. * @param effect defines the effect to bind
  28152. */
  28153. bindSamplers(effect: Effect): void;
  28154. private _activateCurrentTexture;
  28155. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28156. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28157. /**
  28158. * Sets a texture to the webGL context from a postprocess
  28159. * @param channel defines the channel to use
  28160. * @param postProcess defines the source postprocess
  28161. */
  28162. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28163. /**
  28164. * Binds the output of the passed in post process to the texture channel specified
  28165. * @param channel The channel the texture should be bound to
  28166. * @param postProcess The post process which's output should be bound
  28167. */
  28168. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28169. /**
  28170. * Unbind all textures from the webGL context
  28171. */
  28172. unbindAllTextures(): void;
  28173. /**
  28174. * Sets a texture to the according uniform.
  28175. * @param channel The texture channel
  28176. * @param uniform The uniform to set
  28177. * @param texture The texture to apply
  28178. */
  28179. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28180. /**
  28181. * Sets a depth stencil texture from a render target to the according uniform.
  28182. * @param channel The texture channel
  28183. * @param uniform The uniform to set
  28184. * @param texture The render target texture containing the depth stencil texture to apply
  28185. */
  28186. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28187. private _bindSamplerUniformToChannel;
  28188. private _getTextureWrapMode;
  28189. private _setTexture;
  28190. /**
  28191. * Sets an array of texture to the webGL context
  28192. * @param channel defines the channel where the texture array must be set
  28193. * @param uniform defines the associated uniform location
  28194. * @param textures defines the array of textures to bind
  28195. */
  28196. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28197. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28198. private _setTextureParameterFloat;
  28199. private _setTextureParameterInteger;
  28200. /**
  28201. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28202. * @param x defines the x coordinate of the rectangle where pixels must be read
  28203. * @param y defines the y coordinate of the rectangle where pixels must be read
  28204. * @param width defines the width of the rectangle where pixels must be read
  28205. * @param height defines the height of the rectangle where pixels must be read
  28206. * @returns a Uint8Array containing RGBA colors
  28207. */
  28208. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28209. /**
  28210. * Add an externaly attached data from its key.
  28211. * This method call will fail and return false, if such key already exists.
  28212. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28213. * @param key the unique key that identifies the data
  28214. * @param data the data object to associate to the key for this Engine instance
  28215. * @return true if no such key were already present and the data was added successfully, false otherwise
  28216. */
  28217. addExternalData<T>(key: string, data: T): boolean;
  28218. /**
  28219. * Get an externaly attached data from its key
  28220. * @param key the unique key that identifies the data
  28221. * @return the associated data, if present (can be null), or undefined if not present
  28222. */
  28223. getExternalData<T>(key: string): T;
  28224. /**
  28225. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28226. * @param key the unique key that identifies the data
  28227. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28228. * @return the associated data, can be null if the factory returned null.
  28229. */
  28230. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28231. /**
  28232. * Remove an externaly attached data from the Engine instance
  28233. * @param key the unique key that identifies the data
  28234. * @return true if the data was successfully removed, false if it doesn't exist
  28235. */
  28236. removeExternalData(key: string): boolean;
  28237. /**
  28238. * Unbind all vertex attributes from the webGL context
  28239. */
  28240. unbindAllAttributes(): void;
  28241. /**
  28242. * 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
  28243. */
  28244. releaseEffects(): void;
  28245. /**
  28246. * Dispose and release all associated resources
  28247. */
  28248. dispose(): void;
  28249. /**
  28250. * Display the loading screen
  28251. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28252. */
  28253. displayLoadingUI(): void;
  28254. /**
  28255. * Hide the loading screen
  28256. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28257. */
  28258. hideLoadingUI(): void;
  28259. /**
  28260. * Gets the current loading screen object
  28261. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28262. */
  28263. /**
  28264. * Sets the current loading screen object
  28265. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28266. */
  28267. loadingScreen: ILoadingScreen;
  28268. /**
  28269. * Sets the current loading screen text
  28270. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28271. */
  28272. loadingUIText: string;
  28273. /**
  28274. * Sets the current loading screen background color
  28275. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28276. */
  28277. loadingUIBackgroundColor: string;
  28278. /**
  28279. * Attach a new callback raised when context lost event is fired
  28280. * @param callback defines the callback to call
  28281. */
  28282. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28283. /**
  28284. * Attach a new callback raised when context restored event is fired
  28285. * @param callback defines the callback to call
  28286. */
  28287. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28288. /**
  28289. * Gets the source code of the vertex shader associated with a specific webGL program
  28290. * @param program defines the program to use
  28291. * @returns a string containing the source code of the vertex shader associated with the program
  28292. */
  28293. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28294. /**
  28295. * Gets the source code of the fragment shader associated with a specific webGL program
  28296. * @param program defines the program to use
  28297. * @returns a string containing the source code of the fragment shader associated with the program
  28298. */
  28299. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28300. /**
  28301. * Get the current error code of the webGL context
  28302. * @returns the error code
  28303. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28304. */
  28305. getError(): number;
  28306. /**
  28307. * Gets the current framerate
  28308. * @returns a number representing the framerate
  28309. */
  28310. getFps(): number;
  28311. /**
  28312. * Gets the time spent between current and previous frame
  28313. * @returns a number representing the delta time in ms
  28314. */
  28315. getDeltaTime(): number;
  28316. private _measureFps;
  28317. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28318. private _canRenderToFloatFramebuffer;
  28319. private _canRenderToHalfFloatFramebuffer;
  28320. private _canRenderToFramebuffer;
  28321. /** @hidden */ getWebGLTextureType(type: number): number;
  28322. /** @hidden */ getInternalFormat(format: number): number;
  28323. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28324. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  28325. /** @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;
  28326. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28327. /**
  28328. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28329. * @returns true if the engine can be created
  28330. * @ignorenaming
  28331. */
  28332. static isSupported(): boolean;
  28333. }
  28334. }
  28335. declare module BABYLON {
  28336. /**
  28337. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28338. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28339. */
  28340. export class EffectFallbacks {
  28341. private _defines;
  28342. private _currentRank;
  28343. private _maxRank;
  28344. private _mesh;
  28345. /**
  28346. * Removes the fallback from the bound mesh.
  28347. */
  28348. unBindMesh(): void;
  28349. /**
  28350. * Adds a fallback on the specified property.
  28351. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28352. * @param define The name of the define in the shader
  28353. */
  28354. addFallback(rank: number, define: string): void;
  28355. /**
  28356. * Sets the mesh to use CPU skinning when needing to fallback.
  28357. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28358. * @param mesh The mesh to use the fallbacks.
  28359. */
  28360. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28361. /**
  28362. * Checks to see if more fallbacks are still availible.
  28363. */
  28364. readonly isMoreFallbacks: boolean;
  28365. /**
  28366. * Removes the defines that shoould be removed when falling back.
  28367. * @param currentDefines defines the current define statements for the shader.
  28368. * @param effect defines the current effect we try to compile
  28369. * @returns The resulting defines with defines of the current rank removed.
  28370. */
  28371. reduce(currentDefines: string, effect: Effect): string;
  28372. }
  28373. /**
  28374. * Options to be used when creating an effect.
  28375. */
  28376. export class EffectCreationOptions {
  28377. /**
  28378. * Atrributes that will be used in the shader.
  28379. */
  28380. attributes: string[];
  28381. /**
  28382. * Uniform varible names that will be set in the shader.
  28383. */
  28384. uniformsNames: string[];
  28385. /**
  28386. * Uniform buffer varible names that will be set in the shader.
  28387. */
  28388. uniformBuffersNames: string[];
  28389. /**
  28390. * Sampler texture variable names that will be set in the shader.
  28391. */
  28392. samplers: string[];
  28393. /**
  28394. * Define statements that will be set in the shader.
  28395. */
  28396. defines: any;
  28397. /**
  28398. * Possible fallbacks for this effect to improve performance when needed.
  28399. */
  28400. fallbacks: Nullable<EffectFallbacks>;
  28401. /**
  28402. * Callback that will be called when the shader is compiled.
  28403. */
  28404. onCompiled: Nullable<(effect: Effect) => void>;
  28405. /**
  28406. * Callback that will be called if an error occurs during shader compilation.
  28407. */
  28408. onError: Nullable<(effect: Effect, errors: string) => void>;
  28409. /**
  28410. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28411. */
  28412. indexParameters: any;
  28413. /**
  28414. * Max number of lights that can be used in the shader.
  28415. */
  28416. maxSimultaneousLights: number;
  28417. /**
  28418. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28419. */
  28420. transformFeedbackVaryings: Nullable<string[]>;
  28421. }
  28422. /**
  28423. * Effect containing vertex and fragment shader that can be executed on an object.
  28424. */
  28425. export class Effect implements IDisposable {
  28426. /**
  28427. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28428. */
  28429. static ShadersRepository: string;
  28430. /**
  28431. * Name of the effect.
  28432. */
  28433. name: any;
  28434. /**
  28435. * String container all the define statements that should be set on the shader.
  28436. */
  28437. defines: string;
  28438. /**
  28439. * Callback that will be called when the shader is compiled.
  28440. */
  28441. onCompiled: Nullable<(effect: Effect) => void>;
  28442. /**
  28443. * Callback that will be called if an error occurs during shader compilation.
  28444. */
  28445. onError: Nullable<(effect: Effect, errors: string) => void>;
  28446. /**
  28447. * Callback that will be called when effect is bound.
  28448. */
  28449. onBind: Nullable<(effect: Effect) => void>;
  28450. /**
  28451. * Unique ID of the effect.
  28452. */
  28453. uniqueId: number;
  28454. /**
  28455. * Observable that will be called when the shader is compiled.
  28456. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28457. */
  28458. onCompileObservable: Observable<Effect>;
  28459. /**
  28460. * Observable that will be called if an error occurs during shader compilation.
  28461. */
  28462. onErrorObservable: Observable<Effect>;
  28463. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  28464. /**
  28465. * Observable that will be called when effect is bound.
  28466. */
  28467. readonly onBindObservable: Observable<Effect>;
  28468. /** @hidden */ bonesComputationForcedToCPU: boolean;
  28469. private static _uniqueIdSeed;
  28470. private _engine;
  28471. private _uniformBuffersNames;
  28472. private _uniformsNames;
  28473. private _samplerList;
  28474. private _samplers;
  28475. private _isReady;
  28476. private _compilationError;
  28477. private _attributesNames;
  28478. private _attributes;
  28479. private _uniforms;
  28480. /**
  28481. * Key for the effect.
  28482. * @hidden
  28483. */ key: string;
  28484. private _indexParameters;
  28485. private _fallbacks;
  28486. private _vertexSourceCode;
  28487. private _fragmentSourceCode;
  28488. private _vertexSourceCodeOverride;
  28489. private _fragmentSourceCodeOverride;
  28490. private _transformFeedbackVaryings;
  28491. /**
  28492. * Compiled shader to webGL program.
  28493. * @hidden
  28494. */ program: WebGLProgram;
  28495. private _valueCache;
  28496. private static _baseCache;
  28497. /**
  28498. * Instantiates an effect.
  28499. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28500. * @param baseName Name of the effect.
  28501. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28502. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28503. * @param samplers List of sampler variables that will be passed to the shader.
  28504. * @param engine Engine to be used to render the effect
  28505. * @param defines Define statements to be added to the shader.
  28506. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28507. * @param onCompiled Callback that will be called when the shader is compiled.
  28508. * @param onError Callback that will be called if an error occurs during shader compilation.
  28509. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28510. */
  28511. 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);
  28512. /**
  28513. * Unique key for this effect
  28514. */
  28515. readonly key: string;
  28516. /**
  28517. * If the effect has been compiled and prepared.
  28518. * @returns if the effect is compiled and prepared.
  28519. */
  28520. isReady(): boolean;
  28521. /**
  28522. * The engine the effect was initialized with.
  28523. * @returns the engine.
  28524. */
  28525. getEngine(): Engine;
  28526. /**
  28527. * The compiled webGL program for the effect
  28528. * @returns the webGL program.
  28529. */
  28530. getProgram(): WebGLProgram;
  28531. /**
  28532. * The set of names of attribute variables for the shader.
  28533. * @returns An array of attribute names.
  28534. */
  28535. getAttributesNames(): string[];
  28536. /**
  28537. * Returns the attribute at the given index.
  28538. * @param index The index of the attribute.
  28539. * @returns The location of the attribute.
  28540. */
  28541. getAttributeLocation(index: number): number;
  28542. /**
  28543. * Returns the attribute based on the name of the variable.
  28544. * @param name of the attribute to look up.
  28545. * @returns the attribute location.
  28546. */
  28547. getAttributeLocationByName(name: string): number;
  28548. /**
  28549. * The number of attributes.
  28550. * @returns the numnber of attributes.
  28551. */
  28552. getAttributesCount(): number;
  28553. /**
  28554. * Gets the index of a uniform variable.
  28555. * @param uniformName of the uniform to look up.
  28556. * @returns the index.
  28557. */
  28558. getUniformIndex(uniformName: string): number;
  28559. /**
  28560. * Returns the attribute based on the name of the variable.
  28561. * @param uniformName of the uniform to look up.
  28562. * @returns the location of the uniform.
  28563. */
  28564. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28565. /**
  28566. * Returns an array of sampler variable names
  28567. * @returns The array of sampler variable neames.
  28568. */
  28569. getSamplers(): string[];
  28570. /**
  28571. * The error from the last compilation.
  28572. * @returns the error string.
  28573. */
  28574. getCompilationError(): string;
  28575. /**
  28576. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28577. * @param func The callback to be used.
  28578. */
  28579. executeWhenCompiled(func: (effect: Effect) => void): void;
  28580. private _checkIsReady;
  28581. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28582. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28583. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28584. private _processShaderConversion;
  28585. private _processIncludes;
  28586. private _processPrecision;
  28587. /**
  28588. * Recompiles the webGL program
  28589. * @param vertexSourceCode The source code for the vertex shader.
  28590. * @param fragmentSourceCode The source code for the fragment shader.
  28591. * @param onCompiled Callback called when completed.
  28592. * @param onError Callback called on error.
  28593. * @hidden
  28594. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  28595. /**
  28596. * Gets the uniform locations of the the specified variable names
  28597. * @param names THe names of the variables to lookup.
  28598. * @returns Array of locations in the same order as variable names.
  28599. */
  28600. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  28601. /**
  28602. * Prepares the effect
  28603. * @hidden
  28604. */ prepareEffect(): void;
  28605. /**
  28606. * Checks if the effect is supported. (Must be called after compilation)
  28607. */
  28608. readonly isSupported: boolean;
  28609. /**
  28610. * Binds a texture to the engine to be used as output of the shader.
  28611. * @param channel Name of the output variable.
  28612. * @param texture Texture to bind.
  28613. * @hidden
  28614. */ bindTexture(channel: string, texture: InternalTexture): void;
  28615. /**
  28616. * Sets a texture on the engine to be used in the shader.
  28617. * @param channel Name of the sampler variable.
  28618. * @param texture Texture to set.
  28619. */
  28620. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28621. /**
  28622. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28623. * @param channel Name of the sampler variable.
  28624. * @param texture Texture to set.
  28625. */
  28626. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28627. /**
  28628. * Sets an array of textures on the engine to be used in the shader.
  28629. * @param channel Name of the variable.
  28630. * @param textures Textures to set.
  28631. */
  28632. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28633. /**
  28634. * 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)
  28635. * @param channel Name of the sampler variable.
  28636. * @param postProcess Post process to get the input texture from.
  28637. */
  28638. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28639. /**
  28640. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28641. * 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)
  28642. * @param channel Name of the sampler variable.
  28643. * @param postProcess Post process to get the output texture from.
  28644. */
  28645. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28646. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28647. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28648. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28649. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28650. /**
  28651. * Binds a buffer to a uniform.
  28652. * @param buffer Buffer to bind.
  28653. * @param name Name of the uniform variable to bind to.
  28654. */
  28655. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  28656. /**
  28657. * Binds block to a uniform.
  28658. * @param blockName Name of the block to bind.
  28659. * @param index Index to bind.
  28660. */
  28661. bindUniformBlock(blockName: string, index: number): void;
  28662. /**
  28663. * Sets an interger value on a uniform variable.
  28664. * @param uniformName Name of the variable.
  28665. * @param value Value to be set.
  28666. * @returns this effect.
  28667. */
  28668. setInt(uniformName: string, value: number): Effect;
  28669. /**
  28670. * Sets an int array on a uniform variable.
  28671. * @param uniformName Name of the variable.
  28672. * @param array array to be set.
  28673. * @returns this effect.
  28674. */
  28675. setIntArray(uniformName: string, array: Int32Array): Effect;
  28676. /**
  28677. * 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)
  28678. * @param uniformName Name of the variable.
  28679. * @param array array to be set.
  28680. * @returns this effect.
  28681. */
  28682. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28683. /**
  28684. * 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)
  28685. * @param uniformName Name of the variable.
  28686. * @param array array to be set.
  28687. * @returns this effect.
  28688. */
  28689. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28690. /**
  28691. * 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)
  28692. * @param uniformName Name of the variable.
  28693. * @param array array to be set.
  28694. * @returns this effect.
  28695. */
  28696. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28697. /**
  28698. * Sets an float array on a uniform variable.
  28699. * @param uniformName Name of the variable.
  28700. * @param array array to be set.
  28701. * @returns this effect.
  28702. */
  28703. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28704. /**
  28705. * 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)
  28706. * @param uniformName Name of the variable.
  28707. * @param array array to be set.
  28708. * @returns this effect.
  28709. */
  28710. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28711. /**
  28712. * 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)
  28713. * @param uniformName Name of the variable.
  28714. * @param array array to be set.
  28715. * @returns this effect.
  28716. */
  28717. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28718. /**
  28719. * 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)
  28720. * @param uniformName Name of the variable.
  28721. * @param array array to be set.
  28722. * @returns this effect.
  28723. */
  28724. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28725. /**
  28726. * Sets an array on a uniform variable.
  28727. * @param uniformName Name of the variable.
  28728. * @param array array to be set.
  28729. * @returns this effect.
  28730. */
  28731. setArray(uniformName: string, array: number[]): Effect;
  28732. /**
  28733. * 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)
  28734. * @param uniformName Name of the variable.
  28735. * @param array array to be set.
  28736. * @returns this effect.
  28737. */
  28738. setArray2(uniformName: string, array: number[]): Effect;
  28739. /**
  28740. * 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)
  28741. * @param uniformName Name of the variable.
  28742. * @param array array to be set.
  28743. * @returns this effect.
  28744. */
  28745. setArray3(uniformName: string, array: number[]): Effect;
  28746. /**
  28747. * 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)
  28748. * @param uniformName Name of the variable.
  28749. * @param array array to be set.
  28750. * @returns this effect.
  28751. */
  28752. setArray4(uniformName: string, array: number[]): Effect;
  28753. /**
  28754. * Sets matrices on a uniform variable.
  28755. * @param uniformName Name of the variable.
  28756. * @param matrices matrices to be set.
  28757. * @returns this effect.
  28758. */
  28759. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28760. /**
  28761. * Sets matrix on a uniform variable.
  28762. * @param uniformName Name of the variable.
  28763. * @param matrix matrix to be set.
  28764. * @returns this effect.
  28765. */
  28766. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28767. /**
  28768. * 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)
  28769. * @param uniformName Name of the variable.
  28770. * @param matrix matrix to be set.
  28771. * @returns this effect.
  28772. */
  28773. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28774. /**
  28775. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28776. * @param uniformName Name of the variable.
  28777. * @param matrix matrix to be set.
  28778. * @returns this effect.
  28779. */
  28780. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28781. /**
  28782. * Sets a float on a uniform variable.
  28783. * @param uniformName Name of the variable.
  28784. * @param value value to be set.
  28785. * @returns this effect.
  28786. */
  28787. setFloat(uniformName: string, value: number): Effect;
  28788. /**
  28789. * Sets a boolean on a uniform variable.
  28790. * @param uniformName Name of the variable.
  28791. * @param bool value to be set.
  28792. * @returns this effect.
  28793. */
  28794. setBool(uniformName: string, bool: boolean): Effect;
  28795. /**
  28796. * Sets a Vector2 on a uniform variable.
  28797. * @param uniformName Name of the variable.
  28798. * @param vector2 vector2 to be set.
  28799. * @returns this effect.
  28800. */
  28801. setVector2(uniformName: string, vector2: Vector2): Effect;
  28802. /**
  28803. * Sets a float2 on a uniform variable.
  28804. * @param uniformName Name of the variable.
  28805. * @param x First float in float2.
  28806. * @param y Second float in float2.
  28807. * @returns this effect.
  28808. */
  28809. setFloat2(uniformName: string, x: number, y: number): Effect;
  28810. /**
  28811. * Sets a Vector3 on a uniform variable.
  28812. * @param uniformName Name of the variable.
  28813. * @param vector3 Value to be set.
  28814. * @returns this effect.
  28815. */
  28816. setVector3(uniformName: string, vector3: Vector3): Effect;
  28817. /**
  28818. * Sets a float3 on a uniform variable.
  28819. * @param uniformName Name of the variable.
  28820. * @param x First float in float3.
  28821. * @param y Second float in float3.
  28822. * @param z Third float in float3.
  28823. * @returns this effect.
  28824. */
  28825. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28826. /**
  28827. * Sets a Vector4 on a uniform variable.
  28828. * @param uniformName Name of the variable.
  28829. * @param vector4 Value to be set.
  28830. * @returns this effect.
  28831. */
  28832. setVector4(uniformName: string, vector4: Vector4): Effect;
  28833. /**
  28834. * Sets a float4 on a uniform variable.
  28835. * @param uniformName Name of the variable.
  28836. * @param x First float in float4.
  28837. * @param y Second float in float4.
  28838. * @param z Third float in float4.
  28839. * @param w Fourth float in float4.
  28840. * @returns this effect.
  28841. */
  28842. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28843. /**
  28844. * Sets a Color3 on a uniform variable.
  28845. * @param uniformName Name of the variable.
  28846. * @param color3 Value to be set.
  28847. * @returns this effect.
  28848. */
  28849. setColor3(uniformName: string, color3: Color3): Effect;
  28850. /**
  28851. * Sets a Color4 on a uniform variable.
  28852. * @param uniformName Name of the variable.
  28853. * @param color3 Value to be set.
  28854. * @param alpha Alpha value to be set.
  28855. * @returns this effect.
  28856. */
  28857. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28858. /**
  28859. * Sets a Color4 on a uniform variable
  28860. * @param uniformName defines the name of the variable
  28861. * @param color4 defines the value to be set
  28862. * @returns this effect.
  28863. */
  28864. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28865. /** Release all associated resources */
  28866. dispose(): void;
  28867. /**
  28868. * This function will add a new shader to the shader store
  28869. * @param name the name of the shader
  28870. * @param pixelShader optional pixel shader content
  28871. * @param vertexShader optional vertex shader content
  28872. */
  28873. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28874. /**
  28875. * Store of each shader (The can be looked up using effect.key)
  28876. */
  28877. static ShadersStore: {
  28878. [key: string]: string;
  28879. };
  28880. /**
  28881. * Store of each included file for a shader (The can be looked up using effect.key)
  28882. */
  28883. static IncludesShadersStore: {
  28884. [key: string]: string;
  28885. };
  28886. /**
  28887. * Resets the cache of effects.
  28888. */
  28889. static ResetCache(): void;
  28890. }
  28891. }
  28892. declare module BABYLON {
  28893. /**
  28894. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28895. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28896. * 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;
  28897. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28898. */
  28899. export class ColorCurves {
  28900. private _dirty;
  28901. private _tempColor;
  28902. private _globalCurve;
  28903. private _highlightsCurve;
  28904. private _midtonesCurve;
  28905. private _shadowsCurve;
  28906. private _positiveCurve;
  28907. private _negativeCurve;
  28908. private _globalHue;
  28909. private _globalDensity;
  28910. private _globalSaturation;
  28911. private _globalExposure;
  28912. /**
  28913. * Gets the global Hue value.
  28914. * 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).
  28915. */
  28916. /**
  28917. * Sets the global Hue value.
  28918. * 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).
  28919. */
  28920. globalHue: number;
  28921. /**
  28922. * Gets the global Density value.
  28923. * 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.
  28924. * Values less than zero provide a filter of opposite hue.
  28925. */
  28926. /**
  28927. * Sets the global Density value.
  28928. * 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.
  28929. * Values less than zero provide a filter of opposite hue.
  28930. */
  28931. globalDensity: number;
  28932. /**
  28933. * Gets the global Saturation value.
  28934. * 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.
  28935. */
  28936. /**
  28937. * Sets the global Saturation value.
  28938. * 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.
  28939. */
  28940. globalSaturation: number;
  28941. /**
  28942. * Gets the global Exposure value.
  28943. * 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.
  28944. */
  28945. /**
  28946. * Sets the global Exposure value.
  28947. * 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.
  28948. */
  28949. globalExposure: number;
  28950. private _highlightsHue;
  28951. private _highlightsDensity;
  28952. private _highlightsSaturation;
  28953. private _highlightsExposure;
  28954. /**
  28955. * Gets the highlights Hue value.
  28956. * 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).
  28957. */
  28958. /**
  28959. * Sets the highlights Hue value.
  28960. * 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).
  28961. */
  28962. highlightsHue: number;
  28963. /**
  28964. * Gets the highlights Density value.
  28965. * 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.
  28966. * Values less than zero provide a filter of opposite hue.
  28967. */
  28968. /**
  28969. * Sets the highlights Density value.
  28970. * 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.
  28971. * Values less than zero provide a filter of opposite hue.
  28972. */
  28973. highlightsDensity: number;
  28974. /**
  28975. * Gets the highlights Saturation value.
  28976. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  28977. */
  28978. /**
  28979. * Sets the highlights Saturation value.
  28980. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  28981. */
  28982. highlightsSaturation: number;
  28983. /**
  28984. * Gets the highlights Exposure value.
  28985. * 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.
  28986. */
  28987. /**
  28988. * Sets the highlights Exposure value.
  28989. * 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.
  28990. */
  28991. highlightsExposure: number;
  28992. private _midtonesHue;
  28993. private _midtonesDensity;
  28994. private _midtonesSaturation;
  28995. private _midtonesExposure;
  28996. /**
  28997. * Gets the midtones Hue value.
  28998. * 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).
  28999. */
  29000. /**
  29001. * Sets the midtones Hue value.
  29002. * 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).
  29003. */
  29004. midtonesHue: number;
  29005. /**
  29006. * Gets the midtones Density value.
  29007. * 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.
  29008. * Values less than zero provide a filter of opposite hue.
  29009. */
  29010. /**
  29011. * Sets the midtones Density value.
  29012. * 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.
  29013. * Values less than zero provide a filter of opposite hue.
  29014. */
  29015. midtonesDensity: number;
  29016. /**
  29017. * Gets the midtones Saturation value.
  29018. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29019. */
  29020. /**
  29021. * Sets the midtones Saturation value.
  29022. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29023. */
  29024. midtonesSaturation: number;
  29025. /**
  29026. * Gets the midtones Exposure value.
  29027. * 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.
  29028. */
  29029. /**
  29030. * Sets the midtones Exposure value.
  29031. * 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.
  29032. */
  29033. midtonesExposure: number;
  29034. private _shadowsHue;
  29035. private _shadowsDensity;
  29036. private _shadowsSaturation;
  29037. private _shadowsExposure;
  29038. /**
  29039. * Gets the shadows Hue value.
  29040. * 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).
  29041. */
  29042. /**
  29043. * Sets the shadows Hue value.
  29044. * 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).
  29045. */
  29046. shadowsHue: number;
  29047. /**
  29048. * Gets the shadows Density value.
  29049. * 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.
  29050. * Values less than zero provide a filter of opposite hue.
  29051. */
  29052. /**
  29053. * Sets the shadows Density value.
  29054. * 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.
  29055. * Values less than zero provide a filter of opposite hue.
  29056. */
  29057. shadowsDensity: number;
  29058. /**
  29059. * Gets the shadows Saturation value.
  29060. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29061. */
  29062. /**
  29063. * Sets the shadows Saturation value.
  29064. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29065. */
  29066. shadowsSaturation: number;
  29067. /**
  29068. * Gets the shadows Exposure value.
  29069. * 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.
  29070. */
  29071. /**
  29072. * Sets the shadows Exposure value.
  29073. * 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.
  29074. */
  29075. shadowsExposure: number;
  29076. /**
  29077. * Returns the class name
  29078. * @returns The class name
  29079. */
  29080. getClassName(): string;
  29081. /**
  29082. * Binds the color curves to the shader.
  29083. * @param colorCurves The color curve to bind
  29084. * @param effect The effect to bind to
  29085. * @param positiveUniform The positive uniform shader parameter
  29086. * @param neutralUniform The neutral uniform shader parameter
  29087. * @param negativeUniform The negative uniform shader parameter
  29088. */
  29089. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29090. /**
  29091. * Prepare the list of uniforms associated with the ColorCurves effects.
  29092. * @param uniformsList The list of uniforms used in the effect
  29093. */
  29094. static PrepareUniforms(uniformsList: string[]): void;
  29095. /**
  29096. * Returns color grading data based on a hue, density, saturation and exposure value.
  29097. * @param filterHue The hue of the color filter.
  29098. * @param filterDensity The density of the color filter.
  29099. * @param saturation The saturation.
  29100. * @param exposure The exposure.
  29101. * @param result The result data container.
  29102. */
  29103. private getColorGradingDataToRef;
  29104. /**
  29105. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29106. * @param value The input slider value in range [-100,100].
  29107. * @returns Adjusted value.
  29108. */
  29109. private static applyColorGradingSliderNonlinear;
  29110. /**
  29111. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29112. * @param hue The hue (H) input.
  29113. * @param saturation The saturation (S) input.
  29114. * @param brightness The brightness (B) input.
  29115. * @result An RGBA color represented as Vector4.
  29116. */
  29117. private static fromHSBToRef;
  29118. /**
  29119. * Returns a value clamped between min and max
  29120. * @param value The value to clamp
  29121. * @param min The minimum of value
  29122. * @param max The maximum of value
  29123. * @returns The clamped value.
  29124. */
  29125. private static clamp;
  29126. /**
  29127. * Clones the current color curve instance.
  29128. * @return The cloned curves
  29129. */
  29130. clone(): ColorCurves;
  29131. /**
  29132. * Serializes the current color curve instance to a json representation.
  29133. * @return a JSON representation
  29134. */
  29135. serialize(): any;
  29136. /**
  29137. * Parses the color curve from a json representation.
  29138. * @param source the JSON source to parse
  29139. * @return The parsed curves
  29140. */
  29141. static Parse(source: any): ColorCurves;
  29142. }
  29143. }
  29144. declare module BABYLON {
  29145. /**
  29146. * Interface to follow in your material defines to integrate easily the
  29147. * Image proccessing functions.
  29148. * @hidden
  29149. */
  29150. export interface IImageProcessingConfigurationDefines {
  29151. IMAGEPROCESSING: boolean;
  29152. VIGNETTE: boolean;
  29153. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29154. VIGNETTEBLENDMODEOPAQUE: boolean;
  29155. TONEMAPPING: boolean;
  29156. TONEMAPPING_ACES: boolean;
  29157. CONTRAST: boolean;
  29158. EXPOSURE: boolean;
  29159. COLORCURVES: boolean;
  29160. COLORGRADING: boolean;
  29161. COLORGRADING3D: boolean;
  29162. SAMPLER3DGREENDEPTH: boolean;
  29163. SAMPLER3DBGRMAP: boolean;
  29164. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29165. }
  29166. /**
  29167. * @hidden
  29168. */
  29169. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29170. IMAGEPROCESSING: boolean;
  29171. VIGNETTE: boolean;
  29172. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29173. VIGNETTEBLENDMODEOPAQUE: boolean;
  29174. TONEMAPPING: boolean;
  29175. TONEMAPPING_ACES: boolean;
  29176. CONTRAST: boolean;
  29177. COLORCURVES: boolean;
  29178. COLORGRADING: boolean;
  29179. COLORGRADING3D: boolean;
  29180. SAMPLER3DGREENDEPTH: boolean;
  29181. SAMPLER3DBGRMAP: boolean;
  29182. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29183. EXPOSURE: boolean;
  29184. constructor();
  29185. }
  29186. /**
  29187. * This groups together the common properties used for image processing either in direct forward pass
  29188. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29189. * or not.
  29190. */
  29191. export class ImageProcessingConfiguration {
  29192. /**
  29193. * Default tone mapping applied in BabylonJS.
  29194. */
  29195. static readonly TONEMAPPING_STANDARD: number;
  29196. /**
  29197. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29198. * to other engines rendering to increase portability.
  29199. */
  29200. static readonly TONEMAPPING_ACES: number;
  29201. /**
  29202. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29203. */
  29204. colorCurves: Nullable<ColorCurves>;
  29205. private _colorCurvesEnabled;
  29206. /**
  29207. * Gets wether the color curves effect is enabled.
  29208. */
  29209. /**
  29210. * Sets wether the color curves effect is enabled.
  29211. */
  29212. colorCurvesEnabled: boolean;
  29213. private _colorGradingTexture;
  29214. /**
  29215. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29216. */
  29217. /**
  29218. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29219. */
  29220. colorGradingTexture: Nullable<BaseTexture>;
  29221. private _colorGradingEnabled;
  29222. /**
  29223. * Gets wether the color grading effect is enabled.
  29224. */
  29225. /**
  29226. * Sets wether the color grading effect is enabled.
  29227. */
  29228. colorGradingEnabled: boolean;
  29229. private _colorGradingWithGreenDepth;
  29230. /**
  29231. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29232. */
  29233. /**
  29234. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29235. */
  29236. colorGradingWithGreenDepth: boolean;
  29237. private _colorGradingBGR;
  29238. /**
  29239. * Gets wether the color grading texture contains BGR values.
  29240. */
  29241. /**
  29242. * Sets wether the color grading texture contains BGR values.
  29243. */
  29244. colorGradingBGR: boolean;
  29245. /** @hidden */ exposure: number;
  29246. /**
  29247. * Gets the Exposure used in the effect.
  29248. */
  29249. /**
  29250. * Sets the Exposure used in the effect.
  29251. */
  29252. exposure: number;
  29253. private _toneMappingEnabled;
  29254. /**
  29255. * Gets wether the tone mapping effect is enabled.
  29256. */
  29257. /**
  29258. * Sets wether the tone mapping effect is enabled.
  29259. */
  29260. toneMappingEnabled: boolean;
  29261. private _toneMappingType;
  29262. /**
  29263. * Gets the type of tone mapping effect.
  29264. */
  29265. /**
  29266. * Sets the type of tone mapping effect used in BabylonJS.
  29267. */
  29268. toneMappingType: number;
  29269. protected _contrast: number;
  29270. /**
  29271. * Gets the contrast used in the effect.
  29272. */
  29273. /**
  29274. * Sets the contrast used in the effect.
  29275. */
  29276. contrast: number;
  29277. /**
  29278. * Vignette stretch size.
  29279. */
  29280. vignetteStretch: number;
  29281. /**
  29282. * Vignette centre X Offset.
  29283. */
  29284. vignetteCentreX: number;
  29285. /**
  29286. * Vignette centre Y Offset.
  29287. */
  29288. vignetteCentreY: number;
  29289. /**
  29290. * Vignette weight or intensity of the vignette effect.
  29291. */
  29292. vignetteWeight: number;
  29293. /**
  29294. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29295. * if vignetteEnabled is set to true.
  29296. */
  29297. vignetteColor: Color4;
  29298. /**
  29299. * Camera field of view used by the Vignette effect.
  29300. */
  29301. vignetteCameraFov: number;
  29302. private _vignetteBlendMode;
  29303. /**
  29304. * Gets the vignette blend mode allowing different kind of effect.
  29305. */
  29306. /**
  29307. * Sets the vignette blend mode allowing different kind of effect.
  29308. */
  29309. vignetteBlendMode: number;
  29310. private _vignetteEnabled;
  29311. /**
  29312. * Gets wether the vignette effect is enabled.
  29313. */
  29314. /**
  29315. * Sets wether the vignette effect is enabled.
  29316. */
  29317. vignetteEnabled: boolean;
  29318. private _applyByPostProcess;
  29319. /**
  29320. * Gets wether the image processing is applied through a post process or not.
  29321. */
  29322. /**
  29323. * Sets wether the image processing is applied through a post process or not.
  29324. */
  29325. applyByPostProcess: boolean;
  29326. private _isEnabled;
  29327. /**
  29328. * Gets wether the image processing is enabled or not.
  29329. */
  29330. /**
  29331. * Sets wether the image processing is enabled or not.
  29332. */
  29333. isEnabled: boolean;
  29334. /**
  29335. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29336. */
  29337. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29338. /**
  29339. * Method called each time the image processing information changes requires to recompile the effect.
  29340. */
  29341. protected _updateParameters(): void;
  29342. /**
  29343. * Gets the current class name.
  29344. * @return "ImageProcessingConfiguration"
  29345. */
  29346. getClassName(): string;
  29347. /**
  29348. * Prepare the list of uniforms associated with the Image Processing effects.
  29349. * @param uniforms The list of uniforms used in the effect
  29350. * @param defines the list of defines currently in use
  29351. */
  29352. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29353. /**
  29354. * Prepare the list of samplers associated with the Image Processing effects.
  29355. * @param samplersList The list of uniforms used in the effect
  29356. * @param defines the list of defines currently in use
  29357. */
  29358. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29359. /**
  29360. * Prepare the list of defines associated to the shader.
  29361. * @param defines the list of defines to complete
  29362. * @param forPostProcess Define if we are currently in post process mode or not
  29363. */
  29364. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29365. /**
  29366. * Returns true if all the image processing information are ready.
  29367. * @returns True if ready, otherwise, false
  29368. */
  29369. isReady(): boolean;
  29370. /**
  29371. * Binds the image processing to the shader.
  29372. * @param effect The effect to bind to
  29373. * @param aspectRatio Define the current aspect ratio of the effect
  29374. */
  29375. bind(effect: Effect, aspectRatio?: number): void;
  29376. /**
  29377. * Clones the current image processing instance.
  29378. * @return The cloned image processing
  29379. */
  29380. clone(): ImageProcessingConfiguration;
  29381. /**
  29382. * Serializes the current image processing instance to a json representation.
  29383. * @return a JSON representation
  29384. */
  29385. serialize(): any;
  29386. /**
  29387. * Parses the image processing from a json representation.
  29388. * @param source the JSON source to parse
  29389. * @return The parsed image processing
  29390. */
  29391. static Parse(source: any): ImageProcessingConfiguration;
  29392. private static _VIGNETTEMODE_MULTIPLY;
  29393. private static _VIGNETTEMODE_OPAQUE;
  29394. /**
  29395. * Used to apply the vignette as a mix with the pixel color.
  29396. */
  29397. static readonly VIGNETTEMODE_MULTIPLY: number;
  29398. /**
  29399. * Used to apply the vignette as a replacement of the pixel color.
  29400. */
  29401. static readonly VIGNETTEMODE_OPAQUE: number;
  29402. }
  29403. }
  29404. declare module BABYLON {
  29405. /**
  29406. * This represents all the required information to add a fresnel effect on a material:
  29407. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29408. */
  29409. export class FresnelParameters {
  29410. private _isEnabled;
  29411. /**
  29412. * Define if the fresnel effect is enable or not.
  29413. */
  29414. isEnabled: boolean;
  29415. /**
  29416. * Define the color used on edges (grazing angle)
  29417. */
  29418. leftColor: Color3;
  29419. /**
  29420. * Define the color used on center
  29421. */
  29422. rightColor: Color3;
  29423. /**
  29424. * Define bias applied to computed fresnel term
  29425. */
  29426. bias: number;
  29427. /**
  29428. * Defined the power exponent applied to fresnel term
  29429. */
  29430. power: number;
  29431. /**
  29432. * Clones the current fresnel and its valuues
  29433. * @returns a clone fresnel configuration
  29434. */
  29435. clone(): FresnelParameters;
  29436. /**
  29437. * Serializes the current fresnel parameters to a JSON representation.
  29438. * @return the JSON serialization
  29439. */
  29440. serialize(): any;
  29441. /**
  29442. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29443. * @param parsedFresnelParameters Define the JSON representation
  29444. * @returns the parsed parameters
  29445. */
  29446. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29447. }
  29448. }
  29449. declare module BABYLON {
  29450. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29451. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29452. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29453. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29454. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29455. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29456. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29457. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29458. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29459. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29460. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29461. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29462. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29463. /**
  29464. * Decorator used to define property that can be serialized as reference to a camera
  29465. * @param sourceName defines the name of the property to decorate
  29466. */
  29467. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29468. /**
  29469. * Class used to help serialization objects
  29470. */
  29471. export class SerializationHelper {
  29472. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29473. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29474. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29475. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29476. /**
  29477. * Appends the serialized animations from the source animations
  29478. * @param source Source containing the animations
  29479. * @param destination Target to store the animations
  29480. */
  29481. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29482. /**
  29483. * Static function used to serialized a specific entity
  29484. * @param entity defines the entity to serialize
  29485. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29486. * @returns a JSON compatible object representing the serialization of the entity
  29487. */
  29488. static Serialize<T>(entity: T, serializationObject?: any): any;
  29489. /**
  29490. * Creates a new entity from a serialization data object
  29491. * @param creationFunction defines a function used to instanciated the new entity
  29492. * @param source defines the source serialization data
  29493. * @param scene defines the hosting scene
  29494. * @param rootUrl defines the root url for resources
  29495. * @returns a new entity
  29496. */
  29497. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29498. /**
  29499. * Clones an object
  29500. * @param creationFunction defines the function used to instanciate the new object
  29501. * @param source defines the source object
  29502. * @returns the cloned object
  29503. */
  29504. static Clone<T>(creationFunction: () => T, source: T): T;
  29505. /**
  29506. * Instanciates a new object based on a source one (some data will be shared between both object)
  29507. * @param creationFunction defines the function used to instanciate the new object
  29508. * @param source defines the source object
  29509. * @returns the new object
  29510. */
  29511. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29512. }
  29513. }
  29514. declare module BABYLON {
  29515. /**
  29516. * This is the base class of all the camera used in the application.
  29517. * @see http://doc.babylonjs.com/features/cameras
  29518. */
  29519. export class Camera extends Node {
  29520. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29521. /**
  29522. * This is the default projection mode used by the cameras.
  29523. * It helps recreating a feeling of perspective and better appreciate depth.
  29524. * This is the best way to simulate real life cameras.
  29525. */
  29526. static readonly PERSPECTIVE_CAMERA: number;
  29527. /**
  29528. * This helps creating camera with an orthographic mode.
  29529. * 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.
  29530. */
  29531. static readonly ORTHOGRAPHIC_CAMERA: number;
  29532. /**
  29533. * This is the default FOV mode for perspective cameras.
  29534. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29535. */
  29536. static readonly FOVMODE_VERTICAL_FIXED: number;
  29537. /**
  29538. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29539. */
  29540. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29541. /**
  29542. * This specifies ther is no need for a camera rig.
  29543. * Basically only one eye is rendered corresponding to the camera.
  29544. */
  29545. static readonly RIG_MODE_NONE: number;
  29546. /**
  29547. * Simulates a camera Rig with one blue eye and one red eye.
  29548. * This can be use with 3d blue and red glasses.
  29549. */
  29550. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29551. /**
  29552. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29553. */
  29554. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29555. /**
  29556. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29557. */
  29558. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29559. /**
  29560. * Defines that both eyes of the camera will be rendered over under each other.
  29561. */
  29562. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29563. /**
  29564. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29565. */
  29566. static readonly RIG_MODE_VR: number;
  29567. /**
  29568. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29569. */
  29570. static readonly RIG_MODE_WEBVR: number;
  29571. /**
  29572. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29573. */
  29574. static readonly RIG_MODE_CUSTOM: number;
  29575. /**
  29576. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29577. */
  29578. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29579. /**
  29580. * Define the input manager associated with the camera.
  29581. */
  29582. inputs: CameraInputsManager<Camera>;
  29583. /** @hidden */ position: Vector3;
  29584. /**
  29585. * Define the current local position of the camera in the scene
  29586. */
  29587. position: Vector3;
  29588. /**
  29589. * The vector the camera should consider as up.
  29590. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29591. */
  29592. upVector: Vector3;
  29593. /**
  29594. * Define the current limit on the left side for an orthographic camera
  29595. * In scene unit
  29596. */
  29597. orthoLeft: Nullable<number>;
  29598. /**
  29599. * Define the current limit on the right side for an orthographic camera
  29600. * In scene unit
  29601. */
  29602. orthoRight: Nullable<number>;
  29603. /**
  29604. * Define the current limit on the bottom side for an orthographic camera
  29605. * In scene unit
  29606. */
  29607. orthoBottom: Nullable<number>;
  29608. /**
  29609. * Define the current limit on the top side for an orthographic camera
  29610. * In scene unit
  29611. */
  29612. orthoTop: Nullable<number>;
  29613. /**
  29614. * Field Of View is set in Radians. (default is 0.8)
  29615. */
  29616. fov: number;
  29617. /**
  29618. * Define the minimum distance the camera can see from.
  29619. * This is important to note that the depth buffer are not infinite and the closer it starts
  29620. * the more your scene might encounter depth fighting issue.
  29621. */
  29622. minZ: number;
  29623. /**
  29624. * Define the maximum distance the camera can see to.
  29625. * This is important to note that the depth buffer are not infinite and the further it end
  29626. * the more your scene might encounter depth fighting issue.
  29627. */
  29628. maxZ: number;
  29629. /**
  29630. * Define the default inertia of the camera.
  29631. * This helps giving a smooth feeling to the camera movement.
  29632. */
  29633. inertia: number;
  29634. /**
  29635. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29636. */
  29637. mode: number;
  29638. /**
  29639. * Define wether the camera is intermediate.
  29640. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29641. */
  29642. isIntermediate: boolean;
  29643. /**
  29644. * Define the viewport of the camera.
  29645. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29646. */
  29647. viewport: Viewport;
  29648. /**
  29649. * Restricts the camera to viewing objects with the same layerMask.
  29650. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29651. */
  29652. layerMask: number;
  29653. /**
  29654. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29655. */
  29656. fovMode: number;
  29657. /**
  29658. * Rig mode of the camera.
  29659. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29660. * This is normally controlled byt the camera themselves as internal use.
  29661. */
  29662. cameraRigMode: number;
  29663. /**
  29664. * Defines the distance between both "eyes" in case of a RIG
  29665. */
  29666. interaxialDistance: number;
  29667. /**
  29668. * Defines if stereoscopic rendering is done side by side or over under.
  29669. */
  29670. isStereoscopicSideBySide: boolean;
  29671. /**
  29672. * 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
  29673. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29674. * else in the scene.
  29675. */
  29676. customRenderTargets: RenderTargetTexture[];
  29677. /**
  29678. * When set, the camera will render to this render target instead of the default canvas
  29679. */
  29680. outputRenderTarget: Nullable<RenderTargetTexture>;
  29681. /**
  29682. * Observable triggered when the camera view matrix has changed.
  29683. */
  29684. onViewMatrixChangedObservable: Observable<Camera>;
  29685. /**
  29686. * Observable triggered when the camera Projection matrix has changed.
  29687. */
  29688. onProjectionMatrixChangedObservable: Observable<Camera>;
  29689. /**
  29690. * Observable triggered when the inputs have been processed.
  29691. */
  29692. onAfterCheckInputsObservable: Observable<Camera>;
  29693. /**
  29694. * Observable triggered when reset has been called and applied to the camera.
  29695. */
  29696. onRestoreStateObservable: Observable<Camera>;
  29697. /** @hidden */ cameraRigParams: any;
  29698. /** @hidden */ rigCameras: Camera[];
  29699. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  29700. protected _webvrViewMatrix: Matrix;
  29701. /** @hidden */ skipRendering: boolean;
  29702. /** @hidden */ projectionMatrix: Matrix;
  29703. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  29704. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  29705. protected _globalPosition: Vector3;
  29706. /** hidden */ computedViewMatrix: Matrix;
  29707. private _doNotComputeProjectionMatrix;
  29708. private _transformMatrix;
  29709. private _frustumPlanes;
  29710. private _refreshFrustumPlanes;
  29711. private _storedFov;
  29712. private _stateStored;
  29713. /**
  29714. * Instantiates a new camera object.
  29715. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29716. * @see http://doc.babylonjs.com/features/cameras
  29717. * @param name Defines the name of the camera in the scene
  29718. * @param position Defines the position of the camera
  29719. * @param scene Defines the scene the camera belongs too
  29720. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29721. */
  29722. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29723. /**
  29724. * Store current camera state (fov, position, etc..)
  29725. * @returns the camera
  29726. */
  29727. storeState(): Camera;
  29728. /**
  29729. * Restores the camera state values if it has been stored. You must call storeState() first
  29730. */
  29731. protected _restoreStateValues(): boolean;
  29732. /**
  29733. * Restored camera state. You must call storeState() first.
  29734. * @returns true if restored and false otherwise
  29735. */
  29736. restoreState(): boolean;
  29737. /**
  29738. * Gets the class name of the camera.
  29739. * @returns the class name
  29740. */
  29741. getClassName(): string;
  29742. /** @hidden */ protected readonly _isCamera: boolean;
  29743. /**
  29744. * Gets a string representation of the camera useful for debug purpose.
  29745. * @param fullDetails Defines that a more verboe level of logging is required
  29746. * @returns the string representation
  29747. */
  29748. toString(fullDetails?: boolean): string;
  29749. /**
  29750. * Gets the current world space position of the camera.
  29751. */
  29752. readonly globalPosition: Vector3;
  29753. /**
  29754. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29755. * @returns the active meshe list
  29756. */
  29757. getActiveMeshes(): SmartArray<AbstractMesh>;
  29758. /**
  29759. * Check wether a mesh is part of the current active mesh list of the camera
  29760. * @param mesh Defines the mesh to check
  29761. * @returns true if active, false otherwise
  29762. */
  29763. isActiveMesh(mesh: Mesh): boolean;
  29764. /**
  29765. * Is this camera ready to be used/rendered
  29766. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29767. * @return true if the camera is ready
  29768. */
  29769. isReady(completeCheck?: boolean): boolean;
  29770. /** @hidden */ initCache(): void;
  29771. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29772. /** @hidden */ isSynchronized(): boolean;
  29773. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29774. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29775. /**
  29776. * Attach the input controls to a specific dom element to get the input from.
  29777. * @param element Defines the element the controls should be listened from
  29778. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29779. */
  29780. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29781. /**
  29782. * Detach the current controls from the specified dom element.
  29783. * @param element Defines the element to stop listening the inputs from
  29784. */
  29785. detachControl(element: HTMLElement): void;
  29786. /**
  29787. * Update the camera state according to the different inputs gathered during the frame.
  29788. */
  29789. update(): void;
  29790. /** @hidden */ checkInputs(): void;
  29791. /** @hidden */
  29792. readonly rigCameras: Camera[];
  29793. /**
  29794. * Gets the post process used by the rig cameras
  29795. */
  29796. readonly rigPostProcess: Nullable<PostProcess>;
  29797. /**
  29798. * Internal, gets the first post proces.
  29799. * @returns the first post process to be run on this camera.
  29800. */ getFirstPostProcess(): Nullable<PostProcess>;
  29801. private _cascadePostProcessesToRigCams;
  29802. /**
  29803. * Attach a post process to the camera.
  29804. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29805. * @param postProcess The post process to attach to the camera
  29806. * @param insertAt The position of the post process in case several of them are in use in the scene
  29807. * @returns the position the post process has been inserted at
  29808. */
  29809. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29810. /**
  29811. * Detach a post process to the camera.
  29812. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29813. * @param postProcess The post process to detach from the camera
  29814. */
  29815. detachPostProcess(postProcess: PostProcess): void;
  29816. /**
  29817. * Gets the current world matrix of the camera
  29818. */
  29819. getWorldMatrix(): Matrix;
  29820. /** @hidden */ getViewMatrix(): Matrix;
  29821. /**
  29822. * Gets the current view matrix of the camera.
  29823. * @param force forces the camera to recompute the matrix without looking at the cached state
  29824. * @returns the view matrix
  29825. */
  29826. getViewMatrix(force?: boolean): Matrix;
  29827. /**
  29828. * Freeze the projection matrix.
  29829. * It will prevent the cache check of the camera projection compute and can speed up perf
  29830. * if no parameter of the camera are meant to change
  29831. * @param projection Defines manually a projection if necessary
  29832. */
  29833. freezeProjectionMatrix(projection?: Matrix): void;
  29834. /**
  29835. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29836. */
  29837. unfreezeProjectionMatrix(): void;
  29838. /**
  29839. * Gets the current projection matrix of the camera.
  29840. * @param force forces the camera to recompute the matrix without looking at the cached state
  29841. * @returns the projection matrix
  29842. */
  29843. getProjectionMatrix(force?: boolean): Matrix;
  29844. /**
  29845. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29846. * @returns a Matrix
  29847. */
  29848. getTransformationMatrix(): Matrix;
  29849. private _updateFrustumPlanes;
  29850. /**
  29851. * Checks if a cullable object (mesh...) is in the camera frustum
  29852. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29853. * @param target The object to check
  29854. * @returns true if the object is in frustum otherwise false
  29855. */
  29856. isInFrustum(target: ICullable): boolean;
  29857. /**
  29858. * Checks if a cullable object (mesh...) is in the camera frustum
  29859. * Unlike isInFrustum this cheks the full bounding box
  29860. * @param target The object to check
  29861. * @returns true if the object is in frustum otherwise false
  29862. */
  29863. isCompletelyInFrustum(target: ICullable): boolean;
  29864. /**
  29865. * Gets a ray in the forward direction from the camera.
  29866. * @param length Defines the length of the ray to create
  29867. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29868. * @param origin Defines the start point of the ray which defaults to the camera position
  29869. * @returns the forward ray
  29870. */
  29871. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29872. /**
  29873. * Releases resources associated with this node.
  29874. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29875. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29876. */
  29877. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29878. /** @hidden */ isLeftCamera: boolean;
  29879. /**
  29880. * Gets the left camera of a rig setup in case of Rigged Camera
  29881. */
  29882. readonly isLeftCamera: boolean;
  29883. /** @hidden */ isRightCamera: boolean;
  29884. /**
  29885. * Gets the right camera of a rig setup in case of Rigged Camera
  29886. */
  29887. readonly isRightCamera: boolean;
  29888. /**
  29889. * Gets the left camera of a rig setup in case of Rigged Camera
  29890. */
  29891. readonly leftCamera: Nullable<FreeCamera>;
  29892. /**
  29893. * Gets the right camera of a rig setup in case of Rigged Camera
  29894. */
  29895. readonly rightCamera: Nullable<FreeCamera>;
  29896. /**
  29897. * Gets the left camera target of a rig setup in case of Rigged Camera
  29898. * @returns the target position
  29899. */
  29900. getLeftTarget(): Nullable<Vector3>;
  29901. /**
  29902. * Gets the right camera target of a rig setup in case of Rigged Camera
  29903. * @returns the target position
  29904. */
  29905. getRightTarget(): Nullable<Vector3>;
  29906. /**
  29907. * @hidden
  29908. */
  29909. setCameraRigMode(mode: number, rigParams: any): void;
  29910. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  29911. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29912. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  29913. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29914. /** @hidden */ getVRProjectionMatrix(): Matrix;
  29915. protected _updateCameraRotationMatrix(): void;
  29916. protected _updateWebVRCameraRotationMatrix(): void;
  29917. /**
  29918. * This function MUST be overwritten by the different WebVR cameras available.
  29919. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29920. * @hidden
  29921. */ getWebVRProjectionMatrix(): Matrix;
  29922. /**
  29923. * This function MUST be overwritten by the different WebVR cameras available.
  29924. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29925. * @hidden
  29926. */ getWebVRViewMatrix(): Matrix;
  29927. /** @hidden */
  29928. setCameraRigParameter(name: string, value: any): void;
  29929. /**
  29930. * needs to be overridden by children so sub has required properties to be copied
  29931. * @hidden
  29932. */
  29933. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29934. /**
  29935. * May need to be overridden by children
  29936. * @hidden
  29937. */ updateRigCameras(): void;
  29938. /** @hidden */ setupInputs(): void;
  29939. /**
  29940. * Serialiaze the camera setup to a json represention
  29941. * @returns the JSON representation
  29942. */
  29943. serialize(): any;
  29944. /**
  29945. * Clones the current camera.
  29946. * @param name The cloned camera name
  29947. * @returns the cloned camera
  29948. */
  29949. clone(name: string): Camera;
  29950. /**
  29951. * Gets the direction of the camera relative to a given local axis.
  29952. * @param localAxis Defines the reference axis to provide a relative direction.
  29953. * @return the direction
  29954. */
  29955. getDirection(localAxis: Vector3): Vector3;
  29956. /**
  29957. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29958. * @param localAxis Defines the reference axis to provide a relative direction.
  29959. * @param result Defines the vector to store the result in
  29960. */
  29961. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29962. /**
  29963. * Gets a camera constructor for a given camera type
  29964. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29965. * @param name The name of the camera the result will be able to instantiate
  29966. * @param scene The scene the result will construct the camera in
  29967. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29968. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29969. * @returns a factory method to construc the camera
  29970. */
  29971. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29972. /**
  29973. * Compute the world matrix of the camera.
  29974. * @returns the camera workd matrix
  29975. */
  29976. computeWorldMatrix(): Matrix;
  29977. /**
  29978. * Parse a JSON and creates the camera from the parsed information
  29979. * @param parsedCamera The JSON to parse
  29980. * @param scene The scene to instantiate the camera in
  29981. * @returns the newly constructed camera
  29982. */
  29983. static Parse(parsedCamera: any, scene: Scene): Camera;
  29984. }
  29985. }
  29986. declare module BABYLON {
  29987. /**
  29988. * Interface for any object that can request an animation frame
  29989. */
  29990. export interface ICustomAnimationFrameRequester {
  29991. /**
  29992. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29993. */
  29994. renderFunction?: Function;
  29995. /**
  29996. * Called to request the next frame to render to
  29997. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29998. */
  29999. requestAnimationFrame: Function;
  30000. /**
  30001. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30002. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30003. */
  30004. requestID?: number;
  30005. }
  30006. /**
  30007. * Interface containing an array of animations
  30008. */
  30009. export interface IAnimatable {
  30010. /**
  30011. * Array of animations
  30012. */
  30013. animations: Nullable<Array<Animation>>;
  30014. }
  30015. /** Interface used by value gradients (color, factor, ...) */
  30016. export interface IValueGradient {
  30017. /**
  30018. * Gets or sets the gradient value (between 0 and 1)
  30019. */
  30020. gradient: number;
  30021. }
  30022. /** Class used to store color4 gradient */
  30023. export class ColorGradient implements IValueGradient {
  30024. /**
  30025. * Gets or sets the gradient value (between 0 and 1)
  30026. */
  30027. gradient: number;
  30028. /**
  30029. * Gets or sets first associated color
  30030. */
  30031. color1: Color4;
  30032. /**
  30033. * Gets or sets second associated color
  30034. */
  30035. color2?: Color4;
  30036. /**
  30037. * Will get a color picked randomly between color1 and color2.
  30038. * If color2 is undefined then color1 will be used
  30039. * @param result defines the target Color4 to store the result in
  30040. */
  30041. getColorToRef(result: Color4): void;
  30042. }
  30043. /** Class used to store color 3 gradient */
  30044. export class Color3Gradient implements IValueGradient {
  30045. /**
  30046. * Gets or sets the gradient value (between 0 and 1)
  30047. */
  30048. gradient: number;
  30049. /**
  30050. * Gets or sets the associated color
  30051. */
  30052. color: Color3;
  30053. }
  30054. /** Class used to store factor gradient */
  30055. export class FactorGradient implements IValueGradient {
  30056. /**
  30057. * Gets or sets the gradient value (between 0 and 1)
  30058. */
  30059. gradient: number;
  30060. /**
  30061. * Gets or sets first associated factor
  30062. */
  30063. factor1: number;
  30064. /**
  30065. * Gets or sets second associated factor
  30066. */
  30067. factor2?: number;
  30068. /**
  30069. * Will get a number picked randomly between factor1 and factor2.
  30070. * If factor2 is undefined then factor1 will be used
  30071. * @returns the picked number
  30072. */
  30073. getFactor(): number;
  30074. }
  30075. /**
  30076. * @ignore
  30077. * Application error to support additional information when loading a file
  30078. */
  30079. export class LoadFileError extends Error {
  30080. /** defines the optional web request */
  30081. request?: WebRequest | undefined;
  30082. private static _setPrototypeOf;
  30083. /**
  30084. * Creates a new LoadFileError
  30085. * @param message defines the message of the error
  30086. * @param request defines the optional web request
  30087. */
  30088. constructor(message: string,
  30089. /** defines the optional web request */
  30090. request?: WebRequest | undefined);
  30091. }
  30092. /**
  30093. * Class used to define a retry strategy when error happens while loading assets
  30094. */
  30095. export class RetryStrategy {
  30096. /**
  30097. * Function used to defines an exponential back off strategy
  30098. * @param maxRetries defines the maximum number of retries (3 by default)
  30099. * @param baseInterval defines the interval between retries
  30100. * @returns the strategy function to use
  30101. */
  30102. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30103. }
  30104. /**
  30105. * File request interface
  30106. */
  30107. export interface IFileRequest {
  30108. /**
  30109. * Raised when the request is complete (success or error).
  30110. */
  30111. onCompleteObservable: Observable<IFileRequest>;
  30112. /**
  30113. * Aborts the request for a file.
  30114. */
  30115. abort: () => void;
  30116. }
  30117. /**
  30118. * Class containing a set of static utilities functions
  30119. */
  30120. export class Tools {
  30121. /**
  30122. * Gets or sets the base URL to use to load assets
  30123. */
  30124. static BaseUrl: string;
  30125. /**
  30126. * Enable/Disable Custom HTTP Request Headers globally.
  30127. * default = false
  30128. * @see CustomRequestHeaders
  30129. */
  30130. static UseCustomRequestHeaders: boolean;
  30131. /**
  30132. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30133. * i.e. when loading files, where the server/service expects an Authorization header
  30134. */
  30135. static CustomRequestHeaders: {
  30136. [key: string]: string;
  30137. };
  30138. /**
  30139. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30140. */
  30141. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30142. /**
  30143. * Default behaviour for cors in the application.
  30144. * It can be a string if the expected behavior is identical in the entire app.
  30145. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30146. */
  30147. static CorsBehavior: string | ((url: string | string[]) => string);
  30148. /**
  30149. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30150. * @ignorenaming
  30151. */
  30152. static UseFallbackTexture: boolean;
  30153. /**
  30154. * Use this object to register external classes like custom textures or material
  30155. * to allow the laoders to instantiate them
  30156. */
  30157. static RegisteredExternalClasses: {
  30158. [key: string]: Object;
  30159. };
  30160. /**
  30161. * Texture content used if a texture cannot loaded
  30162. * @ignorenaming
  30163. */
  30164. static fallbackTexture: string;
  30165. /**
  30166. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30167. * @param u defines the coordinate on X axis
  30168. * @param v defines the coordinate on Y axis
  30169. * @param width defines the width of the source data
  30170. * @param height defines the height of the source data
  30171. * @param pixels defines the source byte array
  30172. * @param color defines the output color
  30173. */
  30174. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30175. /**
  30176. * Interpolates between a and b via alpha
  30177. * @param a The lower value (returned when alpha = 0)
  30178. * @param b The upper value (returned when alpha = 1)
  30179. * @param alpha The interpolation-factor
  30180. * @return The mixed value
  30181. */
  30182. static Mix(a: number, b: number, alpha: number): number;
  30183. /**
  30184. * Tries to instantiate a new object from a given class name
  30185. * @param className defines the class name to instantiate
  30186. * @returns the new object or null if the system was not able to do the instantiation
  30187. */
  30188. static Instantiate(className: string): any;
  30189. /**
  30190. * Provides a slice function that will work even on IE
  30191. * @param data defines the array to slice
  30192. * @param start defines the start of the data (optional)
  30193. * @param end defines the end of the data (optional)
  30194. * @returns the new sliced array
  30195. */
  30196. static Slice<T>(data: T, start?: number, end?: number): T;
  30197. /**
  30198. * Polyfill for setImmediate
  30199. * @param action defines the action to execute after the current execution block
  30200. */
  30201. static SetImmediate(action: () => void): void;
  30202. /**
  30203. * Function indicating if a number is an exponent of 2
  30204. * @param value defines the value to test
  30205. * @returns true if the value is an exponent of 2
  30206. */
  30207. static IsExponentOfTwo(value: number): boolean;
  30208. private static _tmpFloatArray;
  30209. /**
  30210. * Returns the nearest 32-bit single precision float representation of a Number
  30211. * @param value A Number. If the parameter is of a different type, it will get converted
  30212. * to a number or to NaN if it cannot be converted
  30213. * @returns number
  30214. */
  30215. static FloatRound(value: number): number;
  30216. /**
  30217. * Find the next highest power of two.
  30218. * @param x Number to start search from.
  30219. * @return Next highest power of two.
  30220. */
  30221. static CeilingPOT(x: number): number;
  30222. /**
  30223. * Find the next lowest power of two.
  30224. * @param x Number to start search from.
  30225. * @return Next lowest power of two.
  30226. */
  30227. static FloorPOT(x: number): number;
  30228. /**
  30229. * Find the nearest power of two.
  30230. * @param x Number to start search from.
  30231. * @return Next nearest power of two.
  30232. */
  30233. static NearestPOT(x: number): number;
  30234. /**
  30235. * Get the closest exponent of two
  30236. * @param value defines the value to approximate
  30237. * @param max defines the maximum value to return
  30238. * @param mode defines how to define the closest value
  30239. * @returns closest exponent of two of the given value
  30240. */
  30241. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30242. /**
  30243. * Extracts the filename from a path
  30244. * @param path defines the path to use
  30245. * @returns the filename
  30246. */
  30247. static GetFilename(path: string): string;
  30248. /**
  30249. * Extracts the "folder" part of a path (everything before the filename).
  30250. * @param uri The URI to extract the info from
  30251. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30252. * @returns The "folder" part of the path
  30253. */
  30254. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30255. /**
  30256. * Extracts text content from a DOM element hierarchy
  30257. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30258. */
  30259. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30260. /**
  30261. * Convert an angle in radians to degrees
  30262. * @param angle defines the angle to convert
  30263. * @returns the angle in degrees
  30264. */
  30265. static ToDegrees(angle: number): number;
  30266. /**
  30267. * Convert an angle in degrees to radians
  30268. * @param angle defines the angle to convert
  30269. * @returns the angle in radians
  30270. */
  30271. static ToRadians(angle: number): number;
  30272. /**
  30273. * Encode a buffer to a base64 string
  30274. * @param buffer defines the buffer to encode
  30275. * @returns the encoded string
  30276. */
  30277. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30278. /**
  30279. * Extracts minimum and maximum values from a list of indexed positions
  30280. * @param positions defines the positions to use
  30281. * @param indices defines the indices to the positions
  30282. * @param indexStart defines the start index
  30283. * @param indexCount defines the end index
  30284. * @param bias defines bias value to add to the result
  30285. * @return minimum and maximum values
  30286. */
  30287. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30288. minimum: Vector3;
  30289. maximum: Vector3;
  30290. };
  30291. /**
  30292. * Extracts minimum and maximum values from a list of positions
  30293. * @param positions defines the positions to use
  30294. * @param start defines the start index in the positions array
  30295. * @param count defines the number of positions to handle
  30296. * @param bias defines bias value to add to the result
  30297. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30298. * @return minimum and maximum values
  30299. */
  30300. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30301. minimum: Vector3;
  30302. maximum: Vector3;
  30303. };
  30304. /**
  30305. * Returns an array if obj is not an array
  30306. * @param obj defines the object to evaluate as an array
  30307. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30308. * @returns either obj directly if obj is an array or a new array containing obj
  30309. */
  30310. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30311. /**
  30312. * Gets the pointer prefix to use
  30313. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30314. */
  30315. static GetPointerPrefix(): string;
  30316. /**
  30317. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30318. * @param func - the function to be called
  30319. * @param requester - the object that will request the next frame. Falls back to window.
  30320. * @returns frame number
  30321. */
  30322. static QueueNewFrame(func: () => void, requester?: any): number;
  30323. /**
  30324. * Ask the browser to promote the current element to fullscreen rendering mode
  30325. * @param element defines the DOM element to promote
  30326. */
  30327. static RequestFullscreen(element: HTMLElement): void;
  30328. /**
  30329. * Asks the browser to exit fullscreen mode
  30330. */
  30331. static ExitFullscreen(): void;
  30332. /**
  30333. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30334. * @param url define the url we are trying
  30335. * @param element define the dom element where to configure the cors policy
  30336. */
  30337. static SetCorsBehavior(url: string | string[], element: {
  30338. crossOrigin: string | null;
  30339. }): void;
  30340. /**
  30341. * Removes unwanted characters from an url
  30342. * @param url defines the url to clean
  30343. * @returns the cleaned url
  30344. */
  30345. static CleanUrl(url: string): string;
  30346. /**
  30347. * Gets or sets a function used to pre-process url before using them to load assets
  30348. */
  30349. static PreprocessUrl: (url: string) => string;
  30350. /**
  30351. * Loads an image as an HTMLImageElement.
  30352. * @param input url string, ArrayBuffer, or Blob to load
  30353. * @param onLoad callback called when the image successfully loads
  30354. * @param onError callback called when the image fails to load
  30355. * @param offlineProvider offline provider for caching
  30356. * @returns the HTMLImageElement of the loaded image
  30357. */
  30358. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30359. /**
  30360. * Loads a file
  30361. * @param url url string, ArrayBuffer, or Blob to load
  30362. * @param onSuccess callback called when the file successfully loads
  30363. * @param onProgress callback called while file is loading (if the server supports this mode)
  30364. * @param offlineProvider defines the offline provider for caching
  30365. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30366. * @param onError callback called when the file fails to load
  30367. * @returns a file request object
  30368. */
  30369. 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;
  30370. /**
  30371. * Load a script (identified by an url). When the url returns, the
  30372. * content of this file is added into a new script element, attached to the DOM (body element)
  30373. * @param scriptUrl defines the url of the script to laod
  30374. * @param onSuccess defines the callback called when the script is loaded
  30375. * @param onError defines the callback to call if an error occurs
  30376. * @param scriptId defines the id of the script element
  30377. */
  30378. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30379. /**
  30380. * Load an asynchronous script (identified by an url). When the url returns, the
  30381. * content of this file is added into a new script element, attached to the DOM (body element)
  30382. * @param scriptUrl defines the url of the script to laod
  30383. * @param scriptId defines the id of the script element
  30384. * @returns a promise request object
  30385. */
  30386. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30387. /**
  30388. * Loads a file from a blob
  30389. * @param fileToLoad defines the blob to use
  30390. * @param callback defines the callback to call when data is loaded
  30391. * @param progressCallback defines the callback to call during loading process
  30392. * @returns a file request object
  30393. */
  30394. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30395. /**
  30396. * Loads a file
  30397. * @param fileToLoad defines the file to load
  30398. * @param callback defines the callback to call when data is loaded
  30399. * @param progressCallBack defines the callback to call during loading process
  30400. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30401. * @returns a file request object
  30402. */
  30403. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30404. /**
  30405. * Creates a data url from a given string content
  30406. * @param content defines the content to convert
  30407. * @returns the new data url link
  30408. */
  30409. static FileAsURL(content: string): string;
  30410. /**
  30411. * Format the given number to a specific decimal format
  30412. * @param value defines the number to format
  30413. * @param decimals defines the number of decimals to use
  30414. * @returns the formatted string
  30415. */
  30416. static Format(value: number, decimals?: number): string;
  30417. /**
  30418. * Checks if a given vector is inside a specific range
  30419. * @param v defines the vector to test
  30420. * @param min defines the minimum range
  30421. * @param max defines the maximum range
  30422. */
  30423. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30424. /**
  30425. * Tries to copy an object by duplicating every property
  30426. * @param source defines the source object
  30427. * @param destination defines the target object
  30428. * @param doNotCopyList defines a list of properties to avoid
  30429. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30430. */
  30431. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30432. /**
  30433. * Gets a boolean indicating if the given object has no own property
  30434. * @param obj defines the object to test
  30435. * @returns true if object has no own property
  30436. */
  30437. static IsEmpty(obj: any): boolean;
  30438. /**
  30439. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30440. * @param str Source string
  30441. * @param suffix Suffix to search for in the source string
  30442. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30443. */
  30444. static EndsWith(str: string, suffix: string): boolean;
  30445. /**
  30446. * Function used to register events at window level
  30447. * @param events defines the events to register
  30448. */
  30449. static RegisterTopRootEvents(events: {
  30450. name: string;
  30451. handler: Nullable<(e: FocusEvent) => any>;
  30452. }[]): void;
  30453. /**
  30454. * Function used to unregister events from window level
  30455. * @param events defines the events to unregister
  30456. */
  30457. static UnregisterTopRootEvents(events: {
  30458. name: string;
  30459. handler: Nullable<(e: FocusEvent) => any>;
  30460. }[]): void;
  30461. /**
  30462. * @ignore
  30463. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30464. /**
  30465. * Dumps the current bound framebuffer
  30466. * @param width defines the rendering width
  30467. * @param height defines the rendering height
  30468. * @param engine defines the hosting engine
  30469. * @param successCallback defines the callback triggered once the data are available
  30470. * @param mimeType defines the mime type of the result
  30471. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30472. */
  30473. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30474. /**
  30475. * Converts the canvas data to blob.
  30476. * This acts as a polyfill for browsers not supporting the to blob function.
  30477. * @param canvas Defines the canvas to extract the data from
  30478. * @param successCallback Defines the callback triggered once the data are available
  30479. * @param mimeType Defines the mime type of the result
  30480. */
  30481. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30482. /**
  30483. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30484. * @param successCallback defines the callback triggered once the data are available
  30485. * @param mimeType defines the mime type of the result
  30486. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30487. */
  30488. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30489. /**
  30490. * Downloads a blob in the browser
  30491. * @param blob defines the blob to download
  30492. * @param fileName defines the name of the downloaded file
  30493. */
  30494. static Download(blob: Blob, fileName: string): void;
  30495. /**
  30496. * Captures a screenshot of the current rendering
  30497. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30498. * @param engine defines the rendering engine
  30499. * @param camera defines the source camera
  30500. * @param size This parameter can be set to a single number or to an object with the
  30501. * following (optional) properties: precision, width, height. If a single number is passed,
  30502. * it will be used for both width and height. If an object is passed, the screenshot size
  30503. * will be derived from the parameters. The precision property is a multiplier allowing
  30504. * rendering at a higher or lower resolution
  30505. * @param successCallback defines the callback receives a single parameter which contains the
  30506. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30507. * src parameter of an <img> to display it
  30508. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30509. * Check your browser for supported MIME types
  30510. */
  30511. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30512. /**
  30513. * Generates an image screenshot from the specified camera.
  30514. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30515. * @param engine The engine to use for rendering
  30516. * @param camera The camera to use for rendering
  30517. * @param size This parameter can be set to a single number or to an object with the
  30518. * following (optional) properties: precision, width, height. If a single number is passed,
  30519. * it will be used for both width and height. If an object is passed, the screenshot size
  30520. * will be derived from the parameters. The precision property is a multiplier allowing
  30521. * rendering at a higher or lower resolution
  30522. * @param successCallback The callback receives a single parameter which contains the
  30523. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30524. * src parameter of an <img> to display it
  30525. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30526. * Check your browser for supported MIME types
  30527. * @param samples Texture samples (default: 1)
  30528. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30529. * @param fileName A name for for the downloaded file.
  30530. */
  30531. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30532. /**
  30533. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30534. * Be aware Math.random() could cause collisions, but:
  30535. * "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"
  30536. * @returns a pseudo random id
  30537. */
  30538. static RandomId(): string;
  30539. /**
  30540. * Test if the given uri is a base64 string
  30541. * @param uri The uri to test
  30542. * @return True if the uri is a base64 string or false otherwise
  30543. */
  30544. static IsBase64(uri: string): boolean;
  30545. /**
  30546. * Decode the given base64 uri.
  30547. * @param uri The uri to decode
  30548. * @return The decoded base64 data.
  30549. */
  30550. static DecodeBase64(uri: string): ArrayBuffer;
  30551. /**
  30552. * Gets the absolute url.
  30553. * @param url the input url
  30554. * @return the absolute url
  30555. */
  30556. static GetAbsoluteUrl(url: string): string;
  30557. /**
  30558. * No log
  30559. */
  30560. static readonly NoneLogLevel: number;
  30561. /**
  30562. * Only message logs
  30563. */
  30564. static readonly MessageLogLevel: number;
  30565. /**
  30566. * Only warning logs
  30567. */
  30568. static readonly WarningLogLevel: number;
  30569. /**
  30570. * Only error logs
  30571. */
  30572. static readonly ErrorLogLevel: number;
  30573. /**
  30574. * All logs
  30575. */
  30576. static readonly AllLogLevel: number;
  30577. /**
  30578. * Gets a value indicating the number of loading errors
  30579. * @ignorenaming
  30580. */
  30581. static readonly errorsCount: number;
  30582. /**
  30583. * Callback called when a new log is added
  30584. */
  30585. static OnNewCacheEntry: (entry: string) => void;
  30586. /**
  30587. * Log a message to the console
  30588. * @param message defines the message to log
  30589. */
  30590. static Log(message: string): void;
  30591. /**
  30592. * Write a warning message to the console
  30593. * @param message defines the message to log
  30594. */
  30595. static Warn(message: string): void;
  30596. /**
  30597. * Write an error message to the console
  30598. * @param message defines the message to log
  30599. */
  30600. static Error(message: string): void;
  30601. /**
  30602. * Gets current log cache (list of logs)
  30603. */
  30604. static readonly LogCache: string;
  30605. /**
  30606. * Clears the log cache
  30607. */
  30608. static ClearLogCache(): void;
  30609. /**
  30610. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30611. */
  30612. static LogLevels: number;
  30613. /**
  30614. * Checks if the loaded document was accessed via `file:`-Protocol.
  30615. * @returns boolean
  30616. */
  30617. static IsFileURL(): boolean;
  30618. /**
  30619. * Checks if the window object exists
  30620. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30621. */
  30622. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30623. /**
  30624. * No performance log
  30625. */
  30626. static readonly PerformanceNoneLogLevel: number;
  30627. /**
  30628. * Use user marks to log performance
  30629. */
  30630. static readonly PerformanceUserMarkLogLevel: number;
  30631. /**
  30632. * Log performance to the console
  30633. */
  30634. static readonly PerformanceConsoleLogLevel: number;
  30635. private static _performance;
  30636. /**
  30637. * Sets the current performance log level
  30638. */
  30639. static PerformanceLogLevel: number;
  30640. private static _StartPerformanceCounterDisabled;
  30641. private static _EndPerformanceCounterDisabled;
  30642. private static _StartUserMark;
  30643. private static _EndUserMark;
  30644. private static _StartPerformanceConsole;
  30645. private static _EndPerformanceConsole;
  30646. /**
  30647. * Starts a performance counter
  30648. */
  30649. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30650. /**
  30651. * Ends a specific performance coutner
  30652. */
  30653. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30654. /**
  30655. * Gets either window.performance.now() if supported or Date.now() else
  30656. */
  30657. static readonly Now: number;
  30658. /**
  30659. * This method will return the name of the class used to create the instance of the given object.
  30660. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30661. * @param object the object to get the class name from
  30662. * @param isType defines if the object is actually a type
  30663. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30664. */
  30665. static GetClassName(object: any, isType?: boolean): string;
  30666. /**
  30667. * Gets the first element of an array satisfying a given predicate
  30668. * @param array defines the array to browse
  30669. * @param predicate defines the predicate to use
  30670. * @returns null if not found or the element
  30671. */
  30672. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30673. /**
  30674. * This method will return the name of the full name of the class, including its owning module (if any).
  30675. * 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).
  30676. * @param object the object to get the class name from
  30677. * @param isType defines if the object is actually a type
  30678. * @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.
  30679. * @ignorenaming
  30680. */
  30681. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30682. /**
  30683. * Returns a promise that resolves after the given amount of time.
  30684. * @param delay Number of milliseconds to delay
  30685. * @returns Promise that resolves after the given amount of time
  30686. */
  30687. static DelayAsync(delay: number): Promise<void>;
  30688. /**
  30689. * Gets the current gradient from an array of IValueGradient
  30690. * @param ratio defines the current ratio to get
  30691. * @param gradients defines the array of IValueGradient
  30692. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30693. */
  30694. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30695. }
  30696. /**
  30697. * This class is used to track a performance counter which is number based.
  30698. * The user has access to many properties which give statistics of different nature.
  30699. *
  30700. * The implementer can track two kinds of Performance Counter: time and count.
  30701. * 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.
  30702. * 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.
  30703. */
  30704. export class PerfCounter {
  30705. /**
  30706. * Gets or sets a global boolean to turn on and off all the counters
  30707. */
  30708. static Enabled: boolean;
  30709. /**
  30710. * Returns the smallest value ever
  30711. */
  30712. readonly min: number;
  30713. /**
  30714. * Returns the biggest value ever
  30715. */
  30716. readonly max: number;
  30717. /**
  30718. * Returns the average value since the performance counter is running
  30719. */
  30720. readonly average: number;
  30721. /**
  30722. * Returns the average value of the last second the counter was monitored
  30723. */
  30724. readonly lastSecAverage: number;
  30725. /**
  30726. * Returns the current value
  30727. */
  30728. readonly current: number;
  30729. /**
  30730. * Gets the accumulated total
  30731. */
  30732. readonly total: number;
  30733. /**
  30734. * Gets the total value count
  30735. */
  30736. readonly count: number;
  30737. /**
  30738. * Creates a new counter
  30739. */
  30740. constructor();
  30741. /**
  30742. * Call this method to start monitoring a new frame.
  30743. * 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.
  30744. */
  30745. fetchNewFrame(): void;
  30746. /**
  30747. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30748. * @param newCount the count value to add to the monitored count
  30749. * @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.
  30750. */
  30751. addCount(newCount: number, fetchResult: boolean): void;
  30752. /**
  30753. * Start monitoring this performance counter
  30754. */
  30755. beginMonitoring(): void;
  30756. /**
  30757. * Compute the time lapsed since the previous beginMonitoring() call.
  30758. * @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
  30759. */
  30760. endMonitoring(newFrame?: boolean): void;
  30761. private _fetchResult;
  30762. private _startMonitoringTime;
  30763. private _min;
  30764. private _max;
  30765. private _average;
  30766. private _current;
  30767. private _totalValueCount;
  30768. private _totalAccumulated;
  30769. private _lastSecAverage;
  30770. private _lastSecAccumulated;
  30771. private _lastSecTime;
  30772. private _lastSecValueCount;
  30773. }
  30774. /**
  30775. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30776. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30777. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30778. * @param name The name of the class, case should be preserved
  30779. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30780. */
  30781. export function className(name: string, module?: string): (target: Object) => void;
  30782. /**
  30783. * An implementation of a loop for asynchronous functions.
  30784. */
  30785. export class AsyncLoop {
  30786. /**
  30787. * Defines the number of iterations for the loop
  30788. */
  30789. iterations: number;
  30790. /**
  30791. * Defines the current index of the loop.
  30792. */
  30793. index: number;
  30794. private _done;
  30795. private _fn;
  30796. private _successCallback;
  30797. /**
  30798. * Constructor.
  30799. * @param iterations the number of iterations.
  30800. * @param func the function to run each iteration
  30801. * @param successCallback the callback that will be called upon succesful execution
  30802. * @param offset starting offset.
  30803. */
  30804. constructor(
  30805. /**
  30806. * Defines the number of iterations for the loop
  30807. */
  30808. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30809. /**
  30810. * Execute the next iteration. Must be called after the last iteration was finished.
  30811. */
  30812. executeNext(): void;
  30813. /**
  30814. * Break the loop and run the success callback.
  30815. */
  30816. breakLoop(): void;
  30817. /**
  30818. * Create and run an async loop.
  30819. * @param iterations the number of iterations.
  30820. * @param fn the function to run each iteration
  30821. * @param successCallback the callback that will be called upon succesful execution
  30822. * @param offset starting offset.
  30823. * @returns the created async loop object
  30824. */
  30825. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30826. /**
  30827. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30828. * @param iterations total number of iterations
  30829. * @param syncedIterations number of synchronous iterations in each async iteration.
  30830. * @param fn the function to call each iteration.
  30831. * @param callback a success call back that will be called when iterating stops.
  30832. * @param breakFunction a break condition (optional)
  30833. * @param timeout timeout settings for the setTimeout function. default - 0.
  30834. * @returns the created async loop object
  30835. */
  30836. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30837. }
  30838. }
  30839. declare module BABYLON {
  30840. /** @hidden */
  30841. export interface ICollisionCoordinator {
  30842. createCollider(): Collider;
  30843. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30844. init(scene: Scene): void;
  30845. }
  30846. /** @hidden */
  30847. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30848. private _scene;
  30849. private _scaledPosition;
  30850. private _scaledVelocity;
  30851. private _finalPosition;
  30852. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30853. createCollider(): Collider;
  30854. init(scene: Scene): void;
  30855. private _collideWithWorld;
  30856. }
  30857. }
  30858. declare module BABYLON {
  30859. /**
  30860. * This class defines the direct association between an animation and a target
  30861. */
  30862. export class TargetedAnimation {
  30863. /**
  30864. * Animation to perform
  30865. */
  30866. animation: Animation;
  30867. /**
  30868. * Target to animate
  30869. */
  30870. target: any;
  30871. }
  30872. /**
  30873. * Use this class to create coordinated animations on multiple targets
  30874. */
  30875. export class AnimationGroup implements IDisposable {
  30876. /** The name of the animation group */
  30877. name: string;
  30878. private _scene;
  30879. private _targetedAnimations;
  30880. private _animatables;
  30881. private _from;
  30882. private _to;
  30883. private _isStarted;
  30884. private _isPaused;
  30885. private _speedRatio;
  30886. /**
  30887. * Gets or sets the unique id of the node
  30888. */
  30889. uniqueId: number;
  30890. /**
  30891. * This observable will notify when one animation have ended
  30892. */
  30893. onAnimationEndObservable: Observable<TargetedAnimation>;
  30894. /**
  30895. * Observer raised when one animation loops
  30896. */
  30897. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30898. /**
  30899. * This observable will notify when all animations have ended.
  30900. */
  30901. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30902. /**
  30903. * This observable will notify when all animations have paused.
  30904. */
  30905. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30906. /**
  30907. * This observable will notify when all animations are playing.
  30908. */
  30909. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30910. /**
  30911. * Gets the first frame
  30912. */
  30913. readonly from: number;
  30914. /**
  30915. * Gets the last frame
  30916. */
  30917. readonly to: number;
  30918. /**
  30919. * Define if the animations are started
  30920. */
  30921. readonly isStarted: boolean;
  30922. /**
  30923. * Gets a value indicating that the current group is playing
  30924. */
  30925. readonly isPlaying: boolean;
  30926. /**
  30927. * Gets or sets the speed ratio to use for all animations
  30928. */
  30929. /**
  30930. * Gets or sets the speed ratio to use for all animations
  30931. */
  30932. speedRatio: number;
  30933. /**
  30934. * Gets the targeted animations for this animation group
  30935. */
  30936. readonly targetedAnimations: Array<TargetedAnimation>;
  30937. /**
  30938. * returning the list of animatables controlled by this animation group.
  30939. */
  30940. readonly animatables: Array<Animatable>;
  30941. /**
  30942. * Instantiates a new Animation Group.
  30943. * This helps managing several animations at once.
  30944. * @see http://doc.babylonjs.com/how_to/group
  30945. * @param name Defines the name of the group
  30946. * @param scene Defines the scene the group belongs to
  30947. */
  30948. constructor(
  30949. /** The name of the animation group */
  30950. name: string, scene?: Nullable<Scene>);
  30951. /**
  30952. * Add an animation (with its target) in the group
  30953. * @param animation defines the animation we want to add
  30954. * @param target defines the target of the animation
  30955. * @returns the TargetedAnimation object
  30956. */
  30957. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  30958. /**
  30959. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  30960. * It can add constant keys at begin or end
  30961. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  30962. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  30963. * @returns the animation group
  30964. */
  30965. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  30966. /**
  30967. * Start all animations on given targets
  30968. * @param loop defines if animations must loop
  30969. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  30970. * @param from defines the from key (optional)
  30971. * @param to defines the to key (optional)
  30972. * @returns the current animation group
  30973. */
  30974. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  30975. /**
  30976. * Pause all animations
  30977. * @returns the animation group
  30978. */
  30979. pause(): AnimationGroup;
  30980. /**
  30981. * Play all animations to initial state
  30982. * This function will start() the animations if they were not started or will restart() them if they were paused
  30983. * @param loop defines if animations must loop
  30984. * @returns the animation group
  30985. */
  30986. play(loop?: boolean): AnimationGroup;
  30987. /**
  30988. * Reset all animations to initial state
  30989. * @returns the animation group
  30990. */
  30991. reset(): AnimationGroup;
  30992. /**
  30993. * Restart animations from key 0
  30994. * @returns the animation group
  30995. */
  30996. restart(): AnimationGroup;
  30997. /**
  30998. * Stop all animations
  30999. * @returns the animation group
  31000. */
  31001. stop(): AnimationGroup;
  31002. /**
  31003. * Set animation weight for all animatables
  31004. * @param weight defines the weight to use
  31005. * @return the animationGroup
  31006. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31007. */
  31008. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31009. /**
  31010. * Synchronize and normalize all animatables with a source animatable
  31011. * @param root defines the root animatable to synchronize with
  31012. * @return the animationGroup
  31013. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31014. */
  31015. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31016. /**
  31017. * Goes to a specific frame in this animation group
  31018. * @param frame the frame number to go to
  31019. * @return the animationGroup
  31020. */
  31021. goToFrame(frame: number): AnimationGroup;
  31022. /**
  31023. * Dispose all associated resources
  31024. */
  31025. dispose(): void;
  31026. private _checkAnimationGroupEnded;
  31027. /**
  31028. * Clone the current animation group and returns a copy
  31029. * @param newName defines the name of the new group
  31030. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31031. * @returns the new aniamtion group
  31032. */
  31033. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31034. /**
  31035. * Returns a new AnimationGroup object parsed from the source provided.
  31036. * @param parsedAnimationGroup defines the source
  31037. * @param scene defines the scene that will receive the animationGroup
  31038. * @returns a new AnimationGroup
  31039. */
  31040. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31041. /**
  31042. * Returns the string "AnimationGroup"
  31043. * @returns "AnimationGroup"
  31044. */
  31045. getClassName(): string;
  31046. /**
  31047. * Creates a detailled string about the object
  31048. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31049. * @returns a string representing the object
  31050. */
  31051. toString(fullDetails?: boolean): string;
  31052. }
  31053. }
  31054. declare module BABYLON {
  31055. /**
  31056. * Define an interface for all classes that will hold resources
  31057. */
  31058. export interface IDisposable {
  31059. /**
  31060. * Releases all held resources
  31061. */
  31062. dispose(): void;
  31063. }
  31064. /** Interface defining initialization parameters for Scene class */
  31065. export interface SceneOptions {
  31066. /**
  31067. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31068. * It will improve performance when the number of geometries becomes important.
  31069. */
  31070. useGeometryUniqueIdsMap?: boolean;
  31071. /**
  31072. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31073. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31074. */
  31075. useMaterialMeshMap?: boolean;
  31076. /**
  31077. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31078. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31079. */
  31080. useClonedMeshhMap?: boolean;
  31081. }
  31082. /**
  31083. * Represents a scene to be rendered by the engine.
  31084. * @see http://doc.babylonjs.com/features/scene
  31085. */
  31086. export class Scene extends AbstractScene implements IAnimatable {
  31087. private static _uniqueIdCounter;
  31088. /** The fog is deactivated */
  31089. static readonly FOGMODE_NONE: number;
  31090. /** The fog density is following an exponential function */
  31091. static readonly FOGMODE_EXP: number;
  31092. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31093. static readonly FOGMODE_EXP2: number;
  31094. /** The fog density is following a linear function. */
  31095. static readonly FOGMODE_LINEAR: number;
  31096. /**
  31097. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31098. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31099. */
  31100. static MinDeltaTime: number;
  31101. /**
  31102. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31103. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31104. */
  31105. static MaxDeltaTime: number;
  31106. /**
  31107. * Factory used to create the default material.
  31108. * @param name The name of the material to create
  31109. * @param scene The scene to create the material for
  31110. * @returns The default material
  31111. */
  31112. static DefaultMaterialFactory(scene: Scene): Material;
  31113. /**
  31114. * Factory used to create the a collision coordinator.
  31115. * @returns The collision coordinator
  31116. */
  31117. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31118. /** @hidden */ protected readonly _isScene: boolean;
  31119. /**
  31120. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31121. */
  31122. autoClear: boolean;
  31123. /**
  31124. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31125. */
  31126. autoClearDepthAndStencil: boolean;
  31127. /**
  31128. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31129. */
  31130. clearColor: Color4;
  31131. /**
  31132. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31133. */
  31134. ambientColor: Color3;
  31135. /**
  31136. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31137. * It should only be one of the following (if not the default embedded one):
  31138. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31139. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31140. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31141. * The material properties need to be setup according to the type of texture in use.
  31142. */
  31143. environmentBRDFTexture: BaseTexture;
  31144. /** @hidden */
  31145. protected _environmentTexture: Nullable<BaseTexture>;
  31146. /**
  31147. * Texture used in all pbr material as the reflection texture.
  31148. * As in the majority of the scene they are the same (exception for multi room and so on),
  31149. * this is easier to reference from here than from all the materials.
  31150. */
  31151. /**
  31152. * Texture used in all pbr material as the reflection texture.
  31153. * As in the majority of the scene they are the same (exception for multi room and so on),
  31154. * this is easier to set here than in all the materials.
  31155. */
  31156. environmentTexture: Nullable<BaseTexture>;
  31157. /** @hidden */
  31158. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31159. /**
  31160. * Default image processing configuration used either in the rendering
  31161. * Forward main pass or through the imageProcessingPostProcess if present.
  31162. * As in the majority of the scene they are the same (exception for multi camera),
  31163. * this is easier to reference from here than from all the materials and post process.
  31164. *
  31165. * No setter as we it is a shared configuration, you can set the values instead.
  31166. */
  31167. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31168. private _forceWireframe;
  31169. /**
  31170. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31171. */
  31172. forceWireframe: boolean;
  31173. private _forcePointsCloud;
  31174. /**
  31175. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31176. */
  31177. forcePointsCloud: boolean;
  31178. /**
  31179. * Gets or sets the active clipplane 1
  31180. */
  31181. clipPlane: Nullable<Plane>;
  31182. /**
  31183. * Gets or sets the active clipplane 2
  31184. */
  31185. clipPlane2: Nullable<Plane>;
  31186. /**
  31187. * Gets or sets the active clipplane 3
  31188. */
  31189. clipPlane3: Nullable<Plane>;
  31190. /**
  31191. * Gets or sets the active clipplane 4
  31192. */
  31193. clipPlane4: Nullable<Plane>;
  31194. /**
  31195. * Gets or sets a boolean indicating if animations are enabled
  31196. */
  31197. animationsEnabled: boolean;
  31198. private _animationPropertiesOverride;
  31199. /**
  31200. * Gets or sets the animation properties override
  31201. */
  31202. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31203. /**
  31204. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31205. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31206. */
  31207. useConstantAnimationDeltaTime: boolean;
  31208. /**
  31209. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31210. * Please note that it requires to run a ray cast through the scene on every frame
  31211. */
  31212. constantlyUpdateMeshUnderPointer: boolean;
  31213. /**
  31214. * Defines the HTML cursor to use when hovering over interactive elements
  31215. */
  31216. hoverCursor: string;
  31217. /**
  31218. * Defines the HTML default cursor to use (empty by default)
  31219. */
  31220. defaultCursor: string;
  31221. /**
  31222. * This is used to call preventDefault() on pointer down
  31223. * in order to block unwanted artifacts like system double clicks
  31224. */
  31225. preventDefaultOnPointerDown: boolean;
  31226. /**
  31227. * This is used to call preventDefault() on pointer up
  31228. * in order to block unwanted artifacts like system double clicks
  31229. */
  31230. preventDefaultOnPointerUp: boolean;
  31231. /**
  31232. * Gets or sets user defined metadata
  31233. */
  31234. metadata: any;
  31235. /**
  31236. * For internal use only. Please do not use.
  31237. */
  31238. reservedDataStore: any;
  31239. /**
  31240. * Gets the name of the plugin used to load this scene (null by default)
  31241. */
  31242. loadingPluginName: string;
  31243. /**
  31244. * Use this array to add regular expressions used to disable offline support for specific urls
  31245. */
  31246. disableOfflineSupportExceptionRules: RegExp[];
  31247. /**
  31248. * An event triggered when the scene is disposed.
  31249. */
  31250. onDisposeObservable: Observable<Scene>;
  31251. private _onDisposeObserver;
  31252. /** Sets a function to be executed when this scene is disposed. */
  31253. onDispose: () => void;
  31254. /**
  31255. * An event triggered before rendering the scene (right after animations and physics)
  31256. */
  31257. onBeforeRenderObservable: Observable<Scene>;
  31258. private _onBeforeRenderObserver;
  31259. /** Sets a function to be executed before rendering this scene */
  31260. beforeRender: Nullable<() => void>;
  31261. /**
  31262. * An event triggered after rendering the scene
  31263. */
  31264. onAfterRenderObservable: Observable<Scene>;
  31265. private _onAfterRenderObserver;
  31266. /** Sets a function to be executed after rendering this scene */
  31267. afterRender: Nullable<() => void>;
  31268. /**
  31269. * An event triggered before animating the scene
  31270. */
  31271. onBeforeAnimationsObservable: Observable<Scene>;
  31272. /**
  31273. * An event triggered after animations processing
  31274. */
  31275. onAfterAnimationsObservable: Observable<Scene>;
  31276. /**
  31277. * An event triggered before draw calls are ready to be sent
  31278. */
  31279. onBeforeDrawPhaseObservable: Observable<Scene>;
  31280. /**
  31281. * An event triggered after draw calls have been sent
  31282. */
  31283. onAfterDrawPhaseObservable: Observable<Scene>;
  31284. /**
  31285. * An event triggered when the scene is ready
  31286. */
  31287. onReadyObservable: Observable<Scene>;
  31288. /**
  31289. * An event triggered before rendering a camera
  31290. */
  31291. onBeforeCameraRenderObservable: Observable<Camera>;
  31292. private _onBeforeCameraRenderObserver;
  31293. /** Sets a function to be executed before rendering a camera*/
  31294. beforeCameraRender: () => void;
  31295. /**
  31296. * An event triggered after rendering a camera
  31297. */
  31298. onAfterCameraRenderObservable: Observable<Camera>;
  31299. private _onAfterCameraRenderObserver;
  31300. /** Sets a function to be executed after rendering a camera*/
  31301. afterCameraRender: () => void;
  31302. /**
  31303. * An event triggered when active meshes evaluation is about to start
  31304. */
  31305. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31306. /**
  31307. * An event triggered when active meshes evaluation is done
  31308. */
  31309. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31310. /**
  31311. * An event triggered when particles rendering is about to start
  31312. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31313. */
  31314. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31315. /**
  31316. * An event triggered when particles rendering is done
  31317. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31318. */
  31319. onAfterParticlesRenderingObservable: Observable<Scene>;
  31320. /**
  31321. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31322. */
  31323. onDataLoadedObservable: Observable<Scene>;
  31324. /**
  31325. * An event triggered when a camera is created
  31326. */
  31327. onNewCameraAddedObservable: Observable<Camera>;
  31328. /**
  31329. * An event triggered when a camera is removed
  31330. */
  31331. onCameraRemovedObservable: Observable<Camera>;
  31332. /**
  31333. * An event triggered when a light is created
  31334. */
  31335. onNewLightAddedObservable: Observable<Light>;
  31336. /**
  31337. * An event triggered when a light is removed
  31338. */
  31339. onLightRemovedObservable: Observable<Light>;
  31340. /**
  31341. * An event triggered when a geometry is created
  31342. */
  31343. onNewGeometryAddedObservable: Observable<Geometry>;
  31344. /**
  31345. * An event triggered when a geometry is removed
  31346. */
  31347. onGeometryRemovedObservable: Observable<Geometry>;
  31348. /**
  31349. * An event triggered when a transform node is created
  31350. */
  31351. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31352. /**
  31353. * An event triggered when a transform node is removed
  31354. */
  31355. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31356. /**
  31357. * An event triggered when a mesh is created
  31358. */
  31359. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31360. /**
  31361. * An event triggered when a mesh is removed
  31362. */
  31363. onMeshRemovedObservable: Observable<AbstractMesh>;
  31364. /**
  31365. * An event triggered when a skeleton is created
  31366. */
  31367. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31368. /**
  31369. * An event triggered when a skeleton is removed
  31370. */
  31371. onSkeletonRemovedObservable: Observable<Skeleton>;
  31372. /**
  31373. * An event triggered when a material is created
  31374. */
  31375. onNewMaterialAddedObservable: Observable<Material>;
  31376. /**
  31377. * An event triggered when a material is removed
  31378. */
  31379. onMaterialRemovedObservable: Observable<Material>;
  31380. /**
  31381. * An event triggered when a texture is created
  31382. */
  31383. onNewTextureAddedObservable: Observable<BaseTexture>;
  31384. /**
  31385. * An event triggered when a texture is removed
  31386. */
  31387. onTextureRemovedObservable: Observable<BaseTexture>;
  31388. /**
  31389. * An event triggered when render targets are about to be rendered
  31390. * Can happen multiple times per frame.
  31391. */
  31392. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31393. /**
  31394. * An event triggered when render targets were rendered.
  31395. * Can happen multiple times per frame.
  31396. */
  31397. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31398. /**
  31399. * An event triggered before calculating deterministic simulation step
  31400. */
  31401. onBeforeStepObservable: Observable<Scene>;
  31402. /**
  31403. * An event triggered after calculating deterministic simulation step
  31404. */
  31405. onAfterStepObservable: Observable<Scene>;
  31406. /**
  31407. * An event triggered when the activeCamera property is updated
  31408. */
  31409. onActiveCameraChanged: Observable<Scene>;
  31410. /**
  31411. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31412. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31413. * 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)
  31414. */
  31415. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31416. /**
  31417. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31418. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31419. * 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)
  31420. */
  31421. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31422. /**
  31423. * This Observable will when a mesh has been imported into the scene.
  31424. */
  31425. onMeshImportedObservable: Observable<AbstractMesh>;
  31426. /**
  31427. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31428. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31429. */
  31430. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31431. /** @hidden */ registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31432. /**
  31433. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31434. */
  31435. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31436. /**
  31437. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31438. */
  31439. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31440. /**
  31441. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31442. */
  31443. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31444. private _onPointerMove;
  31445. private _onPointerDown;
  31446. private _onPointerUp;
  31447. /** Callback called when a pointer move is detected */
  31448. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31449. /** Callback called when a pointer down is detected */
  31450. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31451. /** Callback called when a pointer up is detected */
  31452. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31453. /** Callback called when a pointer pick is detected */
  31454. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31455. /**
  31456. * 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).
  31457. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31458. */
  31459. onPrePointerObservable: Observable<PointerInfoPre>;
  31460. /**
  31461. * Observable event triggered each time an input event is received from the rendering canvas
  31462. */
  31463. onPointerObservable: Observable<PointerInfo>;
  31464. /**
  31465. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31466. */
  31467. readonly unTranslatedPointer: Vector2;
  31468. /** The distance in pixel that you have to move to prevent some events */
  31469. static DragMovementThreshold: number;
  31470. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31471. static LongPressDelay: number;
  31472. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31473. static DoubleClickDelay: number;
  31474. /** If you need to check double click without raising a single click at first click, enable this flag */
  31475. static ExclusiveDoubleClickMode: boolean;
  31476. private _initClickEvent;
  31477. private _initActionManager;
  31478. private _delayedSimpleClick;
  31479. private _delayedSimpleClickTimeout;
  31480. private _previousDelayedSimpleClickTimeout;
  31481. private _meshPickProceed;
  31482. private _previousButtonPressed;
  31483. private _currentPickResult;
  31484. private _previousPickResult;
  31485. private _totalPointersPressed;
  31486. private _doubleClickOccured;
  31487. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31488. cameraToUseForPointers: Nullable<Camera>;
  31489. private _pointerX;
  31490. private _pointerY;
  31491. private _unTranslatedPointerX;
  31492. private _unTranslatedPointerY;
  31493. private _startingPointerPosition;
  31494. private _previousStartingPointerPosition;
  31495. private _startingPointerTime;
  31496. private _previousStartingPointerTime;
  31497. private _pointerCaptures;
  31498. private _timeAccumulator;
  31499. private _currentStepId;
  31500. private _currentInternalStep;
  31501. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  31502. /**
  31503. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31504. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31505. */
  31506. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31507. /**
  31508. * Observable event triggered each time an keyboard event is received from the hosting window
  31509. */
  31510. onKeyboardObservable: Observable<KeyboardInfo>;
  31511. private _onKeyDown;
  31512. private _onKeyUp;
  31513. private _onCanvasFocusObserver;
  31514. private _onCanvasBlurObserver;
  31515. private _useRightHandedSystem;
  31516. /**
  31517. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31518. */
  31519. useRightHandedSystem: boolean;
  31520. /**
  31521. * Sets the step Id used by deterministic lock step
  31522. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31523. * @param newStepId defines the step Id
  31524. */
  31525. setStepId(newStepId: number): void;
  31526. /**
  31527. * Gets the step Id used by deterministic lock step
  31528. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31529. * @returns the step Id
  31530. */
  31531. getStepId(): number;
  31532. /**
  31533. * Gets the internal step used by deterministic lock step
  31534. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31535. * @returns the internal step
  31536. */
  31537. getInternalStep(): number;
  31538. private _fogEnabled;
  31539. /**
  31540. * Gets or sets a boolean indicating if fog is enabled on this scene
  31541. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31542. * (Default is true)
  31543. */
  31544. fogEnabled: boolean;
  31545. private _fogMode;
  31546. /**
  31547. * Gets or sets the fog mode to use
  31548. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31549. * | mode | value |
  31550. * | --- | --- |
  31551. * | FOGMODE_NONE | 0 |
  31552. * | FOGMODE_EXP | 1 |
  31553. * | FOGMODE_EXP2 | 2 |
  31554. * | FOGMODE_LINEAR | 3 |
  31555. */
  31556. fogMode: number;
  31557. /**
  31558. * Gets or sets the fog color to use
  31559. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31560. * (Default is Color3(0.2, 0.2, 0.3))
  31561. */
  31562. fogColor: Color3;
  31563. /**
  31564. * Gets or sets the fog density to use
  31565. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31566. * (Default is 0.1)
  31567. */
  31568. fogDensity: number;
  31569. /**
  31570. * Gets or sets the fog start distance to use
  31571. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31572. * (Default is 0)
  31573. */
  31574. fogStart: number;
  31575. /**
  31576. * Gets or sets the fog end distance to use
  31577. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31578. * (Default is 1000)
  31579. */
  31580. fogEnd: number;
  31581. private _shadowsEnabled;
  31582. /**
  31583. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31584. */
  31585. shadowsEnabled: boolean;
  31586. private _lightsEnabled;
  31587. /**
  31588. * Gets or sets a boolean indicating if lights are enabled on this scene
  31589. */
  31590. lightsEnabled: boolean;
  31591. /** All of the active cameras added to this scene. */
  31592. activeCameras: Camera[];
  31593. /** @hidden */ activeCamera: Nullable<Camera>;
  31594. /** Gets or sets the current active camera */
  31595. activeCamera: Nullable<Camera>;
  31596. private _defaultMaterial;
  31597. /** The default material used on meshes when no material is affected */
  31598. /** The default material used on meshes when no material is affected */
  31599. defaultMaterial: Material;
  31600. private _texturesEnabled;
  31601. /**
  31602. * Gets or sets a boolean indicating if textures are enabled on this scene
  31603. */
  31604. texturesEnabled: boolean;
  31605. /**
  31606. * Gets or sets a boolean indicating if particles are enabled on this scene
  31607. */
  31608. particlesEnabled: boolean;
  31609. /**
  31610. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31611. */
  31612. spritesEnabled: boolean;
  31613. private _skeletonsEnabled;
  31614. /**
  31615. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31616. */
  31617. skeletonsEnabled: boolean;
  31618. /**
  31619. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31620. */
  31621. lensFlaresEnabled: boolean;
  31622. /**
  31623. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31624. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31625. */
  31626. collisionsEnabled: boolean;
  31627. private _collisionCoordinator;
  31628. /** @hidden */
  31629. readonly collisionCoordinator: ICollisionCoordinator;
  31630. /**
  31631. * Defines the gravity applied to this scene (used only for collisions)
  31632. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31633. */
  31634. gravity: Vector3;
  31635. /**
  31636. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31637. */
  31638. postProcessesEnabled: boolean;
  31639. /**
  31640. * The list of postprocesses added to the scene
  31641. */
  31642. postProcesses: PostProcess[];
  31643. /**
  31644. * Gets the current postprocess manager
  31645. */
  31646. postProcessManager: PostProcessManager;
  31647. /**
  31648. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31649. */
  31650. renderTargetsEnabled: boolean;
  31651. /**
  31652. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31653. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31654. */
  31655. dumpNextRenderTargets: boolean;
  31656. /**
  31657. * The list of user defined render targets added to the scene
  31658. */
  31659. customRenderTargets: RenderTargetTexture[];
  31660. /**
  31661. * Defines if texture loading must be delayed
  31662. * If true, textures will only be loaded when they need to be rendered
  31663. */
  31664. useDelayedTextureLoading: boolean;
  31665. /**
  31666. * Gets the list of meshes imported to the scene through SceneLoader
  31667. */
  31668. importedMeshesFiles: String[];
  31669. /**
  31670. * Gets or sets a boolean indicating if probes are enabled on this scene
  31671. */
  31672. probesEnabled: boolean;
  31673. /**
  31674. * Gets or sets the current offline provider to use to store scene data
  31675. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31676. */
  31677. offlineProvider: IOfflineProvider;
  31678. /**
  31679. * Gets or sets the action manager associated with the scene
  31680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31681. */
  31682. actionManager: AbstractActionManager;
  31683. private _meshesForIntersections;
  31684. /**
  31685. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31686. */
  31687. proceduralTexturesEnabled: boolean;
  31688. private _engine;
  31689. private _totalVertices;
  31690. /** @hidden */ activeIndices: PerfCounter;
  31691. /** @hidden */ activeParticles: PerfCounter;
  31692. /** @hidden */ activeBones: PerfCounter;
  31693. private _animationRatio;
  31694. /** @hidden */ animationTimeLast: number;
  31695. /** @hidden */ animationTime: number;
  31696. /**
  31697. * Gets or sets a general scale for animation speed
  31698. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31699. */
  31700. animationTimeScale: number;
  31701. /** @hidden */ cachedMaterial: Nullable<Material>;
  31702. /** @hidden */ cachedEffect: Nullable<Effect>;
  31703. /** @hidden */ cachedVisibility: Nullable<number>;
  31704. private _renderId;
  31705. private _frameId;
  31706. private _executeWhenReadyTimeoutId;
  31707. private _intermediateRendering;
  31708. private _viewUpdateFlag;
  31709. private _projectionUpdateFlag;
  31710. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  31711. private _activeRequests;
  31712. /** @hidden */ pendingData: any[];
  31713. private _isDisposed;
  31714. /**
  31715. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31716. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31717. */
  31718. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31719. private _activeMeshes;
  31720. private _processedMaterials;
  31721. private _renderTargets;
  31722. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  31723. private _activeSkeletons;
  31724. private _softwareSkinnedMeshes;
  31725. private _renderingManager;
  31726. /** @hidden */ activeAnimatables: Animatable[];
  31727. private _transformMatrix;
  31728. private _sceneUbo;
  31729. /** @hidden */ viewMatrix: Matrix;
  31730. private _projectionMatrix;
  31731. private _wheelEventName;
  31732. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  31733. /** @hidden */ frustumPlanes: Plane[];
  31734. /**
  31735. * Gets the list of frustum planes (built from the active camera)
  31736. */
  31737. readonly frustumPlanes: Plane[];
  31738. /**
  31739. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31740. * This is useful if there are more lights that the maximum simulteanous authorized
  31741. */
  31742. requireLightSorting: boolean;
  31743. /** @hidden */
  31744. readonly useMaterialMeshMap: boolean;
  31745. /** @hidden */
  31746. readonly useClonedMeshhMap: boolean;
  31747. private _pointerOverMesh;
  31748. private _pickedDownMesh;
  31749. private _pickedUpMesh;
  31750. private _externalData;
  31751. private _uid;
  31752. /**
  31753. * @hidden
  31754. * Backing store of defined scene components.
  31755. */ components: ISceneComponent[];
  31756. /**
  31757. * @hidden
  31758. * Backing store of defined scene components.
  31759. */ serializableComponents: ISceneSerializableComponent[];
  31760. /**
  31761. * List of components to register on the next registration step.
  31762. */
  31763. private _transientComponents;
  31764. /**
  31765. * Registers the transient components if needed.
  31766. */
  31767. private _registerTransientComponents;
  31768. /**
  31769. * @hidden
  31770. * Add a component to the scene.
  31771. * Note that the ccomponent could be registered on th next frame if this is called after
  31772. * the register component stage.
  31773. * @param component Defines the component to add to the scene
  31774. */ addComponent(component: ISceneComponent): void;
  31775. /**
  31776. * @hidden
  31777. * Gets a component from the scene.
  31778. * @param name defines the name of the component to retrieve
  31779. * @returns the component or null if not present
  31780. */ getComponent(name: string): Nullable<ISceneComponent>;
  31781. /**
  31782. * @hidden
  31783. * Defines the actions happening before camera updates.
  31784. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31785. /**
  31786. * @hidden
  31787. * Defines the actions happening before clear the canvas.
  31788. */ beforeClearStage: Stage<SimpleStageAction>;
  31789. /**
  31790. * @hidden
  31791. * Defines the actions when collecting render targets for the frame.
  31792. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31793. /**
  31794. * @hidden
  31795. * Defines the actions happening for one camera in the frame.
  31796. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31797. /**
  31798. * @hidden
  31799. * Defines the actions happening during the per mesh ready checks.
  31800. */ isReadyForMeshStage: Stage<MeshStageAction>;
  31801. /**
  31802. * @hidden
  31803. * Defines the actions happening before evaluate active mesh checks.
  31804. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31805. /**
  31806. * @hidden
  31807. * Defines the actions happening during the evaluate sub mesh checks.
  31808. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31809. /**
  31810. * @hidden
  31811. * Defines the actions happening during the active mesh stage.
  31812. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  31813. /**
  31814. * @hidden
  31815. * Defines the actions happening during the per camera render target step.
  31816. */ cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  31817. /**
  31818. * @hidden
  31819. * Defines the actions happening just before the active camera is drawing.
  31820. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  31821. /**
  31822. * @hidden
  31823. * Defines the actions happening just before a render target is drawing.
  31824. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31825. /**
  31826. * @hidden
  31827. * Defines the actions happening just before a rendering group is drawing.
  31828. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31829. /**
  31830. * @hidden
  31831. * Defines the actions happening just before a mesh is drawing.
  31832. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31833. /**
  31834. * @hidden
  31835. * Defines the actions happening just after a mesh has been drawn.
  31836. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31837. /**
  31838. * @hidden
  31839. * Defines the actions happening just after a rendering group has been drawn.
  31840. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31841. /**
  31842. * @hidden
  31843. * Defines the actions happening just after the active camera has been drawn.
  31844. */ afterCameraDrawStage: Stage<CameraStageAction>;
  31845. /**
  31846. * @hidden
  31847. * Defines the actions happening just after a render target has been drawn.
  31848. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31849. /**
  31850. * @hidden
  31851. * Defines the actions happening just after rendering all cameras and computing intersections.
  31852. */ afterRenderStage: Stage<SimpleStageAction>;
  31853. /**
  31854. * @hidden
  31855. * Defines the actions happening when a pointer move event happens.
  31856. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  31857. /**
  31858. * @hidden
  31859. * Defines the actions happening when a pointer down event happens.
  31860. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  31861. /**
  31862. * @hidden
  31863. * Defines the actions happening when a pointer up event happens.
  31864. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  31865. /**
  31866. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31867. */
  31868. private geometriesByUniqueId;
  31869. /**
  31870. * Creates a new Scene
  31871. * @param engine defines the engine to use to render this scene
  31872. * @param options defines the scene options
  31873. */
  31874. constructor(engine: Engine, options?: SceneOptions);
  31875. /**
  31876. * Gets a string idenfifying the name of the class
  31877. * @returns "Scene" string
  31878. */
  31879. getClassName(): string;
  31880. private _defaultMeshCandidates;
  31881. /**
  31882. * @hidden
  31883. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31884. private _defaultSubMeshCandidates;
  31885. /**
  31886. * @hidden
  31887. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31888. /**
  31889. * Sets the default candidate providers for the scene.
  31890. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31891. * and getCollidingSubMeshCandidates to their default function
  31892. */
  31893. setDefaultCandidateProviders(): void;
  31894. /**
  31895. * Gets the mesh that is currently under the pointer
  31896. */
  31897. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31898. /**
  31899. * Gets or sets the current on-screen X position of the pointer
  31900. */
  31901. pointerX: number;
  31902. /**
  31903. * Gets or sets the current on-screen Y position of the pointer
  31904. */
  31905. pointerY: number;
  31906. /**
  31907. * Gets the cached material (ie. the latest rendered one)
  31908. * @returns the cached material
  31909. */
  31910. getCachedMaterial(): Nullable<Material>;
  31911. /**
  31912. * Gets the cached effect (ie. the latest rendered one)
  31913. * @returns the cached effect
  31914. */
  31915. getCachedEffect(): Nullable<Effect>;
  31916. /**
  31917. * Gets the cached visibility state (ie. the latest rendered one)
  31918. * @returns the cached visibility state
  31919. */
  31920. getCachedVisibility(): Nullable<number>;
  31921. /**
  31922. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31923. * @param material defines the current material
  31924. * @param effect defines the current effect
  31925. * @param visibility defines the current visibility state
  31926. * @returns true if one parameter is not cached
  31927. */
  31928. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31929. /**
  31930. * Gets the engine associated with the scene
  31931. * @returns an Engine
  31932. */
  31933. getEngine(): Engine;
  31934. /**
  31935. * Gets the total number of vertices rendered per frame
  31936. * @returns the total number of vertices rendered per frame
  31937. */
  31938. getTotalVertices(): number;
  31939. /**
  31940. * Gets the performance counter for total vertices
  31941. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31942. */
  31943. readonly totalVerticesPerfCounter: PerfCounter;
  31944. /**
  31945. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  31946. * @returns the total number of active indices rendered per frame
  31947. */
  31948. getActiveIndices(): number;
  31949. /**
  31950. * Gets the performance counter for active indices
  31951. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31952. */
  31953. readonly totalActiveIndicesPerfCounter: PerfCounter;
  31954. /**
  31955. * Gets the total number of active particles rendered per frame
  31956. * @returns the total number of active particles rendered per frame
  31957. */
  31958. getActiveParticles(): number;
  31959. /**
  31960. * Gets the performance counter for active particles
  31961. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31962. */
  31963. readonly activeParticlesPerfCounter: PerfCounter;
  31964. /**
  31965. * Gets the total number of active bones rendered per frame
  31966. * @returns the total number of active bones rendered per frame
  31967. */
  31968. getActiveBones(): number;
  31969. /**
  31970. * Gets the performance counter for active bones
  31971. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31972. */
  31973. readonly activeBonesPerfCounter: PerfCounter;
  31974. /**
  31975. * Gets the array of active meshes
  31976. * @returns an array of AbstractMesh
  31977. */
  31978. getActiveMeshes(): SmartArray<AbstractMesh>;
  31979. /**
  31980. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  31981. * @returns a number
  31982. */
  31983. getAnimationRatio(): number;
  31984. /**
  31985. * Gets an unique Id for the current render phase
  31986. * @returns a number
  31987. */
  31988. getRenderId(): number;
  31989. /**
  31990. * Gets an unique Id for the current frame
  31991. * @returns a number
  31992. */
  31993. getFrameId(): number;
  31994. /** Call this function if you want to manually increment the render Id*/
  31995. incrementRenderId(): void;
  31996. private _updatePointerPosition;
  31997. private _createUbo;
  31998. private _setRayOnPointerInfo;
  31999. /**
  32000. * Use this method to simulate a pointer move on a mesh
  32001. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32002. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32003. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32004. * @returns the current scene
  32005. */
  32006. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32007. private _processPointerMove;
  32008. private _checkPrePointerObservable;
  32009. /**
  32010. * Use this method to simulate a pointer down on a mesh
  32011. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32012. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32013. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32014. * @returns the current scene
  32015. */
  32016. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32017. private _processPointerDown;
  32018. /**
  32019. * Use this method to simulate a pointer up on a mesh
  32020. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32021. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32022. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32023. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32024. * @returns the current scene
  32025. */
  32026. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32027. private _processPointerUp;
  32028. /**
  32029. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32030. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32031. * @returns true if the pointer was captured
  32032. */
  32033. isPointerCaptured(pointerId?: number): boolean;
  32034. /** @hidden */ isPointerSwiping(): boolean;
  32035. /**
  32036. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32037. * @param attachUp defines if you want to attach events to pointerup
  32038. * @param attachDown defines if you want to attach events to pointerdown
  32039. * @param attachMove defines if you want to attach events to pointermove
  32040. */
  32041. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32042. /** Detaches all event handlers*/
  32043. detachControl(): void;
  32044. /**
  32045. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32046. * Delay loaded resources are not taking in account
  32047. * @return true if all required resources are ready
  32048. */
  32049. isReady(): boolean;
  32050. /** Resets all cached information relative to material (including effect and visibility) */
  32051. resetCachedMaterial(): void;
  32052. /**
  32053. * Registers a function to be called before every frame render
  32054. * @param func defines the function to register
  32055. */
  32056. registerBeforeRender(func: () => void): void;
  32057. /**
  32058. * Unregisters a function called before every frame render
  32059. * @param func defines the function to unregister
  32060. */
  32061. unregisterBeforeRender(func: () => void): void;
  32062. /**
  32063. * Registers a function to be called after every frame render
  32064. * @param func defines the function to register
  32065. */
  32066. registerAfterRender(func: () => void): void;
  32067. /**
  32068. * Unregisters a function called after every frame render
  32069. * @param func defines the function to unregister
  32070. */
  32071. unregisterAfterRender(func: () => void): void;
  32072. private _executeOnceBeforeRender;
  32073. /**
  32074. * The provided function will run before render once and will be disposed afterwards.
  32075. * A timeout delay can be provided so that the function will be executed in N ms.
  32076. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32077. * @param func The function to be executed.
  32078. * @param timeout optional delay in ms
  32079. */
  32080. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32081. /** @hidden */ addPendingData(data: any): void;
  32082. /** @hidden */ removePendingData(data: any): void;
  32083. /**
  32084. * Returns the number of items waiting to be loaded
  32085. * @returns the number of items waiting to be loaded
  32086. */
  32087. getWaitingItemsCount(): number;
  32088. /**
  32089. * Returns a boolean indicating if the scene is still loading data
  32090. */
  32091. readonly isLoading: boolean;
  32092. /**
  32093. * Registers a function to be executed when the scene is ready
  32094. * @param {Function} func - the function to be executed
  32095. */
  32096. executeWhenReady(func: () => void): void;
  32097. /**
  32098. * Returns a promise that resolves when the scene is ready
  32099. * @returns A promise that resolves when the scene is ready
  32100. */
  32101. whenReadyAsync(): Promise<void>;
  32102. /** @hidden */ checkIsReady(): void;
  32103. /**
  32104. * Gets all animatable attached to the scene
  32105. */
  32106. readonly animatables: Animatable[];
  32107. /**
  32108. * Resets the last animation time frame.
  32109. * Useful to override when animations start running when loading a scene for the first time.
  32110. */
  32111. resetLastAnimationTimeFrame(): void;
  32112. /**
  32113. * Gets the current view matrix
  32114. * @returns a Matrix
  32115. */
  32116. getViewMatrix(): Matrix;
  32117. /**
  32118. * Gets the current projection matrix
  32119. * @returns a Matrix
  32120. */
  32121. getProjectionMatrix(): Matrix;
  32122. /**
  32123. * Gets the current transform matrix
  32124. * @returns a Matrix made of View * Projection
  32125. */
  32126. getTransformMatrix(): Matrix;
  32127. /**
  32128. * Sets the current transform matrix
  32129. * @param viewL defines the View matrix to use
  32130. * @param projectionL defines the Projection matrix to use
  32131. * @param viewR defines the right View matrix to use (if provided)
  32132. * @param projectionR defines the right Projection matrix to use (if provided)
  32133. */
  32134. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32135. /**
  32136. * Gets the uniform buffer used to store scene data
  32137. * @returns a UniformBuffer
  32138. */
  32139. getSceneUniformBuffer(): UniformBuffer;
  32140. /**
  32141. * Gets an unique (relatively to the current scene) Id
  32142. * @returns an unique number for the scene
  32143. */
  32144. getUniqueId(): number;
  32145. /**
  32146. * Add a mesh to the list of scene's meshes
  32147. * @param newMesh defines the mesh to add
  32148. * @param recursive if all child meshes should also be added to the scene
  32149. */
  32150. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32151. /**
  32152. * Remove a mesh for the list of scene's meshes
  32153. * @param toRemove defines the mesh to remove
  32154. * @param recursive if all child meshes should also be removed from the scene
  32155. * @returns the index where the mesh was in the mesh list
  32156. */
  32157. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32158. /**
  32159. * Add a transform node to the list of scene's transform nodes
  32160. * @param newTransformNode defines the transform node to add
  32161. */
  32162. addTransformNode(newTransformNode: TransformNode): void;
  32163. /**
  32164. * Remove a transform node for the list of scene's transform nodes
  32165. * @param toRemove defines the transform node to remove
  32166. * @returns the index where the transform node was in the transform node list
  32167. */
  32168. removeTransformNode(toRemove: TransformNode): number;
  32169. /**
  32170. * Remove a skeleton for the list of scene's skeletons
  32171. * @param toRemove defines the skeleton to remove
  32172. * @returns the index where the skeleton was in the skeleton list
  32173. */
  32174. removeSkeleton(toRemove: Skeleton): number;
  32175. /**
  32176. * Remove a morph target for the list of scene's morph targets
  32177. * @param toRemove defines the morph target to remove
  32178. * @returns the index where the morph target was in the morph target list
  32179. */
  32180. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32181. /**
  32182. * Remove a light for the list of scene's lights
  32183. * @param toRemove defines the light to remove
  32184. * @returns the index where the light was in the light list
  32185. */
  32186. removeLight(toRemove: Light): number;
  32187. /**
  32188. * Remove a camera for the list of scene's cameras
  32189. * @param toRemove defines the camera to remove
  32190. * @returns the index where the camera was in the camera list
  32191. */
  32192. removeCamera(toRemove: Camera): number;
  32193. /**
  32194. * Remove a particle system for the list of scene's particle systems
  32195. * @param toRemove defines the particle system to remove
  32196. * @returns the index where the particle system was in the particle system list
  32197. */
  32198. removeParticleSystem(toRemove: IParticleSystem): number;
  32199. /**
  32200. * Remove a animation for the list of scene's animations
  32201. * @param toRemove defines the animation to remove
  32202. * @returns the index where the animation was in the animation list
  32203. */
  32204. removeAnimation(toRemove: Animation): number;
  32205. /**
  32206. * Removes the given animation group from this scene.
  32207. * @param toRemove The animation group to remove
  32208. * @returns The index of the removed animation group
  32209. */
  32210. removeAnimationGroup(toRemove: AnimationGroup): number;
  32211. /**
  32212. * Removes the given multi-material from this scene.
  32213. * @param toRemove The multi-material to remove
  32214. * @returns The index of the removed multi-material
  32215. */
  32216. removeMultiMaterial(toRemove: MultiMaterial): number;
  32217. /**
  32218. * Removes the given material from this scene.
  32219. * @param toRemove The material to remove
  32220. * @returns The index of the removed material
  32221. */
  32222. removeMaterial(toRemove: Material): number;
  32223. /**
  32224. * Removes the given action manager from this scene.
  32225. * @param toRemove The action manager to remove
  32226. * @returns The index of the removed action manager
  32227. */
  32228. removeActionManager(toRemove: AbstractActionManager): number;
  32229. /**
  32230. * Removes the given texture from this scene.
  32231. * @param toRemove The texture to remove
  32232. * @returns The index of the removed texture
  32233. */
  32234. removeTexture(toRemove: BaseTexture): number;
  32235. /**
  32236. * Adds the given light to this scene
  32237. * @param newLight The light to add
  32238. */
  32239. addLight(newLight: Light): void;
  32240. /**
  32241. * Sorts the list list based on light priorities
  32242. */
  32243. sortLightsByPriority(): void;
  32244. /**
  32245. * Adds the given camera to this scene
  32246. * @param newCamera The camera to add
  32247. */
  32248. addCamera(newCamera: Camera): void;
  32249. /**
  32250. * Adds the given skeleton to this scene
  32251. * @param newSkeleton The skeleton to add
  32252. */
  32253. addSkeleton(newSkeleton: Skeleton): void;
  32254. /**
  32255. * Adds the given particle system to this scene
  32256. * @param newParticleSystem The particle system to add
  32257. */
  32258. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32259. /**
  32260. * Adds the given animation to this scene
  32261. * @param newAnimation The animation to add
  32262. */
  32263. addAnimation(newAnimation: Animation): void;
  32264. /**
  32265. * Adds the given animation group to this scene.
  32266. * @param newAnimationGroup The animation group to add
  32267. */
  32268. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32269. /**
  32270. * Adds the given multi-material to this scene
  32271. * @param newMultiMaterial The multi-material to add
  32272. */
  32273. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32274. /**
  32275. * Adds the given material to this scene
  32276. * @param newMaterial The material to add
  32277. */
  32278. addMaterial(newMaterial: Material): void;
  32279. /**
  32280. * Adds the given morph target to this scene
  32281. * @param newMorphTargetManager The morph target to add
  32282. */
  32283. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32284. /**
  32285. * Adds the given geometry to this scene
  32286. * @param newGeometry The geometry to add
  32287. */
  32288. addGeometry(newGeometry: Geometry): void;
  32289. /**
  32290. * Adds the given action manager to this scene
  32291. * @param newActionManager The action manager to add
  32292. */
  32293. addActionManager(newActionManager: AbstractActionManager): void;
  32294. /**
  32295. * Adds the given texture to this scene.
  32296. * @param newTexture The texture to add
  32297. */
  32298. addTexture(newTexture: BaseTexture): void;
  32299. /**
  32300. * Switch active camera
  32301. * @param newCamera defines the new active camera
  32302. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32303. */
  32304. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32305. /**
  32306. * sets the active camera of the scene using its ID
  32307. * @param id defines the camera's ID
  32308. * @return the new active camera or null if none found.
  32309. */
  32310. setActiveCameraByID(id: string): Nullable<Camera>;
  32311. /**
  32312. * sets the active camera of the scene using its name
  32313. * @param name defines the camera's name
  32314. * @returns the new active camera or null if none found.
  32315. */
  32316. setActiveCameraByName(name: string): Nullable<Camera>;
  32317. /**
  32318. * get an animation group using its name
  32319. * @param name defines the material's name
  32320. * @return the animation group or null if none found.
  32321. */
  32322. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32323. /**
  32324. * Get a material using its unique id
  32325. * @param uniqueId defines the material's unique id
  32326. * @return the material or null if none found.
  32327. */
  32328. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32329. /**
  32330. * get a material using its id
  32331. * @param id defines the material's ID
  32332. * @return the material or null if none found.
  32333. */
  32334. getMaterialByID(id: string): Nullable<Material>;
  32335. /**
  32336. * Gets a material using its name
  32337. * @param name defines the material's name
  32338. * @return the material or null if none found.
  32339. */
  32340. getMaterialByName(name: string): Nullable<Material>;
  32341. /**
  32342. * Gets a camera using its id
  32343. * @param id defines the id to look for
  32344. * @returns the camera or null if not found
  32345. */
  32346. getCameraByID(id: string): Nullable<Camera>;
  32347. /**
  32348. * Gets a camera using its unique id
  32349. * @param uniqueId defines the unique id to look for
  32350. * @returns the camera or null if not found
  32351. */
  32352. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32353. /**
  32354. * Gets a camera using its name
  32355. * @param name defines the camera's name
  32356. * @return the camera or null if none found.
  32357. */
  32358. getCameraByName(name: string): Nullable<Camera>;
  32359. /**
  32360. * Gets a bone using its id
  32361. * @param id defines the bone's id
  32362. * @return the bone or null if not found
  32363. */
  32364. getBoneByID(id: string): Nullable<Bone>;
  32365. /**
  32366. * Gets a bone using its id
  32367. * @param name defines the bone's name
  32368. * @return the bone or null if not found
  32369. */
  32370. getBoneByName(name: string): Nullable<Bone>;
  32371. /**
  32372. * Gets a light node using its name
  32373. * @param name defines the the light's name
  32374. * @return the light or null if none found.
  32375. */
  32376. getLightByName(name: string): Nullable<Light>;
  32377. /**
  32378. * Gets a light node using its id
  32379. * @param id defines the light's id
  32380. * @return the light or null if none found.
  32381. */
  32382. getLightByID(id: string): Nullable<Light>;
  32383. /**
  32384. * Gets a light node using its scene-generated unique ID
  32385. * @param uniqueId defines the light's unique id
  32386. * @return the light or null if none found.
  32387. */
  32388. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32389. /**
  32390. * Gets a particle system by id
  32391. * @param id defines the particle system id
  32392. * @return the corresponding system or null if none found
  32393. */
  32394. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32395. /**
  32396. * Gets a geometry using its ID
  32397. * @param id defines the geometry's id
  32398. * @return the geometry or null if none found.
  32399. */
  32400. getGeometryByID(id: string): Nullable<Geometry>;
  32401. private _getGeometryByUniqueID;
  32402. /**
  32403. * Add a new geometry to this scene
  32404. * @param geometry defines the geometry to be added to the scene.
  32405. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32406. * @return a boolean defining if the geometry was added or not
  32407. */
  32408. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32409. /**
  32410. * Removes an existing geometry
  32411. * @param geometry defines the geometry to be removed from the scene
  32412. * @return a boolean defining if the geometry was removed or not
  32413. */
  32414. removeGeometry(geometry: Geometry): boolean;
  32415. /**
  32416. * Gets the list of geometries attached to the scene
  32417. * @returns an array of Geometry
  32418. */
  32419. getGeometries(): Geometry[];
  32420. /**
  32421. * Gets the first added mesh found of a given ID
  32422. * @param id defines the id to search for
  32423. * @return the mesh found or null if not found at all
  32424. */
  32425. getMeshByID(id: string): Nullable<AbstractMesh>;
  32426. /**
  32427. * Gets a list of meshes using their id
  32428. * @param id defines the id to search for
  32429. * @returns a list of meshes
  32430. */
  32431. getMeshesByID(id: string): Array<AbstractMesh>;
  32432. /**
  32433. * Gets the first added transform node found of a given ID
  32434. * @param id defines the id to search for
  32435. * @return the found transform node or null if not found at all.
  32436. */
  32437. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32438. /**
  32439. * Gets a transform node with its auto-generated unique id
  32440. * @param uniqueId efines the unique id to search for
  32441. * @return the found transform node or null if not found at all.
  32442. */
  32443. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32444. /**
  32445. * Gets a list of transform nodes using their id
  32446. * @param id defines the id to search for
  32447. * @returns a list of transform nodes
  32448. */
  32449. getTransformNodesByID(id: string): Array<TransformNode>;
  32450. /**
  32451. * Gets a mesh with its auto-generated unique id
  32452. * @param uniqueId defines the unique id to search for
  32453. * @return the found mesh or null if not found at all.
  32454. */
  32455. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32456. /**
  32457. * Gets a the last added mesh using a given id
  32458. * @param id defines the id to search for
  32459. * @return the found mesh or null if not found at all.
  32460. */
  32461. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32462. /**
  32463. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32464. * @param id defines the id to search for
  32465. * @return the found node or null if not found at all
  32466. */
  32467. getLastEntryByID(id: string): Nullable<Node>;
  32468. /**
  32469. * Gets a node (Mesh, Camera, Light) using a given id
  32470. * @param id defines the id to search for
  32471. * @return the found node or null if not found at all
  32472. */
  32473. getNodeByID(id: string): Nullable<Node>;
  32474. /**
  32475. * Gets a node (Mesh, Camera, Light) using a given name
  32476. * @param name defines the name to search for
  32477. * @return the found node or null if not found at all.
  32478. */
  32479. getNodeByName(name: string): Nullable<Node>;
  32480. /**
  32481. * Gets a mesh using a given name
  32482. * @param name defines the name to search for
  32483. * @return the found mesh or null if not found at all.
  32484. */
  32485. getMeshByName(name: string): Nullable<AbstractMesh>;
  32486. /**
  32487. * Gets a transform node using a given name
  32488. * @param name defines the name to search for
  32489. * @return the found transform node or null if not found at all.
  32490. */
  32491. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32492. /**
  32493. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32494. * @param id defines the id to search for
  32495. * @return the found skeleton or null if not found at all.
  32496. */
  32497. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32498. /**
  32499. * Gets a skeleton using a given auto generated unique id
  32500. * @param uniqueId defines the unique id to search for
  32501. * @return the found skeleton or null if not found at all.
  32502. */
  32503. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32504. /**
  32505. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32506. * @param id defines the id to search for
  32507. * @return the found skeleton or null if not found at all.
  32508. */
  32509. getSkeletonById(id: string): Nullable<Skeleton>;
  32510. /**
  32511. * Gets a skeleton using a given name
  32512. * @param name defines the name to search for
  32513. * @return the found skeleton or null if not found at all.
  32514. */
  32515. getSkeletonByName(name: string): Nullable<Skeleton>;
  32516. /**
  32517. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32518. * @param id defines the id to search for
  32519. * @return the found morph target manager or null if not found at all.
  32520. */
  32521. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32522. /**
  32523. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32524. * @param id defines the id to search for
  32525. * @return the found morph target or null if not found at all.
  32526. */
  32527. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32528. /**
  32529. * Gets a boolean indicating if the given mesh is active
  32530. * @param mesh defines the mesh to look for
  32531. * @returns true if the mesh is in the active list
  32532. */
  32533. isActiveMesh(mesh: AbstractMesh): boolean;
  32534. /**
  32535. * Return a unique id as a string which can serve as an identifier for the scene
  32536. */
  32537. readonly uid: string;
  32538. /**
  32539. * Add an externaly attached data from its key.
  32540. * This method call will fail and return false, if such key already exists.
  32541. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32542. * @param key the unique key that identifies the data
  32543. * @param data the data object to associate to the key for this Engine instance
  32544. * @return true if no such key were already present and the data was added successfully, false otherwise
  32545. */
  32546. addExternalData<T>(key: string, data: T): boolean;
  32547. /**
  32548. * Get an externaly attached data from its key
  32549. * @param key the unique key that identifies the data
  32550. * @return the associated data, if present (can be null), or undefined if not present
  32551. */
  32552. getExternalData<T>(key: string): Nullable<T>;
  32553. /**
  32554. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32555. * @param key the unique key that identifies the data
  32556. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32557. * @return the associated data, can be null if the factory returned null.
  32558. */
  32559. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32560. /**
  32561. * Remove an externaly attached data from the Engine instance
  32562. * @param key the unique key that identifies the data
  32563. * @return true if the data was successfully removed, false if it doesn't exist
  32564. */
  32565. removeExternalData(key: string): boolean;
  32566. private _evaluateSubMesh;
  32567. /**
  32568. * Clear the processed materials smart array preventing retention point in material dispose.
  32569. */
  32570. freeProcessedMaterials(): void;
  32571. private _preventFreeActiveMeshesAndRenderingGroups;
  32572. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32573. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32574. * when disposing several meshes in a row or a hierarchy of meshes.
  32575. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32576. */
  32577. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32578. /**
  32579. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32580. */
  32581. freeActiveMeshes(): void;
  32582. /**
  32583. * Clear the info related to rendering groups preventing retention points during dispose.
  32584. */
  32585. freeRenderingGroups(): void;
  32586. /** @hidden */ isInIntermediateRendering(): boolean;
  32587. /**
  32588. * Lambda returning the list of potentially active meshes.
  32589. */
  32590. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32591. /**
  32592. * Lambda returning the list of potentially active sub meshes.
  32593. */
  32594. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32595. /**
  32596. * Lambda returning the list of potentially intersecting sub meshes.
  32597. */
  32598. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32599. /**
  32600. * Lambda returning the list of potentially colliding sub meshes.
  32601. */
  32602. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32603. private _activeMeshesFrozen;
  32604. /**
  32605. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32606. * @returns the current scene
  32607. */
  32608. freezeActiveMeshes(): Scene;
  32609. /**
  32610. * Use this function to restart evaluating active meshes on every frame
  32611. * @returns the current scene
  32612. */
  32613. unfreezeActiveMeshes(): Scene;
  32614. private _evaluateActiveMeshes;
  32615. private _activeMesh;
  32616. /**
  32617. * Update the transform matrix to update from the current active camera
  32618. * @param force defines a boolean used to force the update even if cache is up to date
  32619. */
  32620. updateTransformMatrix(force?: boolean): void;
  32621. private _bindFrameBuffer;
  32622. /** @hidden */ allowPostProcessClearColor: boolean;
  32623. /** @hidden */ renderForCamera(camera: Camera, rigParent?: Camera): void;
  32624. private _processSubCameras;
  32625. private _checkIntersections;
  32626. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  32627. /**
  32628. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32629. */
  32630. getDeterministicFrameTime: () => number;
  32631. /** @hidden */ animate(): void;
  32632. /** Execute all animations (for a frame) */
  32633. animate(): void;
  32634. /**
  32635. * Render the scene
  32636. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32637. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  32638. */
  32639. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  32640. /**
  32641. * Freeze all materials
  32642. * A frozen material will not be updatable but should be faster to render
  32643. */
  32644. freezeMaterials(): void;
  32645. /**
  32646. * Unfreeze all materials
  32647. * A frozen material will not be updatable but should be faster to render
  32648. */
  32649. unfreezeMaterials(): void;
  32650. /**
  32651. * Releases all held ressources
  32652. */
  32653. dispose(): void;
  32654. /**
  32655. * Gets if the scene is already disposed
  32656. */
  32657. readonly isDisposed: boolean;
  32658. /**
  32659. * Call this function to reduce memory footprint of the scene.
  32660. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32661. */
  32662. clearCachedVertexData(): void;
  32663. /**
  32664. * This function will remove the local cached buffer data from texture.
  32665. * It will save memory but will prevent the texture from being rebuilt
  32666. */
  32667. cleanCachedTextureBuffer(): void;
  32668. /**
  32669. * Get the world extend vectors with an optional filter
  32670. *
  32671. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32672. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32673. */
  32674. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32675. min: Vector3;
  32676. max: Vector3;
  32677. };
  32678. /**
  32679. * Creates a ray that can be used to pick in the scene
  32680. * @param x defines the x coordinate of the origin (on-screen)
  32681. * @param y defines the y coordinate of the origin (on-screen)
  32682. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32683. * @param camera defines the camera to use for the picking
  32684. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32685. * @returns a Ray
  32686. */
  32687. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32688. /**
  32689. * Creates a ray that can be used to pick in the scene
  32690. * @param x defines the x coordinate of the origin (on-screen)
  32691. * @param y defines the y coordinate of the origin (on-screen)
  32692. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32693. * @param result defines the ray where to store the picking ray
  32694. * @param camera defines the camera to use for the picking
  32695. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32696. * @returns the current scene
  32697. */
  32698. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32699. /**
  32700. * Creates a ray that can be used to pick in the scene
  32701. * @param x defines the x coordinate of the origin (on-screen)
  32702. * @param y defines the y coordinate of the origin (on-screen)
  32703. * @param camera defines the camera to use for the picking
  32704. * @returns a Ray
  32705. */
  32706. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32707. /**
  32708. * Creates a ray that can be used to pick in the scene
  32709. * @param x defines the x coordinate of the origin (on-screen)
  32710. * @param y defines the y coordinate of the origin (on-screen)
  32711. * @param result defines the ray where to store the picking ray
  32712. * @param camera defines the camera to use for the picking
  32713. * @returns the current scene
  32714. */
  32715. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32716. /** Launch a ray to try to pick a mesh in the scene
  32717. * @param x position on screen
  32718. * @param y position on screen
  32719. * @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
  32720. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32721. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32722. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32723. * @returns a PickingInfo
  32724. */
  32725. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  32726. /** Use the given ray to pick a mesh in the scene
  32727. * @param ray The ray to use to pick meshes
  32728. * @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
  32729. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32730. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32731. * @returns a PickingInfo
  32732. */
  32733. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  32734. /**
  32735. * Launch a ray to try to pick a mesh in the scene
  32736. * @param x X position on screen
  32737. * @param y Y position on screen
  32738. * @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
  32739. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32740. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32741. * @returns an array of PickingInfo
  32742. */
  32743. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32744. /**
  32745. * Launch a ray to try to pick a mesh in the scene
  32746. * @param ray Ray to use
  32747. * @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
  32748. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32749. * @returns an array of PickingInfo
  32750. */
  32751. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32752. /**
  32753. * Force the value of meshUnderPointer
  32754. * @param mesh defines the mesh to use
  32755. */
  32756. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32757. /**
  32758. * Gets the mesh under the pointer
  32759. * @returns a Mesh or null if no mesh is under the pointer
  32760. */
  32761. getPointerOverMesh(): Nullable<AbstractMesh>;
  32762. /** @hidden */ rebuildGeometries(): void;
  32763. /** @hidden */ rebuildTextures(): void;
  32764. private _getByTags;
  32765. /**
  32766. * Get a list of meshes by tags
  32767. * @param tagsQuery defines the tags query to use
  32768. * @param forEach defines a predicate used to filter results
  32769. * @returns an array of Mesh
  32770. */
  32771. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32772. /**
  32773. * Get a list of cameras by tags
  32774. * @param tagsQuery defines the tags query to use
  32775. * @param forEach defines a predicate used to filter results
  32776. * @returns an array of Camera
  32777. */
  32778. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32779. /**
  32780. * Get a list of lights by tags
  32781. * @param tagsQuery defines the tags query to use
  32782. * @param forEach defines a predicate used to filter results
  32783. * @returns an array of Light
  32784. */
  32785. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32786. /**
  32787. * Get a list of materials by tags
  32788. * @param tagsQuery defines the tags query to use
  32789. * @param forEach defines a predicate used to filter results
  32790. * @returns an array of Material
  32791. */
  32792. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32793. /**
  32794. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32795. * This allowed control for front to back rendering or reversly depending of the special needs.
  32796. *
  32797. * @param renderingGroupId The rendering group id corresponding to its index
  32798. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32799. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32800. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32801. */
  32802. 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;
  32803. /**
  32804. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32805. *
  32806. * @param renderingGroupId The rendering group id corresponding to its index
  32807. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32808. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32809. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32810. */
  32811. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32812. /**
  32813. * Gets the current auto clear configuration for one rendering group of the rendering
  32814. * manager.
  32815. * @param index the rendering group index to get the information for
  32816. * @returns The auto clear setup for the requested rendering group
  32817. */
  32818. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32819. private _blockMaterialDirtyMechanism;
  32820. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32821. blockMaterialDirtyMechanism: boolean;
  32822. /**
  32823. * Will flag all materials as dirty to trigger new shader compilation
  32824. * @param flag defines the flag used to specify which material part must be marked as dirty
  32825. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32826. */
  32827. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32828. /** @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;
  32829. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32830. }
  32831. }
  32832. declare module BABYLON {
  32833. /**
  32834. * Set of assets to keep when moving a scene into an asset container.
  32835. */
  32836. export class KeepAssets extends AbstractScene {
  32837. }
  32838. /**
  32839. * Container with a set of assets that can be added or removed from a scene.
  32840. */
  32841. export class AssetContainer extends AbstractScene {
  32842. /**
  32843. * The scene the AssetContainer belongs to.
  32844. */
  32845. scene: Scene;
  32846. /**
  32847. * Instantiates an AssetContainer.
  32848. * @param scene The scene the AssetContainer belongs to.
  32849. */
  32850. constructor(scene: Scene);
  32851. /**
  32852. * Adds all the assets from the container to the scene.
  32853. */
  32854. addAllToScene(): void;
  32855. /**
  32856. * Removes all the assets in the container from the scene
  32857. */
  32858. removeAllFromScene(): void;
  32859. /**
  32860. * Disposes all the assets in the container
  32861. */
  32862. dispose(): void;
  32863. private _moveAssets;
  32864. /**
  32865. * Removes all the assets contained in the scene and adds them to the container.
  32866. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32867. */
  32868. moveAllFromScene(keepAssets?: KeepAssets): void;
  32869. /**
  32870. * 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.
  32871. * @returns the root mesh
  32872. */
  32873. createRootMesh(): Mesh;
  32874. }
  32875. }
  32876. declare module BABYLON {
  32877. /**
  32878. * Defines how the parser contract is defined.
  32879. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32880. */
  32881. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32882. /**
  32883. * Defines how the individual parser contract is defined.
  32884. * These parser can parse an individual asset
  32885. */
  32886. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32887. /**
  32888. * Base class of the scene acting as a container for the different elements composing a scene.
  32889. * This class is dynamically extended by the different components of the scene increasing
  32890. * flexibility and reducing coupling
  32891. */
  32892. export abstract class AbstractScene {
  32893. /**
  32894. * Stores the list of available parsers in the application.
  32895. */
  32896. private static _BabylonFileParsers;
  32897. /**
  32898. * Stores the list of available individual parsers in the application.
  32899. */
  32900. private static _IndividualBabylonFileParsers;
  32901. /**
  32902. * Adds a parser in the list of available ones
  32903. * @param name Defines the name of the parser
  32904. * @param parser Defines the parser to add
  32905. */
  32906. static AddParser(name: string, parser: BabylonFileParser): void;
  32907. /**
  32908. * Gets a general parser from the list of avaialble ones
  32909. * @param name Defines the name of the parser
  32910. * @returns the requested parser or null
  32911. */
  32912. static GetParser(name: string): Nullable<BabylonFileParser>;
  32913. /**
  32914. * Adds n individual parser in the list of available ones
  32915. * @param name Defines the name of the parser
  32916. * @param parser Defines the parser to add
  32917. */
  32918. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32919. /**
  32920. * Gets an individual parser from the list of avaialble ones
  32921. * @param name Defines the name of the parser
  32922. * @returns the requested parser or null
  32923. */
  32924. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32925. /**
  32926. * Parser json data and populate both a scene and its associated container object
  32927. * @param jsonData Defines the data to parse
  32928. * @param scene Defines the scene to parse the data for
  32929. * @param container Defines the container attached to the parsing sequence
  32930. * @param rootUrl Defines the root url of the data
  32931. */
  32932. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32933. /**
  32934. * Gets the list of root nodes (ie. nodes with no parent)
  32935. */
  32936. rootNodes: Node[];
  32937. /** All of the cameras added to this scene
  32938. * @see http://doc.babylonjs.com/babylon101/cameras
  32939. */
  32940. cameras: Camera[];
  32941. /**
  32942. * All of the lights added to this scene
  32943. * @see http://doc.babylonjs.com/babylon101/lights
  32944. */
  32945. lights: Light[];
  32946. /**
  32947. * All of the (abstract) meshes added to this scene
  32948. */
  32949. meshes: AbstractMesh[];
  32950. /**
  32951. * The list of skeletons added to the scene
  32952. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32953. */
  32954. skeletons: Skeleton[];
  32955. /**
  32956. * All of the particle systems added to this scene
  32957. * @see http://doc.babylonjs.com/babylon101/particles
  32958. */
  32959. particleSystems: IParticleSystem[];
  32960. /**
  32961. * Gets a list of Animations associated with the scene
  32962. */
  32963. animations: Animation[];
  32964. /**
  32965. * All of the animation groups added to this scene
  32966. * @see http://doc.babylonjs.com/how_to/group
  32967. */
  32968. animationGroups: AnimationGroup[];
  32969. /**
  32970. * All of the multi-materials added to this scene
  32971. * @see http://doc.babylonjs.com/how_to/multi_materials
  32972. */
  32973. multiMaterials: MultiMaterial[];
  32974. /**
  32975. * All of the materials added to this scene
  32976. * In the context of a Scene, it is not supposed to be modified manually.
  32977. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  32978. * Note also that the order of the Material wihin the array is not significant and might change.
  32979. * @see http://doc.babylonjs.com/babylon101/materials
  32980. */
  32981. materials: Material[];
  32982. /**
  32983. * The list of morph target managers added to the scene
  32984. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  32985. */
  32986. morphTargetManagers: MorphTargetManager[];
  32987. /**
  32988. * The list of geometries used in the scene.
  32989. */
  32990. geometries: Geometry[];
  32991. /**
  32992. * All of the tranform nodes added to this scene
  32993. * In the context of a Scene, it is not supposed to be modified manually.
  32994. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  32995. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  32996. * @see http://doc.babylonjs.com/how_to/transformnode
  32997. */
  32998. transformNodes: TransformNode[];
  32999. /**
  33000. * ActionManagers available on the scene.
  33001. */
  33002. actionManagers: AbstractActionManager[];
  33003. /**
  33004. * Textures to keep.
  33005. */
  33006. textures: BaseTexture[];
  33007. /**
  33008. * Environment texture for the scene
  33009. */
  33010. environmentTexture: Nullable<BaseTexture>;
  33011. }
  33012. }
  33013. declare module BABYLON {
  33014. /**
  33015. * Defines a sound that can be played in the application.
  33016. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33017. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33018. */
  33019. export class Sound {
  33020. /**
  33021. * The name of the sound in the scene.
  33022. */
  33023. name: string;
  33024. /**
  33025. * Does the sound autoplay once loaded.
  33026. */
  33027. autoplay: boolean;
  33028. /**
  33029. * Does the sound loop after it finishes playing once.
  33030. */
  33031. loop: boolean;
  33032. /**
  33033. * Does the sound use a custom attenuation curve to simulate the falloff
  33034. * happening when the source gets further away from the camera.
  33035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33036. */
  33037. useCustomAttenuation: boolean;
  33038. /**
  33039. * The sound track id this sound belongs to.
  33040. */
  33041. soundTrackId: number;
  33042. /**
  33043. * Is this sound currently played.
  33044. */
  33045. isPlaying: boolean;
  33046. /**
  33047. * Is this sound currently paused.
  33048. */
  33049. isPaused: boolean;
  33050. /**
  33051. * Does this sound enables spatial sound.
  33052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33053. */
  33054. spatialSound: boolean;
  33055. /**
  33056. * Define the reference distance the sound should be heard perfectly.
  33057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33058. */
  33059. refDistance: number;
  33060. /**
  33061. * Define the roll off factor of spatial sounds.
  33062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33063. */
  33064. rolloffFactor: number;
  33065. /**
  33066. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33068. */
  33069. maxDistance: number;
  33070. /**
  33071. * Define the distance attenuation model the sound will follow.
  33072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33073. */
  33074. distanceModel: string;
  33075. /**
  33076. * @hidden
  33077. * Back Compat
  33078. **/
  33079. onended: () => any;
  33080. /**
  33081. * Observable event when the current playing sound finishes.
  33082. */
  33083. onEndedObservable: Observable<Sound>;
  33084. private _panningModel;
  33085. private _playbackRate;
  33086. private _streaming;
  33087. private _startTime;
  33088. private _startOffset;
  33089. private _position;
  33090. /** @hidden */ positionInEmitterSpace: boolean;
  33091. private _localDirection;
  33092. private _volume;
  33093. private _isReadyToPlay;
  33094. private _isDirectional;
  33095. private _readyToPlayCallback;
  33096. private _audioBuffer;
  33097. private _soundSource;
  33098. private _streamingSource;
  33099. private _soundPanner;
  33100. private _soundGain;
  33101. private _inputAudioNode;
  33102. private _outputAudioNode;
  33103. private _coneInnerAngle;
  33104. private _coneOuterAngle;
  33105. private _coneOuterGain;
  33106. private _scene;
  33107. private _connectedTransformNode;
  33108. private _customAttenuationFunction;
  33109. private _registerFunc;
  33110. private _isOutputConnected;
  33111. private _htmlAudioElement;
  33112. private _urlType;
  33113. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33114. /**
  33115. * Create a sound and attach it to a scene
  33116. * @param name Name of your sound
  33117. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33118. * @param scene defines the scene the sound belongs to
  33119. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33120. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33121. */
  33122. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33123. /**
  33124. * Release the sound and its associated resources
  33125. */
  33126. dispose(): void;
  33127. /**
  33128. * Gets if the sounds is ready to be played or not.
  33129. * @returns true if ready, otherwise false
  33130. */
  33131. isReady(): boolean;
  33132. private _soundLoaded;
  33133. /**
  33134. * Sets the data of the sound from an audiobuffer
  33135. * @param audioBuffer The audioBuffer containing the data
  33136. */
  33137. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33138. /**
  33139. * Updates the current sounds options such as maxdistance, loop...
  33140. * @param options A JSON object containing values named as the object properties
  33141. */
  33142. updateOptions(options: any): void;
  33143. private _createSpatialParameters;
  33144. private _updateSpatialParameters;
  33145. /**
  33146. * Switch the panning model to HRTF:
  33147. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33149. */
  33150. switchPanningModelToHRTF(): void;
  33151. /**
  33152. * Switch the panning model to Equal Power:
  33153. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33154. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33155. */
  33156. switchPanningModelToEqualPower(): void;
  33157. private _switchPanningModel;
  33158. /**
  33159. * Connect this sound to a sound track audio node like gain...
  33160. * @param soundTrackAudioNode the sound track audio node to connect to
  33161. */
  33162. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33163. /**
  33164. * Transform this sound into a directional source
  33165. * @param coneInnerAngle Size of the inner cone in degree
  33166. * @param coneOuterAngle Size of the outer cone in degree
  33167. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33168. */
  33169. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33170. /**
  33171. * Gets or sets the inner angle for the directional cone.
  33172. */
  33173. /**
  33174. * Gets or sets the inner angle for the directional cone.
  33175. */
  33176. directionalConeInnerAngle: number;
  33177. /**
  33178. * Gets or sets the outer angle for the directional cone.
  33179. */
  33180. /**
  33181. * Gets or sets the outer angle for the directional cone.
  33182. */
  33183. directionalConeOuterAngle: number;
  33184. /**
  33185. * Sets the position of the emitter if spatial sound is enabled
  33186. * @param newPosition Defines the new posisiton
  33187. */
  33188. setPosition(newPosition: Vector3): void;
  33189. /**
  33190. * Sets the local direction of the emitter if spatial sound is enabled
  33191. * @param newLocalDirection Defines the new local direction
  33192. */
  33193. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33194. private _updateDirection;
  33195. /** @hidden */
  33196. updateDistanceFromListener(): void;
  33197. /**
  33198. * Sets a new custom attenuation function for the sound.
  33199. * @param callback Defines the function used for the attenuation
  33200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33201. */
  33202. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33203. /**
  33204. * Play the sound
  33205. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33206. * @param offset (optional) Start the sound setting it at a specific time
  33207. */
  33208. play(time?: number, offset?: number): void;
  33209. private _onended;
  33210. /**
  33211. * Stop the sound
  33212. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33213. */
  33214. stop(time?: number): void;
  33215. /**
  33216. * Put the sound in pause
  33217. */
  33218. pause(): void;
  33219. /**
  33220. * Sets a dedicated volume for this sounds
  33221. * @param newVolume Define the new volume of the sound
  33222. * @param time Define in how long the sound should be at this value
  33223. */
  33224. setVolume(newVolume: number, time?: number): void;
  33225. /**
  33226. * Set the sound play back rate
  33227. * @param newPlaybackRate Define the playback rate the sound should be played at
  33228. */
  33229. setPlaybackRate(newPlaybackRate: number): void;
  33230. /**
  33231. * Gets the volume of the sound.
  33232. * @returns the volume of the sound
  33233. */
  33234. getVolume(): number;
  33235. /**
  33236. * Attach the sound to a dedicated mesh
  33237. * @param transformNode The transform node to connect the sound with
  33238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33239. */
  33240. attachToMesh(transformNode: TransformNode): void;
  33241. /**
  33242. * Detach the sound from the previously attached mesh
  33243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33244. */
  33245. detachFromMesh(): void;
  33246. private _onRegisterAfterWorldMatrixUpdate;
  33247. /**
  33248. * Clone the current sound in the scene.
  33249. * @returns the new sound clone
  33250. */
  33251. clone(): Nullable<Sound>;
  33252. /**
  33253. * Gets the current underlying audio buffer containing the data
  33254. * @returns the audio buffer
  33255. */
  33256. getAudioBuffer(): Nullable<AudioBuffer>;
  33257. /**
  33258. * Serializes the Sound in a JSON representation
  33259. * @returns the JSON representation of the sound
  33260. */
  33261. serialize(): any;
  33262. /**
  33263. * Parse a JSON representation of a sound to innstantiate in a given scene
  33264. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33265. * @param scene Define the scene the new parsed sound should be created in
  33266. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33267. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33268. * @returns the newly parsed sound
  33269. */
  33270. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33271. }
  33272. }
  33273. declare module BABYLON {
  33274. /**
  33275. * This defines an action helpful to play a defined sound on a triggered action.
  33276. */
  33277. export class PlaySoundAction extends Action {
  33278. private _sound;
  33279. /**
  33280. * Instantiate the action
  33281. * @param triggerOptions defines the trigger options
  33282. * @param sound defines the sound to play
  33283. * @param condition defines the trigger related conditions
  33284. */
  33285. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33286. /** @hidden */ prepare(): void;
  33287. /**
  33288. * Execute the action and play the sound.
  33289. */
  33290. execute(): void;
  33291. /**
  33292. * Serializes the actions and its related information.
  33293. * @param parent defines the object to serialize in
  33294. * @returns the serialized object
  33295. */
  33296. serialize(parent: any): any;
  33297. }
  33298. /**
  33299. * This defines an action helpful to stop a defined sound on a triggered action.
  33300. */
  33301. export class StopSoundAction extends Action {
  33302. private _sound;
  33303. /**
  33304. * Instantiate the action
  33305. * @param triggerOptions defines the trigger options
  33306. * @param sound defines the sound to stop
  33307. * @param condition defines the trigger related conditions
  33308. */
  33309. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33310. /** @hidden */ prepare(): void;
  33311. /**
  33312. * Execute the action and stop the sound.
  33313. */
  33314. execute(): void;
  33315. /**
  33316. * Serializes the actions and its related information.
  33317. * @param parent defines the object to serialize in
  33318. * @returns the serialized object
  33319. */
  33320. serialize(parent: any): any;
  33321. }
  33322. }
  33323. declare module BABYLON {
  33324. /**
  33325. * This defines an action responsible to change the value of a property
  33326. * by interpolating between its current value and the newly set one once triggered.
  33327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33328. */
  33329. export class InterpolateValueAction extends Action {
  33330. /**
  33331. * Defines the path of the property where the value should be interpolated
  33332. */
  33333. propertyPath: string;
  33334. /**
  33335. * Defines the target value at the end of the interpolation.
  33336. */
  33337. value: any;
  33338. /**
  33339. * Defines the time it will take for the property to interpolate to the value.
  33340. */
  33341. duration: number;
  33342. /**
  33343. * Defines if the other scene animations should be stopped when the action has been triggered
  33344. */
  33345. stopOtherAnimations?: boolean;
  33346. /**
  33347. * Defines a callback raised once the interpolation animation has been done.
  33348. */
  33349. onInterpolationDone?: () => void;
  33350. /**
  33351. * Observable triggered once the interpolation animation has been done.
  33352. */
  33353. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33354. private _target;
  33355. private _effectiveTarget;
  33356. private _property;
  33357. /**
  33358. * Instantiate the action
  33359. * @param triggerOptions defines the trigger options
  33360. * @param target defines the object containing the value to interpolate
  33361. * @param propertyPath defines the path to the property in the target object
  33362. * @param value defines the target value at the end of the interpolation
  33363. * @param duration deines the time it will take for the property to interpolate to the value.
  33364. * @param condition defines the trigger related conditions
  33365. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33366. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33367. */
  33368. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33369. /** @hidden */ prepare(): void;
  33370. /**
  33371. * Execute the action starts the value interpolation.
  33372. */
  33373. execute(): void;
  33374. /**
  33375. * Serializes the actions and its related information.
  33376. * @param parent defines the object to serialize in
  33377. * @returns the serialized object
  33378. */
  33379. serialize(parent: any): any;
  33380. }
  33381. }
  33382. declare module BABYLON {
  33383. /**
  33384. * Options allowed during the creation of a sound track.
  33385. */
  33386. export interface ISoundTrackOptions {
  33387. /**
  33388. * The volume the sound track should take during creation
  33389. */
  33390. volume?: number;
  33391. /**
  33392. * Define if the sound track is the main sound track of the scene
  33393. */
  33394. mainTrack?: boolean;
  33395. }
  33396. /**
  33397. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33398. * It will be also used in a future release to apply effects on a specific track.
  33399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33400. */
  33401. export class SoundTrack {
  33402. /**
  33403. * The unique identifier of the sound track in the scene.
  33404. */
  33405. id: number;
  33406. /**
  33407. * The list of sounds included in the sound track.
  33408. */
  33409. soundCollection: Array<Sound>;
  33410. private _outputAudioNode;
  33411. private _scene;
  33412. private _isMainTrack;
  33413. private _connectedAnalyser;
  33414. private _options;
  33415. private _isInitialized;
  33416. /**
  33417. * Creates a new sound track.
  33418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33419. * @param scene Define the scene the sound track belongs to
  33420. * @param options
  33421. */
  33422. constructor(scene: Scene, options?: ISoundTrackOptions);
  33423. private _initializeSoundTrackAudioGraph;
  33424. /**
  33425. * Release the sound track and its associated resources
  33426. */
  33427. dispose(): void;
  33428. /**
  33429. * Adds a sound to this sound track
  33430. * @param sound define the cound to add
  33431. * @ignoreNaming
  33432. */
  33433. AddSound(sound: Sound): void;
  33434. /**
  33435. * Removes a sound to this sound track
  33436. * @param sound define the cound to remove
  33437. * @ignoreNaming
  33438. */
  33439. RemoveSound(sound: Sound): void;
  33440. /**
  33441. * Set a global volume for the full sound track.
  33442. * @param newVolume Define the new volume of the sound track
  33443. */
  33444. setVolume(newVolume: number): void;
  33445. /**
  33446. * Switch the panning model to HRTF:
  33447. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33449. */
  33450. switchPanningModelToHRTF(): void;
  33451. /**
  33452. * Switch the panning model to Equal Power:
  33453. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33455. */
  33456. switchPanningModelToEqualPower(): void;
  33457. /**
  33458. * Connect the sound track to an audio analyser allowing some amazing
  33459. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33461. * @param analyser The analyser to connect to the engine
  33462. */
  33463. connectToAnalyser(analyser: Analyser): void;
  33464. }
  33465. }
  33466. declare module BABYLON {
  33467. interface AbstractScene {
  33468. /**
  33469. * The list of sounds used in the scene.
  33470. */
  33471. sounds: Nullable<Array<Sound>>;
  33472. }
  33473. interface Scene {
  33474. /**
  33475. * @hidden
  33476. * Backing field
  33477. */ mainSoundTrack: SoundTrack;
  33478. /**
  33479. * The main sound track played by the scene.
  33480. * It cotains your primary collection of sounds.
  33481. */
  33482. mainSoundTrack: SoundTrack;
  33483. /**
  33484. * The list of sound tracks added to the scene
  33485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33486. */
  33487. soundTracks: Nullable<Array<SoundTrack>>;
  33488. /**
  33489. * Gets a sound using a given name
  33490. * @param name defines the name to search for
  33491. * @return the found sound or null if not found at all.
  33492. */
  33493. getSoundByName(name: string): Nullable<Sound>;
  33494. /**
  33495. * Gets or sets if audio support is enabled
  33496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33497. */
  33498. audioEnabled: boolean;
  33499. /**
  33500. * Gets or sets if audio will be output to headphones
  33501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33502. */
  33503. headphone: boolean;
  33504. }
  33505. /**
  33506. * Defines the sound scene component responsible to manage any sounds
  33507. * in a given scene.
  33508. */
  33509. export class AudioSceneComponent implements ISceneSerializableComponent {
  33510. /**
  33511. * The component name helpfull to identify the component in the list of scene components.
  33512. */
  33513. readonly name: string;
  33514. /**
  33515. * The scene the component belongs to.
  33516. */
  33517. scene: Scene;
  33518. private _audioEnabled;
  33519. /**
  33520. * Gets whether audio is enabled or not.
  33521. * Please use related enable/disable method to switch state.
  33522. */
  33523. readonly audioEnabled: boolean;
  33524. private _headphone;
  33525. /**
  33526. * Gets whether audio is outputing to headphone or not.
  33527. * Please use the according Switch methods to change output.
  33528. */
  33529. readonly headphone: boolean;
  33530. /**
  33531. * Creates a new instance of the component for the given scene
  33532. * @param scene Defines the scene to register the component in
  33533. */
  33534. constructor(scene: Scene);
  33535. /**
  33536. * Registers the component in a given scene
  33537. */
  33538. register(): void;
  33539. /**
  33540. * Rebuilds the elements related to this component in case of
  33541. * context lost for instance.
  33542. */
  33543. rebuild(): void;
  33544. /**
  33545. * Serializes the component data to the specified json object
  33546. * @param serializationObject The object to serialize to
  33547. */
  33548. serialize(serializationObject: any): void;
  33549. /**
  33550. * Adds all the element from the container to the scene
  33551. * @param container the container holding the elements
  33552. */
  33553. addFromContainer(container: AbstractScene): void;
  33554. /**
  33555. * Removes all the elements in the container from the scene
  33556. * @param container contains the elements to remove
  33557. * @param dispose if the removed element should be disposed (default: false)
  33558. */
  33559. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  33560. /**
  33561. * Disposes the component and the associated ressources.
  33562. */
  33563. dispose(): void;
  33564. /**
  33565. * Disables audio in the associated scene.
  33566. */
  33567. disableAudio(): void;
  33568. /**
  33569. * Enables audio in the associated scene.
  33570. */
  33571. enableAudio(): void;
  33572. /**
  33573. * Switch audio to headphone output.
  33574. */
  33575. switchAudioModeForHeadphones(): void;
  33576. /**
  33577. * Switch audio to normal speakers.
  33578. */
  33579. switchAudioModeForNormalSpeakers(): void;
  33580. private _afterRender;
  33581. }
  33582. }
  33583. declare module BABYLON {
  33584. /**
  33585. * Wraps one or more Sound objects and selects one with random weight for playback.
  33586. */
  33587. export class WeightedSound {
  33588. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33589. loop: boolean;
  33590. private _coneInnerAngle;
  33591. private _coneOuterAngle;
  33592. private _volume;
  33593. /** A Sound is currently playing. */
  33594. isPlaying: boolean;
  33595. /** A Sound is currently paused. */
  33596. isPaused: boolean;
  33597. private _sounds;
  33598. private _weights;
  33599. private _currentIndex?;
  33600. /**
  33601. * Creates a new WeightedSound from the list of sounds given.
  33602. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33603. * @param sounds Array of Sounds that will be selected from.
  33604. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33605. */
  33606. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33607. /**
  33608. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33609. */
  33610. /**
  33611. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33612. */
  33613. directionalConeInnerAngle: number;
  33614. /**
  33615. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33616. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33617. */
  33618. /**
  33619. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33620. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33621. */
  33622. directionalConeOuterAngle: number;
  33623. /**
  33624. * Playback volume.
  33625. */
  33626. /**
  33627. * Playback volume.
  33628. */
  33629. volume: number;
  33630. private _onended;
  33631. /**
  33632. * Suspend playback
  33633. */
  33634. pause(): void;
  33635. /**
  33636. * Stop playback
  33637. */
  33638. stop(): void;
  33639. /**
  33640. * Start playback.
  33641. * @param startOffset Position the clip head at a specific time in seconds.
  33642. */
  33643. play(startOffset?: number): void;
  33644. }
  33645. }
  33646. declare module BABYLON {
  33647. /**
  33648. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33649. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33650. */
  33651. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33652. /**
  33653. * Gets the name of the behavior.
  33654. */
  33655. readonly name: string;
  33656. /**
  33657. * The easing function used by animations
  33658. */
  33659. static EasingFunction: BackEase;
  33660. /**
  33661. * The easing mode used by animations
  33662. */
  33663. static EasingMode: number;
  33664. /**
  33665. * The duration of the animation, in milliseconds
  33666. */
  33667. transitionDuration: number;
  33668. /**
  33669. * Length of the distance animated by the transition when lower radius is reached
  33670. */
  33671. lowerRadiusTransitionRange: number;
  33672. /**
  33673. * Length of the distance animated by the transition when upper radius is reached
  33674. */
  33675. upperRadiusTransitionRange: number;
  33676. private _autoTransitionRange;
  33677. /**
  33678. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33679. */
  33680. /**
  33681. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33682. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33683. */
  33684. autoTransitionRange: boolean;
  33685. private _attachedCamera;
  33686. private _onAfterCheckInputsObserver;
  33687. private _onMeshTargetChangedObserver;
  33688. /**
  33689. * Initializes the behavior.
  33690. */
  33691. init(): void;
  33692. /**
  33693. * Attaches the behavior to its arc rotate camera.
  33694. * @param camera Defines the camera to attach the behavior to
  33695. */
  33696. attach(camera: ArcRotateCamera): void;
  33697. /**
  33698. * Detaches the behavior from its current arc rotate camera.
  33699. */
  33700. detach(): void;
  33701. private _radiusIsAnimating;
  33702. private _radiusBounceTransition;
  33703. private _animatables;
  33704. private _cachedWheelPrecision;
  33705. /**
  33706. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33707. * @param radiusLimit The limit to check against.
  33708. * @return Bool to indicate if at limit.
  33709. */
  33710. private _isRadiusAtLimit;
  33711. /**
  33712. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33713. * @param radiusDelta The delta by which to animate to. Can be negative.
  33714. */
  33715. private _applyBoundRadiusAnimation;
  33716. /**
  33717. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33718. */
  33719. protected _clearAnimationLocks(): void;
  33720. /**
  33721. * Stops and removes all animations that have been applied to the camera
  33722. */
  33723. stopAllAnimations(): void;
  33724. }
  33725. }
  33726. declare module BABYLON {
  33727. /**
  33728. * 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.
  33729. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33730. */
  33731. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33732. /**
  33733. * Gets the name of the behavior.
  33734. */
  33735. readonly name: string;
  33736. private _mode;
  33737. private _radiusScale;
  33738. private _positionScale;
  33739. private _defaultElevation;
  33740. private _elevationReturnTime;
  33741. private _elevationReturnWaitTime;
  33742. private _zoomStopsAnimation;
  33743. private _framingTime;
  33744. /**
  33745. * The easing function used by animations
  33746. */
  33747. static EasingFunction: ExponentialEase;
  33748. /**
  33749. * The easing mode used by animations
  33750. */
  33751. static EasingMode: number;
  33752. /**
  33753. * Sets the current mode used by the behavior
  33754. */
  33755. /**
  33756. * Gets current mode used by the behavior.
  33757. */
  33758. mode: number;
  33759. /**
  33760. * Sets the scale applied to the radius (1 by default)
  33761. */
  33762. /**
  33763. * Gets the scale applied to the radius
  33764. */
  33765. radiusScale: number;
  33766. /**
  33767. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33768. */
  33769. /**
  33770. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33771. */
  33772. positionScale: number;
  33773. /**
  33774. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33775. * behaviour is triggered, in radians.
  33776. */
  33777. /**
  33778. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33779. * behaviour is triggered, in radians.
  33780. */
  33781. defaultElevation: number;
  33782. /**
  33783. * Sets the time (in milliseconds) taken to return to the default beta position.
  33784. * Negative value indicates camera should not return to default.
  33785. */
  33786. /**
  33787. * Gets the time (in milliseconds) taken to return to the default beta position.
  33788. * Negative value indicates camera should not return to default.
  33789. */
  33790. elevationReturnTime: number;
  33791. /**
  33792. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33793. */
  33794. /**
  33795. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33796. */
  33797. elevationReturnWaitTime: number;
  33798. /**
  33799. * Sets the flag that indicates if user zooming should stop animation.
  33800. */
  33801. /**
  33802. * Gets the flag that indicates if user zooming should stop animation.
  33803. */
  33804. zoomStopsAnimation: boolean;
  33805. /**
  33806. * Sets the transition time when framing the mesh, in milliseconds
  33807. */
  33808. /**
  33809. * Gets the transition time when framing the mesh, in milliseconds
  33810. */
  33811. framingTime: number;
  33812. /**
  33813. * Define if the behavior should automatically change the configured
  33814. * camera limits and sensibilities.
  33815. */
  33816. autoCorrectCameraLimitsAndSensibility: boolean;
  33817. private _onPrePointerObservableObserver;
  33818. private _onAfterCheckInputsObserver;
  33819. private _onMeshTargetChangedObserver;
  33820. private _attachedCamera;
  33821. private _isPointerDown;
  33822. private _lastInteractionTime;
  33823. /**
  33824. * Initializes the behavior.
  33825. */
  33826. init(): void;
  33827. /**
  33828. * Attaches the behavior to its arc rotate camera.
  33829. * @param camera Defines the camera to attach the behavior to
  33830. */
  33831. attach(camera: ArcRotateCamera): void;
  33832. /**
  33833. * Detaches the behavior from its current arc rotate camera.
  33834. */
  33835. detach(): void;
  33836. private _animatables;
  33837. private _betaIsAnimating;
  33838. private _betaTransition;
  33839. private _radiusTransition;
  33840. private _vectorTransition;
  33841. /**
  33842. * Targets the given mesh and updates zoom level accordingly.
  33843. * @param mesh The mesh to target.
  33844. * @param radius Optional. If a cached radius position already exists, overrides default.
  33845. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33846. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33847. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33848. */
  33849. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33850. /**
  33851. * Targets the given mesh with its children and updates zoom level accordingly.
  33852. * @param mesh The mesh to target.
  33853. * @param radius Optional. If a cached radius position already exists, overrides default.
  33854. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33855. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33856. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33857. */
  33858. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33859. /**
  33860. * Targets the given meshes with their children and updates zoom level accordingly.
  33861. * @param meshes The mesh to target.
  33862. * @param radius Optional. If a cached radius position already exists, overrides default.
  33863. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33864. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33865. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33866. */
  33867. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33868. /**
  33869. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33870. * @param minimumWorld Determines the smaller position of the bounding box extend
  33871. * @param maximumWorld Determines the bigger position of the bounding box extend
  33872. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33873. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33874. */
  33875. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33876. /**
  33877. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33878. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33879. * frustum width.
  33880. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33881. * to fully enclose the mesh in the viewing frustum.
  33882. */
  33883. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33884. /**
  33885. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33886. * is automatically returned to its default position (expected to be above ground plane).
  33887. */
  33888. private _maintainCameraAboveGround;
  33889. /**
  33890. * Returns the frustum slope based on the canvas ratio and camera FOV
  33891. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33892. */
  33893. private _getFrustumSlope;
  33894. /**
  33895. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33896. */
  33897. private _clearAnimationLocks;
  33898. /**
  33899. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33900. */
  33901. private _applyUserInteraction;
  33902. /**
  33903. * Stops and removes all animations that have been applied to the camera
  33904. */
  33905. stopAllAnimations(): void;
  33906. /**
  33907. * Gets a value indicating if the user is moving the camera
  33908. */
  33909. readonly isUserIsMoving: boolean;
  33910. /**
  33911. * The camera can move all the way towards the mesh.
  33912. */
  33913. static IgnoreBoundsSizeMode: number;
  33914. /**
  33915. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33916. */
  33917. static FitFrustumSidesMode: number;
  33918. }
  33919. }
  33920. declare module BABYLON {
  33921. /**
  33922. * Base class for Camera Pointer Inputs.
  33923. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  33924. * for example usage.
  33925. */
  33926. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  33927. /**
  33928. * Defines the camera the input is attached to.
  33929. */
  33930. abstract camera: Camera;
  33931. /**
  33932. * Whether keyboard modifier keys are pressed at time of last mouse event.
  33933. */
  33934. protected _altKey: boolean;
  33935. protected _ctrlKey: boolean;
  33936. protected _metaKey: boolean;
  33937. protected _shiftKey: boolean;
  33938. /**
  33939. * Which mouse buttons were pressed at time of last mouse event.
  33940. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  33941. */
  33942. protected _buttonsPressed: number;
  33943. /**
  33944. * Defines the buttons associated with the input to handle camera move.
  33945. */
  33946. buttons: number[];
  33947. /**
  33948. * Attach the input controls to a specific dom element to get the input from.
  33949. * @param element Defines the element the controls should be listened from
  33950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33951. */
  33952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33953. /**
  33954. * Detach the current controls from the specified dom element.
  33955. * @param element Defines the element to stop listening the inputs from
  33956. */
  33957. detachControl(element: Nullable<HTMLElement>): void;
  33958. /**
  33959. * Gets the class name of the current input.
  33960. * @returns the class name
  33961. */
  33962. getClassName(): string;
  33963. /**
  33964. * Get the friendly name associated with the input class.
  33965. * @returns the input friendly name
  33966. */
  33967. getSimpleName(): string;
  33968. /**
  33969. * Called on pointer POINTERDOUBLETAP event.
  33970. * Override this method to provide functionality on POINTERDOUBLETAP event.
  33971. */
  33972. protected onDoubleTap(type: string): void;
  33973. /**
  33974. * Called on pointer POINTERMOVE event if only a single touch is active.
  33975. * Override this method to provide functionality.
  33976. */
  33977. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  33978. /**
  33979. * Called on pointer POINTERMOVE event if multiple touches are active.
  33980. * Override this method to provide functionality.
  33981. */
  33982. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  33983. /**
  33984. * Called on JS contextmenu event.
  33985. * Override this method to provide functionality.
  33986. */
  33987. protected onContextMenu(evt: PointerEvent): void;
  33988. /**
  33989. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  33990. * press.
  33991. * Override this method to provide functionality.
  33992. */
  33993. protected onButtonDown(evt: PointerEvent): void;
  33994. /**
  33995. * Called each time a new POINTERUP event occurs. Ie, for each button
  33996. * release.
  33997. * Override this method to provide functionality.
  33998. */
  33999. protected onButtonUp(evt: PointerEvent): void;
  34000. /**
  34001. * Called when window becomes inactive.
  34002. * Override this method to provide functionality.
  34003. */
  34004. protected onLostFocus(): void;
  34005. private _pointerInput;
  34006. private _observer;
  34007. private _onLostFocus;
  34008. private pointA;
  34009. private pointB;
  34010. }
  34011. }
  34012. declare module BABYLON {
  34013. /**
  34014. * Manage the pointers inputs to control an arc rotate camera.
  34015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34016. */
  34017. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34018. /**
  34019. * Defines the camera the input is attached to.
  34020. */
  34021. camera: ArcRotateCamera;
  34022. /**
  34023. * Gets the class name of the current input.
  34024. * @returns the class name
  34025. */
  34026. getClassName(): string;
  34027. /**
  34028. * Defines the buttons associated with the input to handle camera move.
  34029. */
  34030. buttons: number[];
  34031. /**
  34032. * Defines the pointer angular sensibility along the X axis or how fast is
  34033. * the camera rotating.
  34034. */
  34035. angularSensibilityX: number;
  34036. /**
  34037. * Defines the pointer angular sensibility along the Y axis or how fast is
  34038. * the camera rotating.
  34039. */
  34040. angularSensibilityY: number;
  34041. /**
  34042. * Defines the pointer pinch precision or how fast is the camera zooming.
  34043. */
  34044. pinchPrecision: number;
  34045. /**
  34046. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34047. * from 0.
  34048. * It defines the percentage of current camera.radius to use as delta when
  34049. * pinch zoom is used.
  34050. */
  34051. pinchDeltaPercentage: number;
  34052. /**
  34053. * Defines the pointer panning sensibility or how fast is the camera moving.
  34054. */
  34055. panningSensibility: number;
  34056. /**
  34057. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34058. */
  34059. multiTouchPanning: boolean;
  34060. /**
  34061. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34062. * zoom (pinch) through multitouch.
  34063. */
  34064. multiTouchPanAndZoom: boolean;
  34065. /**
  34066. * Revers pinch action direction.
  34067. */
  34068. pinchInwards: boolean;
  34069. private _isPanClick;
  34070. private _twoFingerActivityCount;
  34071. private _isPinching;
  34072. /**
  34073. * Called on pointer POINTERMOVE event if only a single touch is active.
  34074. */
  34075. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34076. /**
  34077. * Called on pointer POINTERDOUBLETAP event.
  34078. */
  34079. protected onDoubleTap(type: string): void;
  34080. /**
  34081. * Called on pointer POINTERMOVE event if multiple touches are active.
  34082. */
  34083. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34084. /**
  34085. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34086. * press.
  34087. */
  34088. protected onButtonDown(evt: PointerEvent): void;
  34089. /**
  34090. * Called each time a new POINTERUP event occurs. Ie, for each button
  34091. * release.
  34092. */
  34093. protected onButtonUp(evt: PointerEvent): void;
  34094. /**
  34095. * Called when window becomes inactive.
  34096. */
  34097. protected onLostFocus(): void;
  34098. }
  34099. }
  34100. declare module BABYLON {
  34101. /**
  34102. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34104. */
  34105. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34106. /**
  34107. * Defines the camera the input is attached to.
  34108. */
  34109. camera: ArcRotateCamera;
  34110. /**
  34111. * Defines the list of key codes associated with the up action (increase alpha)
  34112. */
  34113. keysUp: number[];
  34114. /**
  34115. * Defines the list of key codes associated with the down action (decrease alpha)
  34116. */
  34117. keysDown: number[];
  34118. /**
  34119. * Defines the list of key codes associated with the left action (increase beta)
  34120. */
  34121. keysLeft: number[];
  34122. /**
  34123. * Defines the list of key codes associated with the right action (decrease beta)
  34124. */
  34125. keysRight: number[];
  34126. /**
  34127. * Defines the list of key codes associated with the reset action.
  34128. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34129. */
  34130. keysReset: number[];
  34131. /**
  34132. * Defines the panning sensibility of the inputs.
  34133. * (How fast is the camera paning)
  34134. */
  34135. panningSensibility: number;
  34136. /**
  34137. * Defines the zooming sensibility of the inputs.
  34138. * (How fast is the camera zooming)
  34139. */
  34140. zoomingSensibility: number;
  34141. /**
  34142. * Defines wether maintaining the alt key down switch the movement mode from
  34143. * orientation to zoom.
  34144. */
  34145. useAltToZoom: boolean;
  34146. /**
  34147. * Rotation speed of the camera
  34148. */
  34149. angularSpeed: number;
  34150. private _keys;
  34151. private _ctrlPressed;
  34152. private _altPressed;
  34153. private _onCanvasBlurObserver;
  34154. private _onKeyboardObserver;
  34155. private _engine;
  34156. private _scene;
  34157. /**
  34158. * Attach the input controls to a specific dom element to get the input from.
  34159. * @param element Defines the element the controls should be listened from
  34160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34161. */
  34162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34163. /**
  34164. * Detach the current controls from the specified dom element.
  34165. * @param element Defines the element to stop listening the inputs from
  34166. */
  34167. detachControl(element: Nullable<HTMLElement>): void;
  34168. /**
  34169. * Update the current camera state depending on the inputs that have been used this frame.
  34170. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34171. */
  34172. checkInputs(): void;
  34173. /**
  34174. * Gets the class name of the current intput.
  34175. * @returns the class name
  34176. */
  34177. getClassName(): string;
  34178. /**
  34179. * Get the friendly name associated with the input class.
  34180. * @returns the input friendly name
  34181. */
  34182. getSimpleName(): string;
  34183. }
  34184. }
  34185. declare module BABYLON {
  34186. /**
  34187. * Manage the mouse wheel inputs to control an arc rotate camera.
  34188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34189. */
  34190. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34191. /**
  34192. * Defines the camera the input is attached to.
  34193. */
  34194. camera: ArcRotateCamera;
  34195. /**
  34196. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34197. */
  34198. wheelPrecision: number;
  34199. /**
  34200. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34201. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34202. */
  34203. wheelDeltaPercentage: number;
  34204. private _wheel;
  34205. private _observer;
  34206. /**
  34207. * Attach the input controls to a specific dom element to get the input from.
  34208. * @param element Defines the element the controls should be listened from
  34209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34210. */
  34211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34212. /**
  34213. * Detach the current controls from the specified dom element.
  34214. * @param element Defines the element to stop listening the inputs from
  34215. */
  34216. detachControl(element: Nullable<HTMLElement>): void;
  34217. /**
  34218. * Gets the class name of the current intput.
  34219. * @returns the class name
  34220. */
  34221. getClassName(): string;
  34222. /**
  34223. * Get the friendly name associated with the input class.
  34224. * @returns the input friendly name
  34225. */
  34226. getSimpleName(): string;
  34227. }
  34228. }
  34229. declare module BABYLON {
  34230. /**
  34231. * Default Inputs manager for the ArcRotateCamera.
  34232. * It groups all the default supported inputs for ease of use.
  34233. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34234. */
  34235. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34236. /**
  34237. * Instantiates a new ArcRotateCameraInputsManager.
  34238. * @param camera Defines the camera the inputs belong to
  34239. */
  34240. constructor(camera: ArcRotateCamera);
  34241. /**
  34242. * Add mouse wheel input support to the input manager.
  34243. * @returns the current input manager
  34244. */
  34245. addMouseWheel(): ArcRotateCameraInputsManager;
  34246. /**
  34247. * Add pointers input support to the input manager.
  34248. * @returns the current input manager
  34249. */
  34250. addPointers(): ArcRotateCameraInputsManager;
  34251. /**
  34252. * Add keyboard input support to the input manager.
  34253. * @returns the current input manager
  34254. */
  34255. addKeyboard(): ArcRotateCameraInputsManager;
  34256. }
  34257. }
  34258. declare module BABYLON {
  34259. /**
  34260. * This represents an orbital type of camera.
  34261. *
  34262. * 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.
  34263. * 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.
  34264. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34265. */
  34266. export class ArcRotateCamera extends TargetCamera {
  34267. /**
  34268. * Defines the rotation angle of the camera along the longitudinal axis.
  34269. */
  34270. alpha: number;
  34271. /**
  34272. * Defines the rotation angle of the camera along the latitudinal axis.
  34273. */
  34274. beta: number;
  34275. /**
  34276. * Defines the radius of the camera from it s target point.
  34277. */
  34278. radius: number;
  34279. protected _target: Vector3;
  34280. protected _targetHost: Nullable<AbstractMesh>;
  34281. /**
  34282. * Defines the target point of the camera.
  34283. * The camera looks towards it form the radius distance.
  34284. */
  34285. target: Vector3;
  34286. /**
  34287. * Define the current local position of the camera in the scene
  34288. */
  34289. position: Vector3;
  34290. protected _upVector: Vector3;
  34291. protected _upToYMatrix: Matrix;
  34292. protected _YToUpMatrix: Matrix;
  34293. /**
  34294. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34295. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34296. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34297. */
  34298. upVector: Vector3;
  34299. /**
  34300. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34301. */
  34302. setMatUp(): void;
  34303. /**
  34304. * Current inertia value on the longitudinal axis.
  34305. * The bigger this number the longer it will take for the camera to stop.
  34306. */
  34307. inertialAlphaOffset: number;
  34308. /**
  34309. * Current inertia value on the latitudinal axis.
  34310. * The bigger this number the longer it will take for the camera to stop.
  34311. */
  34312. inertialBetaOffset: number;
  34313. /**
  34314. * Current inertia value on the radius axis.
  34315. * The bigger this number the longer it will take for the camera to stop.
  34316. */
  34317. inertialRadiusOffset: number;
  34318. /**
  34319. * Minimum allowed angle on the longitudinal axis.
  34320. * This can help limiting how the Camera is able to move in the scene.
  34321. */
  34322. lowerAlphaLimit: Nullable<number>;
  34323. /**
  34324. * Maximum allowed angle on the longitudinal axis.
  34325. * This can help limiting how the Camera is able to move in the scene.
  34326. */
  34327. upperAlphaLimit: Nullable<number>;
  34328. /**
  34329. * Minimum allowed angle on the latitudinal axis.
  34330. * This can help limiting how the Camera is able to move in the scene.
  34331. */
  34332. lowerBetaLimit: number;
  34333. /**
  34334. * Maximum allowed angle on the latitudinal axis.
  34335. * This can help limiting how the Camera is able to move in the scene.
  34336. */
  34337. upperBetaLimit: number;
  34338. /**
  34339. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34340. * This can help limiting how the Camera is able to move in the scene.
  34341. */
  34342. lowerRadiusLimit: Nullable<number>;
  34343. /**
  34344. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34345. * This can help limiting how the Camera is able to move in the scene.
  34346. */
  34347. upperRadiusLimit: Nullable<number>;
  34348. /**
  34349. * Defines the current inertia value used during panning of the camera along the X axis.
  34350. */
  34351. inertialPanningX: number;
  34352. /**
  34353. * Defines the current inertia value used during panning of the camera along the Y axis.
  34354. */
  34355. inertialPanningY: number;
  34356. /**
  34357. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34358. * Basically if your fingers moves away from more than this distance you will be considered
  34359. * in pinch mode.
  34360. */
  34361. pinchToPanMaxDistance: number;
  34362. /**
  34363. * Defines the maximum distance the camera can pan.
  34364. * This could help keeping the cammera always in your scene.
  34365. */
  34366. panningDistanceLimit: Nullable<number>;
  34367. /**
  34368. * Defines the target of the camera before paning.
  34369. */
  34370. panningOriginTarget: Vector3;
  34371. /**
  34372. * Defines the value of the inertia used during panning.
  34373. * 0 would mean stop inertia and one would mean no decelleration at all.
  34374. */
  34375. panningInertia: number;
  34376. /**
  34377. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34378. */
  34379. angularSensibilityX: number;
  34380. /**
  34381. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34382. */
  34383. angularSensibilityY: number;
  34384. /**
  34385. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34386. */
  34387. pinchPrecision: number;
  34388. /**
  34389. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34390. * It will be used instead of pinchDeltaPrecision if different from 0.
  34391. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34392. */
  34393. pinchDeltaPercentage: number;
  34394. /**
  34395. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34396. */
  34397. panningSensibility: number;
  34398. /**
  34399. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34400. */
  34401. keysUp: number[];
  34402. /**
  34403. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34404. */
  34405. keysDown: number[];
  34406. /**
  34407. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34408. */
  34409. keysLeft: number[];
  34410. /**
  34411. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34412. */
  34413. keysRight: number[];
  34414. /**
  34415. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34416. */
  34417. wheelPrecision: number;
  34418. /**
  34419. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34420. * It will be used instead of pinchDeltaPrecision if different from 0.
  34421. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34422. */
  34423. wheelDeltaPercentage: number;
  34424. /**
  34425. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34426. */
  34427. zoomOnFactor: number;
  34428. /**
  34429. * Defines a screen offset for the camera position.
  34430. */
  34431. targetScreenOffset: Vector2;
  34432. /**
  34433. * Allows the camera to be completely reversed.
  34434. * If false the camera can not arrive upside down.
  34435. */
  34436. allowUpsideDown: boolean;
  34437. /**
  34438. * Define if double tap/click is used to restore the previously saved state of the camera.
  34439. */
  34440. useInputToRestoreState: boolean;
  34441. /** @hidden */ viewMatrix: Matrix;
  34442. /** @hidden */ useCtrlForPanning: boolean;
  34443. /** @hidden */ panningMouseButton: number;
  34444. /**
  34445. * Defines the input associated to the camera.
  34446. */
  34447. inputs: ArcRotateCameraInputsManager;
  34448. /** @hidden */ reset: () => void;
  34449. /**
  34450. * Defines the allowed panning axis.
  34451. */
  34452. panningAxis: Vector3;
  34453. protected _localDirection: Vector3;
  34454. protected _transformedDirection: Vector3;
  34455. private _bouncingBehavior;
  34456. /**
  34457. * Gets the bouncing behavior of the camera if it has been enabled.
  34458. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34459. */
  34460. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34461. /**
  34462. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34463. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34464. */
  34465. useBouncingBehavior: boolean;
  34466. private _framingBehavior;
  34467. /**
  34468. * Gets the framing behavior of the camera if it has been enabled.
  34469. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34470. */
  34471. readonly framingBehavior: Nullable<FramingBehavior>;
  34472. /**
  34473. * Defines if the framing behavior of the camera is enabled on the camera.
  34474. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34475. */
  34476. useFramingBehavior: boolean;
  34477. private _autoRotationBehavior;
  34478. /**
  34479. * Gets the auto rotation behavior of the camera if it has been enabled.
  34480. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34481. */
  34482. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34483. /**
  34484. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34485. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34486. */
  34487. useAutoRotationBehavior: boolean;
  34488. /**
  34489. * Observable triggered when the mesh target has been changed on the camera.
  34490. */
  34491. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34492. /**
  34493. * Event raised when the camera is colliding with a mesh.
  34494. */
  34495. onCollide: (collidedMesh: AbstractMesh) => void;
  34496. /**
  34497. * Defines whether the camera should check collision with the objects oh the scene.
  34498. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34499. */
  34500. checkCollisions: boolean;
  34501. /**
  34502. * Defines the collision radius of the camera.
  34503. * This simulates a sphere around the camera.
  34504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34505. */
  34506. collisionRadius: Vector3;
  34507. protected _collider: Collider;
  34508. protected _previousPosition: Vector3;
  34509. protected _collisionVelocity: Vector3;
  34510. protected _newPosition: Vector3;
  34511. protected _previousAlpha: number;
  34512. protected _previousBeta: number;
  34513. protected _previousRadius: number;
  34514. protected _collisionTriggered: boolean;
  34515. protected _targetBoundingCenter: Nullable<Vector3>;
  34516. private _computationVector;
  34517. /**
  34518. * Instantiates a new ArcRotateCamera in a given scene
  34519. * @param name Defines the name of the camera
  34520. * @param alpha Defines the camera rotation along the logitudinal axis
  34521. * @param beta Defines the camera rotation along the latitudinal axis
  34522. * @param radius Defines the camera distance from its target
  34523. * @param target Defines the camera target
  34524. * @param scene Defines the scene the camera belongs to
  34525. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34526. */
  34527. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34528. /** @hidden */ initCache(): void;
  34529. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  34530. protected _getTargetPosition(): Vector3;
  34531. private _storedAlpha;
  34532. private _storedBeta;
  34533. private _storedRadius;
  34534. private _storedTarget;
  34535. /**
  34536. * Stores the current state of the camera (alpha, beta, radius and target)
  34537. * @returns the camera itself
  34538. */
  34539. storeState(): Camera;
  34540. /**
  34541. * @hidden
  34542. * Restored camera state. You must call storeState() first
  34543. */ restoreStateValues(): boolean;
  34544. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  34545. /**
  34546. * Attached controls to the current camera.
  34547. * @param element Defines the element the controls should be listened from
  34548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34549. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34550. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34551. */
  34552. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34553. /**
  34554. * Detach the current controls from the camera.
  34555. * The camera will stop reacting to inputs.
  34556. * @param element Defines the element to stop listening the inputs from
  34557. */
  34558. detachControl(element: HTMLElement): void;
  34559. /** @hidden */ checkInputs(): void;
  34560. protected _checkLimits(): void;
  34561. /**
  34562. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34563. */
  34564. rebuildAnglesAndRadius(): void;
  34565. /**
  34566. * Use a position to define the current camera related information like aplha, beta and radius
  34567. * @param position Defines the position to set the camera at
  34568. */
  34569. setPosition(position: Vector3): void;
  34570. /**
  34571. * Defines the target the camera should look at.
  34572. * This will automatically adapt alpha beta and radius to fit within the new target.
  34573. * @param target Defines the new target as a Vector or a mesh
  34574. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34575. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34576. */
  34577. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34578. /** @hidden */ getViewMatrix(): Matrix;
  34579. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34580. /**
  34581. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34582. * @param meshes Defines the mesh to zoom on
  34583. * @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)
  34584. */
  34585. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34586. /**
  34587. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34588. * The target will be changed but the radius
  34589. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34590. * @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)
  34591. */
  34592. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34593. min: Vector3;
  34594. max: Vector3;
  34595. distance: number;
  34596. }, doNotUpdateMaxZ?: boolean): void;
  34597. /**
  34598. * @override
  34599. * Override Camera.createRigCamera
  34600. */
  34601. createRigCamera(name: string, cameraIndex: number): Camera;
  34602. /**
  34603. * @hidden
  34604. * @override
  34605. * Override Camera._updateRigCameras
  34606. */ updateRigCameras(): void;
  34607. /**
  34608. * Destroy the camera and release the current resources hold by it.
  34609. */
  34610. dispose(): void;
  34611. /**
  34612. * Gets the current object class name.
  34613. * @return the class name
  34614. */
  34615. getClassName(): string;
  34616. }
  34617. }
  34618. declare module BABYLON {
  34619. /**
  34620. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34621. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34622. */
  34623. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34624. /**
  34625. * Gets the name of the behavior.
  34626. */
  34627. readonly name: string;
  34628. private _zoomStopsAnimation;
  34629. private _idleRotationSpeed;
  34630. private _idleRotationWaitTime;
  34631. private _idleRotationSpinupTime;
  34632. /**
  34633. * Sets the flag that indicates if user zooming should stop animation.
  34634. */
  34635. /**
  34636. * Gets the flag that indicates if user zooming should stop animation.
  34637. */
  34638. zoomStopsAnimation: boolean;
  34639. /**
  34640. * Sets the default speed at which the camera rotates around the model.
  34641. */
  34642. /**
  34643. * Gets the default speed at which the camera rotates around the model.
  34644. */
  34645. idleRotationSpeed: number;
  34646. /**
  34647. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34648. */
  34649. /**
  34650. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34651. */
  34652. idleRotationWaitTime: number;
  34653. /**
  34654. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34655. */
  34656. /**
  34657. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34658. */
  34659. idleRotationSpinupTime: number;
  34660. /**
  34661. * Gets a value indicating if the camera is currently rotating because of this behavior
  34662. */
  34663. readonly rotationInProgress: boolean;
  34664. private _onPrePointerObservableObserver;
  34665. private _onAfterCheckInputsObserver;
  34666. private _attachedCamera;
  34667. private _isPointerDown;
  34668. private _lastFrameTime;
  34669. private _lastInteractionTime;
  34670. private _cameraRotationSpeed;
  34671. /**
  34672. * Initializes the behavior.
  34673. */
  34674. init(): void;
  34675. /**
  34676. * Attaches the behavior to its arc rotate camera.
  34677. * @param camera Defines the camera to attach the behavior to
  34678. */
  34679. attach(camera: ArcRotateCamera): void;
  34680. /**
  34681. * Detaches the behavior from its current arc rotate camera.
  34682. */
  34683. detach(): void;
  34684. /**
  34685. * Returns true if user is scrolling.
  34686. * @return true if user is scrolling.
  34687. */
  34688. private _userIsZooming;
  34689. private _lastFrameRadius;
  34690. private _shouldAnimationStopForInteraction;
  34691. /**
  34692. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34693. */
  34694. private _applyUserInteraction;
  34695. private _userIsMoving;
  34696. }
  34697. }
  34698. declare module BABYLON {
  34699. /**
  34700. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34701. */
  34702. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34703. private ui;
  34704. /**
  34705. * The name of the behavior
  34706. */
  34707. name: string;
  34708. /**
  34709. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34710. */
  34711. distanceAwayFromFace: number;
  34712. /**
  34713. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34714. */
  34715. distanceAwayFromBottomOfFace: number;
  34716. private _faceVectors;
  34717. private _target;
  34718. private _scene;
  34719. private _onRenderObserver;
  34720. private _tmpMatrix;
  34721. private _tmpVector;
  34722. /**
  34723. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34724. * @param ui The transform node that should be attched to the mesh
  34725. */
  34726. constructor(ui: TransformNode);
  34727. /**
  34728. * Initializes the behavior
  34729. */
  34730. init(): void;
  34731. private _closestFace;
  34732. private _zeroVector;
  34733. private _lookAtTmpMatrix;
  34734. private _lookAtToRef;
  34735. /**
  34736. * Attaches the AttachToBoxBehavior to the passed in mesh
  34737. * @param target The mesh that the specified node will be attached to
  34738. */
  34739. attach(target: Mesh): void;
  34740. /**
  34741. * Detaches the behavior from the mesh
  34742. */
  34743. detach(): void;
  34744. }
  34745. }
  34746. declare module BABYLON {
  34747. /**
  34748. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34749. */
  34750. export class FadeInOutBehavior implements Behavior<Mesh> {
  34751. /**
  34752. * Time in milliseconds to delay before fading in (Default: 0)
  34753. */
  34754. delay: number;
  34755. /**
  34756. * Time in milliseconds for the mesh to fade in (Default: 300)
  34757. */
  34758. fadeInTime: number;
  34759. private _millisecondsPerFrame;
  34760. private _hovered;
  34761. private _hoverValue;
  34762. private _ownerNode;
  34763. /**
  34764. * Instatiates the FadeInOutBehavior
  34765. */
  34766. constructor();
  34767. /**
  34768. * The name of the behavior
  34769. */
  34770. readonly name: string;
  34771. /**
  34772. * Initializes the behavior
  34773. */
  34774. init(): void;
  34775. /**
  34776. * Attaches the fade behavior on the passed in mesh
  34777. * @param ownerNode The mesh that will be faded in/out once attached
  34778. */
  34779. attach(ownerNode: Mesh): void;
  34780. /**
  34781. * Detaches the behavior from the mesh
  34782. */
  34783. detach(): void;
  34784. /**
  34785. * Triggers the mesh to begin fading in or out
  34786. * @param value if the object should fade in or out (true to fade in)
  34787. */
  34788. fadeIn(value: boolean): void;
  34789. private _update;
  34790. private _setAllVisibility;
  34791. }
  34792. }
  34793. declare module BABYLON {
  34794. /**
  34795. * Class containing a set of static utilities functions for managing Pivots
  34796. * @hidden
  34797. */
  34798. export class PivotTools {
  34799. private static _PivotCached;
  34800. private static _OldPivotPoint;
  34801. private static _PivotTranslation;
  34802. private static _PivotTmpVector;
  34803. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34804. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  34805. }
  34806. }
  34807. declare module BABYLON {
  34808. /**
  34809. * Class containing static functions to help procedurally build meshes
  34810. */
  34811. export class PlaneBuilder {
  34812. /**
  34813. * Creates a plane mesh
  34814. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  34815. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  34816. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  34817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34818. * * 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
  34819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34820. * @param name defines the name of the mesh
  34821. * @param options defines the options used to create the mesh
  34822. * @param scene defines the hosting scene
  34823. * @returns the plane mesh
  34824. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  34825. */
  34826. static CreatePlane(name: string, options: {
  34827. size?: number;
  34828. width?: number;
  34829. height?: number;
  34830. sideOrientation?: number;
  34831. frontUVs?: Vector4;
  34832. backUVs?: Vector4;
  34833. updatable?: boolean;
  34834. sourcePlane?: Plane;
  34835. }, scene?: Nullable<Scene>): Mesh;
  34836. }
  34837. }
  34838. declare module BABYLON {
  34839. /**
  34840. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  34841. */
  34842. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  34843. private static _AnyMouseID;
  34844. private _attachedNode;
  34845. private _dragPlane;
  34846. private _scene;
  34847. private _pointerObserver;
  34848. private _beforeRenderObserver;
  34849. private static _planeScene;
  34850. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  34851. /**
  34852. * 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)
  34853. */
  34854. maxDragAngle: number;
  34855. /**
  34856. * @hidden
  34857. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  34858. /**
  34859. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34860. */
  34861. currentDraggingPointerID: number;
  34862. /**
  34863. * The last position where the pointer hit the drag plane in world space
  34864. */
  34865. lastDragPosition: Vector3;
  34866. /**
  34867. * If the behavior is currently in a dragging state
  34868. */
  34869. dragging: boolean;
  34870. /**
  34871. * 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)
  34872. */
  34873. dragDeltaRatio: number;
  34874. /**
  34875. * If the drag plane orientation should be updated during the dragging (Default: true)
  34876. */
  34877. updateDragPlane: boolean;
  34878. private _debugMode;
  34879. private _moving;
  34880. /**
  34881. * Fires each time the attached mesh is dragged with the pointer
  34882. * * delta between last drag position and current drag position in world space
  34883. * * dragDistance along the drag axis
  34884. * * dragPlaneNormal normal of the current drag plane used during the drag
  34885. * * dragPlanePoint in world space where the drag intersects the drag plane
  34886. */
  34887. onDragObservable: Observable<{
  34888. delta: Vector3;
  34889. dragPlanePoint: Vector3;
  34890. dragPlaneNormal: Vector3;
  34891. dragDistance: number;
  34892. pointerId: number;
  34893. }>;
  34894. /**
  34895. * Fires each time a drag begins (eg. mouse down on mesh)
  34896. */
  34897. onDragStartObservable: Observable<{
  34898. dragPlanePoint: Vector3;
  34899. pointerId: number;
  34900. }>;
  34901. /**
  34902. * Fires each time a drag ends (eg. mouse release after drag)
  34903. */
  34904. onDragEndObservable: Observable<{
  34905. dragPlanePoint: Vector3;
  34906. pointerId: number;
  34907. }>;
  34908. /**
  34909. * If the attached mesh should be moved when dragged
  34910. */
  34911. moveAttached: boolean;
  34912. /**
  34913. * If the drag behavior will react to drag events (Default: true)
  34914. */
  34915. enabled: boolean;
  34916. /**
  34917. * If camera controls should be detached during the drag
  34918. */
  34919. detachCameraControls: boolean;
  34920. /**
  34921. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34922. */
  34923. useObjectOrienationForDragging: boolean;
  34924. private _options;
  34925. /**
  34926. * Creates a pointer drag behavior that can be attached to a mesh
  34927. * @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)
  34928. */
  34929. constructor(options?: {
  34930. dragAxis?: Vector3;
  34931. dragPlaneNormal?: Vector3;
  34932. });
  34933. /**
  34934. * Predicate to determine if it is valid to move the object to a new position when it is moved
  34935. */
  34936. validateDrag: (targetPosition: Vector3) => boolean;
  34937. /**
  34938. * The name of the behavior
  34939. */
  34940. readonly name: string;
  34941. /**
  34942. * Initializes the behavior
  34943. */
  34944. init(): void;
  34945. private _tmpVector;
  34946. private _alternatePickedPoint;
  34947. private _worldDragAxis;
  34948. private _targetPosition;
  34949. private _attachedElement;
  34950. /**
  34951. * Attaches the drag behavior the passed in mesh
  34952. * @param ownerNode The mesh that will be dragged around once attached
  34953. */
  34954. attach(ownerNode: AbstractMesh): void;
  34955. /**
  34956. * Force relase the drag action by code.
  34957. */
  34958. releaseDrag(): void;
  34959. private _startDragRay;
  34960. private _lastPointerRay;
  34961. /**
  34962. * Simulates the start of a pointer drag event on the behavior
  34963. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  34964. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  34965. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  34966. */
  34967. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  34968. private _startDrag;
  34969. private _dragDelta;
  34970. private _moveDrag;
  34971. private _pickWithRayOnDragPlane;
  34972. private _pointA;
  34973. private _pointB;
  34974. private _pointC;
  34975. private _lineA;
  34976. private _lineB;
  34977. private _localAxis;
  34978. private _lookAt;
  34979. private _updateDragPlanePosition;
  34980. /**
  34981. * Detaches the behavior from the mesh
  34982. */
  34983. detach(): void;
  34984. }
  34985. }
  34986. declare module BABYLON {
  34987. /**
  34988. * A behavior that when attached to a mesh will allow the mesh to be scaled
  34989. */
  34990. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  34991. private _dragBehaviorA;
  34992. private _dragBehaviorB;
  34993. private _startDistance;
  34994. private _initialScale;
  34995. private _targetScale;
  34996. private _ownerNode;
  34997. private _sceneRenderObserver;
  34998. /**
  34999. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35000. */
  35001. constructor();
  35002. /**
  35003. * The name of the behavior
  35004. */
  35005. readonly name: string;
  35006. /**
  35007. * Initializes the behavior
  35008. */
  35009. init(): void;
  35010. private _getCurrentDistance;
  35011. /**
  35012. * Attaches the scale behavior the passed in mesh
  35013. * @param ownerNode The mesh that will be scaled around once attached
  35014. */
  35015. attach(ownerNode: Mesh): void;
  35016. /**
  35017. * Detaches the behavior from the mesh
  35018. */
  35019. detach(): void;
  35020. }
  35021. }
  35022. declare module BABYLON {
  35023. /**
  35024. * 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
  35025. */
  35026. export class SixDofDragBehavior implements Behavior<Mesh> {
  35027. private static _virtualScene;
  35028. private _ownerNode;
  35029. private _sceneRenderObserver;
  35030. private _scene;
  35031. private _targetPosition;
  35032. private _virtualOriginMesh;
  35033. private _virtualDragMesh;
  35034. private _pointerObserver;
  35035. private _moving;
  35036. private _startingOrientation;
  35037. /**
  35038. * 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)
  35039. */
  35040. private zDragFactor;
  35041. /**
  35042. * If the object should rotate to face the drag origin
  35043. */
  35044. rotateDraggedObject: boolean;
  35045. /**
  35046. * If the behavior is currently in a dragging state
  35047. */
  35048. dragging: boolean;
  35049. /**
  35050. * 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)
  35051. */
  35052. dragDeltaRatio: number;
  35053. /**
  35054. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35055. */
  35056. currentDraggingPointerID: number;
  35057. /**
  35058. * If camera controls should be detached during the drag
  35059. */
  35060. detachCameraControls: boolean;
  35061. /**
  35062. * Fires each time a drag starts
  35063. */
  35064. onDragStartObservable: Observable<{}>;
  35065. /**
  35066. * Fires each time a drag ends (eg. mouse release after drag)
  35067. */
  35068. onDragEndObservable: Observable<{}>;
  35069. /**
  35070. * 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
  35071. */
  35072. constructor();
  35073. /**
  35074. * The name of the behavior
  35075. */
  35076. readonly name: string;
  35077. /**
  35078. * Initializes the behavior
  35079. */
  35080. init(): void;
  35081. /**
  35082. * Attaches the scale behavior the passed in mesh
  35083. * @param ownerNode The mesh that will be scaled around once attached
  35084. */
  35085. attach(ownerNode: Mesh): void;
  35086. /**
  35087. * Detaches the behavior from the mesh
  35088. */
  35089. detach(): void;
  35090. }
  35091. }
  35092. declare module BABYLON {
  35093. /**
  35094. * Class used to apply inverse kinematics to bones
  35095. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35096. */
  35097. export class BoneIKController {
  35098. private static _tmpVecs;
  35099. private static _tmpQuat;
  35100. private static _tmpMats;
  35101. /**
  35102. * Gets or sets the target mesh
  35103. */
  35104. targetMesh: AbstractMesh;
  35105. /** Gets or sets the mesh used as pole */
  35106. poleTargetMesh: AbstractMesh;
  35107. /**
  35108. * Gets or sets the bone used as pole
  35109. */
  35110. poleTargetBone: Nullable<Bone>;
  35111. /**
  35112. * Gets or sets the target position
  35113. */
  35114. targetPosition: Vector3;
  35115. /**
  35116. * Gets or sets the pole target position
  35117. */
  35118. poleTargetPosition: Vector3;
  35119. /**
  35120. * Gets or sets the pole target local offset
  35121. */
  35122. poleTargetLocalOffset: Vector3;
  35123. /**
  35124. * Gets or sets the pole angle
  35125. */
  35126. poleAngle: number;
  35127. /**
  35128. * Gets or sets the mesh associated with the controller
  35129. */
  35130. mesh: AbstractMesh;
  35131. /**
  35132. * 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)
  35133. */
  35134. slerpAmount: number;
  35135. private _bone1Quat;
  35136. private _bone1Mat;
  35137. private _bone2Ang;
  35138. private _bone1;
  35139. private _bone2;
  35140. private _bone1Length;
  35141. private _bone2Length;
  35142. private _maxAngle;
  35143. private _maxReach;
  35144. private _rightHandedSystem;
  35145. private _bendAxis;
  35146. private _slerping;
  35147. private _adjustRoll;
  35148. /**
  35149. * Gets or sets maximum allowed angle
  35150. */
  35151. maxAngle: number;
  35152. /**
  35153. * Creates a new BoneIKController
  35154. * @param mesh defines the mesh to control
  35155. * @param bone defines the bone to control
  35156. * @param options defines options to set up the controller
  35157. */
  35158. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35159. targetMesh?: AbstractMesh;
  35160. poleTargetMesh?: AbstractMesh;
  35161. poleTargetBone?: Bone;
  35162. poleTargetLocalOffset?: Vector3;
  35163. poleAngle?: number;
  35164. bendAxis?: Vector3;
  35165. maxAngle?: number;
  35166. slerpAmount?: number;
  35167. });
  35168. private _setMaxAngle;
  35169. /**
  35170. * Force the controller to update the bones
  35171. */
  35172. update(): void;
  35173. }
  35174. }
  35175. declare module BABYLON {
  35176. /**
  35177. * Class used to make a bone look toward a point in space
  35178. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35179. */
  35180. export class BoneLookController {
  35181. private static _tmpVecs;
  35182. private static _tmpQuat;
  35183. private static _tmpMats;
  35184. /**
  35185. * The target Vector3 that the bone will look at
  35186. */
  35187. target: Vector3;
  35188. /**
  35189. * The mesh that the bone is attached to
  35190. */
  35191. mesh: AbstractMesh;
  35192. /**
  35193. * The bone that will be looking to the target
  35194. */
  35195. bone: Bone;
  35196. /**
  35197. * The up axis of the coordinate system that is used when the bone is rotated
  35198. */
  35199. upAxis: Vector3;
  35200. /**
  35201. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35202. */
  35203. upAxisSpace: Space;
  35204. /**
  35205. * Used to make an adjustment to the yaw of the bone
  35206. */
  35207. adjustYaw: number;
  35208. /**
  35209. * Used to make an adjustment to the pitch of the bone
  35210. */
  35211. adjustPitch: number;
  35212. /**
  35213. * Used to make an adjustment to the roll of the bone
  35214. */
  35215. adjustRoll: number;
  35216. /**
  35217. * 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)
  35218. */
  35219. slerpAmount: number;
  35220. private _minYaw;
  35221. private _maxYaw;
  35222. private _minPitch;
  35223. private _maxPitch;
  35224. private _minYawSin;
  35225. private _minYawCos;
  35226. private _maxYawSin;
  35227. private _maxYawCos;
  35228. private _midYawConstraint;
  35229. private _minPitchTan;
  35230. private _maxPitchTan;
  35231. private _boneQuat;
  35232. private _slerping;
  35233. private _transformYawPitch;
  35234. private _transformYawPitchInv;
  35235. private _firstFrameSkipped;
  35236. private _yawRange;
  35237. private _fowardAxis;
  35238. /**
  35239. * Gets or sets the minimum yaw angle that the bone can look to
  35240. */
  35241. minYaw: number;
  35242. /**
  35243. * Gets or sets the maximum yaw angle that the bone can look to
  35244. */
  35245. maxYaw: number;
  35246. /**
  35247. * Gets or sets the minimum pitch angle that the bone can look to
  35248. */
  35249. minPitch: number;
  35250. /**
  35251. * Gets or sets the maximum pitch angle that the bone can look to
  35252. */
  35253. maxPitch: number;
  35254. /**
  35255. * Create a BoneLookController
  35256. * @param mesh the mesh that the bone belongs to
  35257. * @param bone the bone that will be looking to the target
  35258. * @param target the target Vector3 to look at
  35259. * @param options optional settings:
  35260. * * maxYaw: the maximum angle the bone will yaw to
  35261. * * minYaw: the minimum angle the bone will yaw to
  35262. * * maxPitch: the maximum angle the bone will pitch to
  35263. * * minPitch: the minimum angle the bone will yaw to
  35264. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35265. * * upAxis: the up axis of the coordinate system
  35266. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35267. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35268. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35269. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35270. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35271. * * adjustRoll: used to make an adjustment to the roll of the bone
  35272. **/
  35273. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35274. maxYaw?: number;
  35275. minYaw?: number;
  35276. maxPitch?: number;
  35277. minPitch?: number;
  35278. slerpAmount?: number;
  35279. upAxis?: Vector3;
  35280. upAxisSpace?: Space;
  35281. yawAxis?: Vector3;
  35282. pitchAxis?: Vector3;
  35283. adjustYaw?: number;
  35284. adjustPitch?: number;
  35285. adjustRoll?: number;
  35286. });
  35287. /**
  35288. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35289. */
  35290. update(): void;
  35291. private _getAngleDiff;
  35292. private _getAngleBetween;
  35293. private _isAngleBetween;
  35294. }
  35295. }
  35296. declare module BABYLON {
  35297. /**
  35298. * Manage the gamepad inputs to control an arc rotate camera.
  35299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35300. */
  35301. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35302. /**
  35303. * Defines the camera the input is attached to.
  35304. */
  35305. camera: ArcRotateCamera;
  35306. /**
  35307. * Defines the gamepad the input is gathering event from.
  35308. */
  35309. gamepad: Nullable<Gamepad>;
  35310. /**
  35311. * Defines the gamepad rotation sensiblity.
  35312. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35313. */
  35314. gamepadRotationSensibility: number;
  35315. /**
  35316. * Defines the gamepad move sensiblity.
  35317. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35318. */
  35319. gamepadMoveSensibility: number;
  35320. private _onGamepadConnectedObserver;
  35321. private _onGamepadDisconnectedObserver;
  35322. /**
  35323. * Attach the input controls to a specific dom element to get the input from.
  35324. * @param element Defines the element the controls should be listened from
  35325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35326. */
  35327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35328. /**
  35329. * Detach the current controls from the specified dom element.
  35330. * @param element Defines the element to stop listening the inputs from
  35331. */
  35332. detachControl(element: Nullable<HTMLElement>): void;
  35333. /**
  35334. * Update the current camera state depending on the inputs that have been used this frame.
  35335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35336. */
  35337. checkInputs(): void;
  35338. /**
  35339. * Gets the class name of the current intput.
  35340. * @returns the class name
  35341. */
  35342. getClassName(): string;
  35343. /**
  35344. * Get the friendly name associated with the input class.
  35345. * @returns the input friendly name
  35346. */
  35347. getSimpleName(): string;
  35348. }
  35349. }
  35350. declare module BABYLON {
  35351. interface ArcRotateCameraInputsManager {
  35352. /**
  35353. * Add orientation input support to the input manager.
  35354. * @returns the current input manager
  35355. */
  35356. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35357. }
  35358. /**
  35359. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35361. */
  35362. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35363. /**
  35364. * Defines the camera the input is attached to.
  35365. */
  35366. camera: ArcRotateCamera;
  35367. /**
  35368. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35369. */
  35370. alphaCorrection: number;
  35371. /**
  35372. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35373. */
  35374. gammaCorrection: number;
  35375. private _alpha;
  35376. private _gamma;
  35377. private _dirty;
  35378. private _deviceOrientationHandler;
  35379. /**
  35380. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35381. */
  35382. constructor();
  35383. /**
  35384. * Attach the input controls to a specific dom element to get the input from.
  35385. * @param element Defines the element the controls should be listened from
  35386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35387. */
  35388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35389. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  35390. /**
  35391. * Update the current camera state depending on the inputs that have been used this frame.
  35392. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35393. */
  35394. checkInputs(): void;
  35395. /**
  35396. * Detach the current controls from the specified dom element.
  35397. * @param element Defines the element to stop listening the inputs from
  35398. */
  35399. detachControl(element: Nullable<HTMLElement>): void;
  35400. /**
  35401. * Gets the class name of the current intput.
  35402. * @returns the class name
  35403. */
  35404. getClassName(): string;
  35405. /**
  35406. * Get the friendly name associated with the input class.
  35407. * @returns the input friendly name
  35408. */
  35409. getSimpleName(): string;
  35410. }
  35411. }
  35412. declare module BABYLON {
  35413. /**
  35414. * Listen to mouse events to control the camera.
  35415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35416. */
  35417. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35418. /**
  35419. * Defines the camera the input is attached to.
  35420. */
  35421. camera: FlyCamera;
  35422. /**
  35423. * Defines if touch is enabled. (Default is true.)
  35424. */
  35425. touchEnabled: boolean;
  35426. /**
  35427. * Defines the buttons associated with the input to handle camera rotation.
  35428. */
  35429. buttons: number[];
  35430. /**
  35431. * Assign buttons for Yaw control.
  35432. */
  35433. buttonsYaw: number[];
  35434. /**
  35435. * Assign buttons for Pitch control.
  35436. */
  35437. buttonsPitch: number[];
  35438. /**
  35439. * Assign buttons for Roll control.
  35440. */
  35441. buttonsRoll: number[];
  35442. /**
  35443. * Detect if any button is being pressed while mouse is moved.
  35444. * -1 = Mouse locked.
  35445. * 0 = Left button.
  35446. * 1 = Middle Button.
  35447. * 2 = Right Button.
  35448. */
  35449. activeButton: number;
  35450. /**
  35451. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35452. * Higher values reduce its sensitivity.
  35453. */
  35454. angularSensibility: number;
  35455. private _mousemoveCallback;
  35456. private _observer;
  35457. private _rollObserver;
  35458. private previousPosition;
  35459. private noPreventDefault;
  35460. private element;
  35461. /**
  35462. * Listen to mouse events to control the camera.
  35463. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35465. */
  35466. constructor(touchEnabled?: boolean);
  35467. /**
  35468. * Attach the mouse control to the HTML DOM element.
  35469. * @param element Defines the element that listens to the input events.
  35470. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35471. */
  35472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35473. /**
  35474. * Detach the current controls from the specified dom element.
  35475. * @param element Defines the element to stop listening the inputs from
  35476. */
  35477. detachControl(element: Nullable<HTMLElement>): void;
  35478. /**
  35479. * Gets the class name of the current input.
  35480. * @returns the class name.
  35481. */
  35482. getClassName(): string;
  35483. /**
  35484. * Get the friendly name associated with the input class.
  35485. * @returns the input's friendly name.
  35486. */
  35487. getSimpleName(): string;
  35488. private _pointerInput;
  35489. private _onMouseMove;
  35490. /**
  35491. * Rotate camera by mouse offset.
  35492. */
  35493. private rotateCamera;
  35494. }
  35495. }
  35496. declare module BABYLON {
  35497. /**
  35498. * Default Inputs manager for the FlyCamera.
  35499. * It groups all the default supported inputs for ease of use.
  35500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35501. */
  35502. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35503. /**
  35504. * Instantiates a new FlyCameraInputsManager.
  35505. * @param camera Defines the camera the inputs belong to.
  35506. */
  35507. constructor(camera: FlyCamera);
  35508. /**
  35509. * Add keyboard input support to the input manager.
  35510. * @returns the new FlyCameraKeyboardMoveInput().
  35511. */
  35512. addKeyboard(): FlyCameraInputsManager;
  35513. /**
  35514. * Add mouse input support to the input manager.
  35515. * @param touchEnabled Enable touch screen support.
  35516. * @returns the new FlyCameraMouseInput().
  35517. */
  35518. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35519. }
  35520. }
  35521. declare module BABYLON {
  35522. /**
  35523. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35524. * such as in a 3D Space Shooter or a Flight Simulator.
  35525. */
  35526. export class FlyCamera extends TargetCamera {
  35527. /**
  35528. * Define the collision ellipsoid of the camera.
  35529. * This is helpful for simulating a camera body, like a player's body.
  35530. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35531. */
  35532. ellipsoid: Vector3;
  35533. /**
  35534. * Define an offset for the position of the ellipsoid around the camera.
  35535. * This can be helpful if the camera is attached away from the player's body center,
  35536. * such as at its head.
  35537. */
  35538. ellipsoidOffset: Vector3;
  35539. /**
  35540. * Enable or disable collisions of the camera with the rest of the scene objects.
  35541. */
  35542. checkCollisions: boolean;
  35543. /**
  35544. * Enable or disable gravity on the camera.
  35545. */
  35546. applyGravity: boolean;
  35547. /**
  35548. * Define the current direction the camera is moving to.
  35549. */
  35550. cameraDirection: Vector3;
  35551. /**
  35552. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35553. * This overrides and empties cameraRotation.
  35554. */
  35555. rotationQuaternion: Quaternion;
  35556. /**
  35557. * Track Roll to maintain the wanted Rolling when looking around.
  35558. */ trackRoll: number;
  35559. /**
  35560. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35561. */
  35562. rollCorrect: number;
  35563. /**
  35564. * Mimic a banked turn, Rolling the camera when Yawing.
  35565. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35566. */
  35567. bankedTurn: boolean;
  35568. /**
  35569. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35570. */
  35571. bankedTurnLimit: number;
  35572. /**
  35573. * Value of 0 disables the banked Roll.
  35574. * Value of 1 is equal to the Yaw angle in radians.
  35575. */
  35576. bankedTurnMultiplier: number;
  35577. /**
  35578. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35579. */
  35580. inputs: FlyCameraInputsManager;
  35581. /**
  35582. * Gets the input sensibility for mouse input.
  35583. * Higher values reduce sensitivity.
  35584. */
  35585. /**
  35586. * Sets the input sensibility for a mouse input.
  35587. * Higher values reduce sensitivity.
  35588. */
  35589. angularSensibility: number;
  35590. /**
  35591. * Get the keys for camera movement forward.
  35592. */
  35593. /**
  35594. * Set the keys for camera movement forward.
  35595. */
  35596. keysForward: number[];
  35597. /**
  35598. * Get the keys for camera movement backward.
  35599. */
  35600. keysBackward: number[];
  35601. /**
  35602. * Get the keys for camera movement up.
  35603. */
  35604. /**
  35605. * Set the keys for camera movement up.
  35606. */
  35607. keysUp: number[];
  35608. /**
  35609. * Get the keys for camera movement down.
  35610. */
  35611. /**
  35612. * Set the keys for camera movement down.
  35613. */
  35614. keysDown: number[];
  35615. /**
  35616. * Get the keys for camera movement left.
  35617. */
  35618. /**
  35619. * Set the keys for camera movement left.
  35620. */
  35621. keysLeft: number[];
  35622. /**
  35623. * Set the keys for camera movement right.
  35624. */
  35625. /**
  35626. * Set the keys for camera movement right.
  35627. */
  35628. keysRight: number[];
  35629. /**
  35630. * Event raised when the camera collides with a mesh in the scene.
  35631. */
  35632. onCollide: (collidedMesh: AbstractMesh) => void;
  35633. private _collider;
  35634. private _needMoveForGravity;
  35635. private _oldPosition;
  35636. private _diffPosition;
  35637. private _newPosition;
  35638. /** @hidden */ localDirection: Vector3;
  35639. /** @hidden */ transformedDirection: Vector3;
  35640. /**
  35641. * Instantiates a FlyCamera.
  35642. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35643. * such as in a 3D Space Shooter or a Flight Simulator.
  35644. * @param name Define the name of the camera in the scene.
  35645. * @param position Define the starting position of the camera in the scene.
  35646. * @param scene Define the scene the camera belongs to.
  35647. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35648. */
  35649. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35650. /**
  35651. * Attach a control to the HTML DOM element.
  35652. * @param element Defines the element that listens to the input events.
  35653. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35654. */
  35655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35656. /**
  35657. * Detach a control from the HTML DOM element.
  35658. * The camera will stop reacting to that input.
  35659. * @param element Defines the element that listens to the input events.
  35660. */
  35661. detachControl(element: HTMLElement): void;
  35662. private _collisionMask;
  35663. /**
  35664. * Get the mask that the camera ignores in collision events.
  35665. */
  35666. /**
  35667. * Set the mask that the camera ignores in collision events.
  35668. */
  35669. collisionMask: number;
  35670. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  35671. /** @hidden */
  35672. private _onCollisionPositionChange;
  35673. /** @hidden */ checkInputs(): void;
  35674. /** @hidden */ decideIfNeedsToMove(): boolean;
  35675. /** @hidden */ updatePosition(): void;
  35676. /**
  35677. * Restore the Roll to its target value at the rate specified.
  35678. * @param rate - Higher means slower restoring.
  35679. * @hidden
  35680. */
  35681. restoreRoll(rate: number): void;
  35682. /**
  35683. * Destroy the camera and release the current resources held by it.
  35684. */
  35685. dispose(): void;
  35686. /**
  35687. * Get the current object class name.
  35688. * @returns the class name.
  35689. */
  35690. getClassName(): string;
  35691. }
  35692. }
  35693. declare module BABYLON {
  35694. /**
  35695. * Listen to keyboard events to control the camera.
  35696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35697. */
  35698. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35699. /**
  35700. * Defines the camera the input is attached to.
  35701. */
  35702. camera: FlyCamera;
  35703. /**
  35704. * The list of keyboard keys used to control the forward move of the camera.
  35705. */
  35706. keysForward: number[];
  35707. /**
  35708. * The list of keyboard keys used to control the backward move of the camera.
  35709. */
  35710. keysBackward: number[];
  35711. /**
  35712. * The list of keyboard keys used to control the forward move of the camera.
  35713. */
  35714. keysUp: number[];
  35715. /**
  35716. * The list of keyboard keys used to control the backward move of the camera.
  35717. */
  35718. keysDown: number[];
  35719. /**
  35720. * The list of keyboard keys used to control the right strafe move of the camera.
  35721. */
  35722. keysRight: number[];
  35723. /**
  35724. * The list of keyboard keys used to control the left strafe move of the camera.
  35725. */
  35726. keysLeft: number[];
  35727. private _keys;
  35728. private _onCanvasBlurObserver;
  35729. private _onKeyboardObserver;
  35730. private _engine;
  35731. private _scene;
  35732. /**
  35733. * Attach the input controls to a specific dom element to get the input from.
  35734. * @param element Defines the element the controls should be listened from
  35735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35736. */
  35737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35738. /**
  35739. * Detach the current controls from the specified dom element.
  35740. * @param element Defines the element to stop listening the inputs from
  35741. */
  35742. detachControl(element: Nullable<HTMLElement>): void;
  35743. /**
  35744. * Gets the class name of the current intput.
  35745. * @returns the class name
  35746. */
  35747. getClassName(): string;
  35748. /** @hidden */ onLostFocus(e: FocusEvent): void;
  35749. /**
  35750. * Get the friendly name associated with the input class.
  35751. * @returns the input friendly name
  35752. */
  35753. getSimpleName(): string;
  35754. /**
  35755. * Update the current camera state depending on the inputs that have been used this frame.
  35756. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35757. */
  35758. checkInputs(): void;
  35759. }
  35760. }
  35761. declare module BABYLON {
  35762. /**
  35763. * Manage the mouse wheel inputs to control a follow camera.
  35764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35765. */
  35766. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35767. /**
  35768. * Defines the camera the input is attached to.
  35769. */
  35770. camera: FollowCamera;
  35771. /**
  35772. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  35773. */
  35774. axisControlRadius: boolean;
  35775. /**
  35776. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  35777. */
  35778. axisControlHeight: boolean;
  35779. /**
  35780. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  35781. */
  35782. axisControlRotation: boolean;
  35783. /**
  35784. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35785. * relation to mouseWheel events.
  35786. */
  35787. wheelPrecision: number;
  35788. /**
  35789. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35790. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35791. */
  35792. wheelDeltaPercentage: number;
  35793. private _wheel;
  35794. private _observer;
  35795. /**
  35796. * Attach the input controls to a specific dom element to get the input from.
  35797. * @param element Defines the element the controls should be listened from
  35798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35799. */
  35800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35801. /**
  35802. * Detach the current controls from the specified dom element.
  35803. * @param element Defines the element to stop listening the inputs from
  35804. */
  35805. detachControl(element: Nullable<HTMLElement>): void;
  35806. /**
  35807. * Gets the class name of the current intput.
  35808. * @returns the class name
  35809. */
  35810. getClassName(): string;
  35811. /**
  35812. * Get the friendly name associated with the input class.
  35813. * @returns the input friendly name
  35814. */
  35815. getSimpleName(): string;
  35816. }
  35817. }
  35818. declare module BABYLON {
  35819. /**
  35820. * Manage the pointers inputs to control an follow camera.
  35821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35822. */
  35823. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  35824. /**
  35825. * Defines the camera the input is attached to.
  35826. */
  35827. camera: FollowCamera;
  35828. /**
  35829. * Gets the class name of the current input.
  35830. * @returns the class name
  35831. */
  35832. getClassName(): string;
  35833. /**
  35834. * Defines the pointer angular sensibility along the X axis or how fast is
  35835. * the camera rotating.
  35836. * A negative number will reverse the axis direction.
  35837. */
  35838. angularSensibilityX: number;
  35839. /**
  35840. * Defines the pointer angular sensibility along the Y axis or how fast is
  35841. * the camera rotating.
  35842. * A negative number will reverse the axis direction.
  35843. */
  35844. angularSensibilityY: number;
  35845. /**
  35846. * Defines the pointer pinch precision or how fast is the camera zooming.
  35847. * A negative number will reverse the axis direction.
  35848. */
  35849. pinchPrecision: number;
  35850. /**
  35851. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35852. * from 0.
  35853. * It defines the percentage of current camera.radius to use as delta when
  35854. * pinch zoom is used.
  35855. */
  35856. pinchDeltaPercentage: number;
  35857. /**
  35858. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  35859. */
  35860. axisXControlRadius: boolean;
  35861. /**
  35862. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  35863. */
  35864. axisXControlHeight: boolean;
  35865. /**
  35866. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  35867. */
  35868. axisXControlRotation: boolean;
  35869. /**
  35870. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  35871. */
  35872. axisYControlRadius: boolean;
  35873. /**
  35874. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  35875. */
  35876. axisYControlHeight: boolean;
  35877. /**
  35878. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  35879. */
  35880. axisYControlRotation: boolean;
  35881. /**
  35882. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  35883. */
  35884. axisPinchControlRadius: boolean;
  35885. /**
  35886. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  35887. */
  35888. axisPinchControlHeight: boolean;
  35889. /**
  35890. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  35891. */
  35892. axisPinchControlRotation: boolean;
  35893. /**
  35894. * Log error messages if basic misconfiguration has occurred.
  35895. */
  35896. warningEnable: boolean;
  35897. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35898. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35899. private _warningCounter;
  35900. private _warning;
  35901. }
  35902. }
  35903. declare module BABYLON {
  35904. /**
  35905. * Default Inputs manager for the FollowCamera.
  35906. * It groups all the default supported inputs for ease of use.
  35907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35908. */
  35909. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  35910. /**
  35911. * Instantiates a new FollowCameraInputsManager.
  35912. * @param camera Defines the camera the inputs belong to
  35913. */
  35914. constructor(camera: FollowCamera);
  35915. /**
  35916. * Add keyboard input support to the input manager.
  35917. * @returns the current input manager
  35918. */
  35919. addKeyboard(): FollowCameraInputsManager;
  35920. /**
  35921. * Add mouse wheel input support to the input manager.
  35922. * @returns the current input manager
  35923. */
  35924. addMouseWheel(): FollowCameraInputsManager;
  35925. /**
  35926. * Add pointers input support to the input manager.
  35927. * @returns the current input manager
  35928. */
  35929. addPointers(): FollowCameraInputsManager;
  35930. /**
  35931. * Add orientation input support to the input manager.
  35932. * @returns the current input manager
  35933. */
  35934. addVRDeviceOrientation(): FollowCameraInputsManager;
  35935. }
  35936. }
  35937. declare module BABYLON {
  35938. /**
  35939. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  35940. * an arc rotate version arcFollowCamera are available.
  35941. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35942. */
  35943. export class FollowCamera extends TargetCamera {
  35944. /**
  35945. * Distance the follow camera should follow an object at
  35946. */
  35947. radius: number;
  35948. /**
  35949. * Minimum allowed distance of the camera to the axis of rotation
  35950. * (The camera can not get closer).
  35951. * This can help limiting how the Camera is able to move in the scene.
  35952. */
  35953. lowerRadiusLimit: Nullable<number>;
  35954. /**
  35955. * Maximum allowed distance of the camera to the axis of rotation
  35956. * (The camera can not get further).
  35957. * This can help limiting how the Camera is able to move in the scene.
  35958. */
  35959. upperRadiusLimit: Nullable<number>;
  35960. /**
  35961. * Define a rotation offset between the camera and the object it follows
  35962. */
  35963. rotationOffset: number;
  35964. /**
  35965. * Minimum allowed angle to camera position relative to target object.
  35966. * This can help limiting how the Camera is able to move in the scene.
  35967. */
  35968. lowerRotationOffsetLimit: Nullable<number>;
  35969. /**
  35970. * Maximum allowed angle to camera position relative to target object.
  35971. * This can help limiting how the Camera is able to move in the scene.
  35972. */
  35973. upperRotationOffsetLimit: Nullable<number>;
  35974. /**
  35975. * Define a height offset between the camera and the object it follows.
  35976. * It can help following an object from the top (like a car chaing a plane)
  35977. */
  35978. heightOffset: number;
  35979. /**
  35980. * Minimum allowed height of camera position relative to target object.
  35981. * This can help limiting how the Camera is able to move in the scene.
  35982. */
  35983. lowerHeightOffsetLimit: Nullable<number>;
  35984. /**
  35985. * Maximum allowed height of camera position relative to target object.
  35986. * This can help limiting how the Camera is able to move in the scene.
  35987. */
  35988. upperHeightOffsetLimit: Nullable<number>;
  35989. /**
  35990. * Define how fast the camera can accelerate to follow it s target.
  35991. */
  35992. cameraAcceleration: number;
  35993. /**
  35994. * Define the speed limit of the camera following an object.
  35995. */
  35996. maxCameraSpeed: number;
  35997. /**
  35998. * Define the target of the camera.
  35999. */
  36000. lockedTarget: Nullable<AbstractMesh>;
  36001. /**
  36002. * Defines the input associated with the camera.
  36003. */
  36004. inputs: FollowCameraInputsManager;
  36005. /**
  36006. * Instantiates the follow camera.
  36007. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36008. * @param name Define the name of the camera in the scene
  36009. * @param position Define the position of the camera
  36010. * @param scene Define the scene the camera belong to
  36011. * @param lockedTarget Define the target of the camera
  36012. */
  36013. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36014. private _follow;
  36015. /**
  36016. * Attached controls to the current camera.
  36017. * @param element Defines the element the controls should be listened from
  36018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36019. */
  36020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36021. /**
  36022. * Detach the current controls from the camera.
  36023. * The camera will stop reacting to inputs.
  36024. * @param element Defines the element to stop listening the inputs from
  36025. */
  36026. detachControl(element: HTMLElement): void;
  36027. /** @hidden */ checkInputs(): void;
  36028. private _checkLimits;
  36029. /**
  36030. * Gets the camera class name.
  36031. * @returns the class name
  36032. */
  36033. getClassName(): string;
  36034. }
  36035. /**
  36036. * Arc Rotate version of the follow camera.
  36037. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36038. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36039. */
  36040. export class ArcFollowCamera extends TargetCamera {
  36041. /** The longitudinal angle of the camera */
  36042. alpha: number;
  36043. /** The latitudinal angle of the camera */
  36044. beta: number;
  36045. /** The radius of the camera from its target */
  36046. radius: number;
  36047. /** Define the camera target (the messh it should follow) */
  36048. target: Nullable<AbstractMesh>;
  36049. private _cartesianCoordinates;
  36050. /**
  36051. * Instantiates a new ArcFollowCamera
  36052. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36053. * @param name Define the name of the camera
  36054. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36055. * @param beta Define the rotation angle of the camera around the elevation axis
  36056. * @param radius Define the radius of the camera from its target point
  36057. * @param target Define the target of the camera
  36058. * @param scene Define the scene the camera belongs to
  36059. */
  36060. constructor(name: string,
  36061. /** The longitudinal angle of the camera */
  36062. alpha: number,
  36063. /** The latitudinal angle of the camera */
  36064. beta: number,
  36065. /** The radius of the camera from its target */
  36066. radius: number,
  36067. /** Define the camera target (the messh it should follow) */
  36068. target: Nullable<AbstractMesh>, scene: Scene);
  36069. private _follow;
  36070. /** @hidden */ checkInputs(): void;
  36071. /**
  36072. * Returns the class name of the object.
  36073. * It is mostly used internally for serialization purposes.
  36074. */
  36075. getClassName(): string;
  36076. }
  36077. }
  36078. declare module BABYLON {
  36079. /**
  36080. * Manage the keyboard inputs to control the movement of a follow camera.
  36081. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36082. */
  36083. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36084. /**
  36085. * Defines the camera the input is attached to.
  36086. */
  36087. camera: FollowCamera;
  36088. /**
  36089. * Defines the list of key codes associated with the up action (increase heightOffset)
  36090. */
  36091. keysHeightOffsetIncr: number[];
  36092. /**
  36093. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36094. */
  36095. keysHeightOffsetDecr: number[];
  36096. /**
  36097. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36098. */
  36099. keysHeightOffsetModifierAlt: boolean;
  36100. /**
  36101. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36102. */
  36103. keysHeightOffsetModifierCtrl: boolean;
  36104. /**
  36105. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36106. */
  36107. keysHeightOffsetModifierShift: boolean;
  36108. /**
  36109. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36110. */
  36111. keysRotationOffsetIncr: number[];
  36112. /**
  36113. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36114. */
  36115. keysRotationOffsetDecr: number[];
  36116. /**
  36117. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36118. */
  36119. keysRotationOffsetModifierAlt: boolean;
  36120. /**
  36121. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36122. */
  36123. keysRotationOffsetModifierCtrl: boolean;
  36124. /**
  36125. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36126. */
  36127. keysRotationOffsetModifierShift: boolean;
  36128. /**
  36129. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36130. */
  36131. keysRadiusIncr: number[];
  36132. /**
  36133. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36134. */
  36135. keysRadiusDecr: number[];
  36136. /**
  36137. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36138. */
  36139. keysRadiusModifierAlt: boolean;
  36140. /**
  36141. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36142. */
  36143. keysRadiusModifierCtrl: boolean;
  36144. /**
  36145. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36146. */
  36147. keysRadiusModifierShift: boolean;
  36148. /**
  36149. * Defines the rate of change of heightOffset.
  36150. */
  36151. heightSensibility: number;
  36152. /**
  36153. * Defines the rate of change of rotationOffset.
  36154. */
  36155. rotationSensibility: number;
  36156. /**
  36157. * Defines the rate of change of radius.
  36158. */
  36159. radiusSensibility: number;
  36160. private _keys;
  36161. private _ctrlPressed;
  36162. private _altPressed;
  36163. private _shiftPressed;
  36164. private _onCanvasBlurObserver;
  36165. private _onKeyboardObserver;
  36166. private _engine;
  36167. private _scene;
  36168. /**
  36169. * Attach the input controls to a specific dom element to get the input from.
  36170. * @param element Defines the element the controls should be listened from
  36171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36172. */
  36173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36174. /**
  36175. * Detach the current controls from the specified dom element.
  36176. * @param element Defines the element to stop listening the inputs from
  36177. */
  36178. detachControl(element: Nullable<HTMLElement>): void;
  36179. /**
  36180. * Update the current camera state depending on the inputs that have been used this frame.
  36181. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36182. */
  36183. checkInputs(): void;
  36184. /**
  36185. * Gets the class name of the current input.
  36186. * @returns the class name
  36187. */
  36188. getClassName(): string;
  36189. /**
  36190. * Get the friendly name associated with the input class.
  36191. * @returns the input friendly name
  36192. */
  36193. getSimpleName(): string;
  36194. /**
  36195. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36196. * allow modification of the heightOffset value.
  36197. */
  36198. private _modifierHeightOffset;
  36199. /**
  36200. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36201. * allow modification of the rotationOffset value.
  36202. */
  36203. private _modifierRotationOffset;
  36204. /**
  36205. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36206. * allow modification of the radius value.
  36207. */
  36208. private _modifierRadius;
  36209. }
  36210. }
  36211. declare module BABYLON {
  36212. interface FreeCameraInputsManager {
  36213. /**
  36214. * @hidden
  36215. */ deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36216. /**
  36217. * Add orientation input support to the input manager.
  36218. * @returns the current input manager
  36219. */
  36220. addDeviceOrientation(): FreeCameraInputsManager;
  36221. }
  36222. /**
  36223. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36224. * Screen rotation is taken into account.
  36225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36226. */
  36227. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36228. private _camera;
  36229. private _screenOrientationAngle;
  36230. private _constantTranform;
  36231. private _screenQuaternion;
  36232. private _alpha;
  36233. private _beta;
  36234. private _gamma;
  36235. /**
  36236. * @hidden
  36237. */ onDeviceOrientationChangedObservable: Observable<void>;
  36238. /**
  36239. * Instantiates a new input
  36240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36241. */
  36242. constructor();
  36243. /**
  36244. * Define the camera controlled by the input.
  36245. */
  36246. camera: FreeCamera;
  36247. /**
  36248. * Attach the input controls to a specific dom element to get the input from.
  36249. * @param element Defines the element the controls should be listened from
  36250. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36251. */
  36252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36253. private _orientationChanged;
  36254. private _deviceOrientation;
  36255. /**
  36256. * Detach the current controls from the specified dom element.
  36257. * @param element Defines the element to stop listening the inputs from
  36258. */
  36259. detachControl(element: Nullable<HTMLElement>): void;
  36260. /**
  36261. * Update the current camera state depending on the inputs that have been used this frame.
  36262. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36263. */
  36264. checkInputs(): void;
  36265. /**
  36266. * Gets the class name of the current intput.
  36267. * @returns the class name
  36268. */
  36269. getClassName(): string;
  36270. /**
  36271. * Get the friendly name associated with the input class.
  36272. * @returns the input friendly name
  36273. */
  36274. getSimpleName(): string;
  36275. }
  36276. }
  36277. declare module BABYLON {
  36278. /**
  36279. * Manage the gamepad inputs to control a free camera.
  36280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36281. */
  36282. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36283. /**
  36284. * Define the camera the input is attached to.
  36285. */
  36286. camera: FreeCamera;
  36287. /**
  36288. * Define the Gamepad controlling the input
  36289. */
  36290. gamepad: Nullable<Gamepad>;
  36291. /**
  36292. * Defines the gamepad rotation sensiblity.
  36293. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36294. */
  36295. gamepadAngularSensibility: number;
  36296. /**
  36297. * Defines the gamepad move sensiblity.
  36298. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36299. */
  36300. gamepadMoveSensibility: number;
  36301. private _onGamepadConnectedObserver;
  36302. private _onGamepadDisconnectedObserver;
  36303. private _cameraTransform;
  36304. private _deltaTransform;
  36305. private _vector3;
  36306. private _vector2;
  36307. /**
  36308. * Attach the input controls to a specific dom element to get the input from.
  36309. * @param element Defines the element the controls should be listened from
  36310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36311. */
  36312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36313. /**
  36314. * Detach the current controls from the specified dom element.
  36315. * @param element Defines the element to stop listening the inputs from
  36316. */
  36317. detachControl(element: Nullable<HTMLElement>): void;
  36318. /**
  36319. * Update the current camera state depending on the inputs that have been used this frame.
  36320. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36321. */
  36322. checkInputs(): void;
  36323. /**
  36324. * Gets the class name of the current intput.
  36325. * @returns the class name
  36326. */
  36327. getClassName(): string;
  36328. /**
  36329. * Get the friendly name associated with the input class.
  36330. * @returns the input friendly name
  36331. */
  36332. getSimpleName(): string;
  36333. }
  36334. }
  36335. declare module BABYLON {
  36336. /**
  36337. * Defines the potential axis of a Joystick
  36338. */
  36339. export enum JoystickAxis {
  36340. /** X axis */
  36341. X = 0,
  36342. /** Y axis */
  36343. Y = 1,
  36344. /** Z axis */
  36345. Z = 2
  36346. }
  36347. /**
  36348. * Class used to define virtual joystick (used in touch mode)
  36349. */
  36350. export class VirtualJoystick {
  36351. /**
  36352. * Gets or sets a boolean indicating that left and right values must be inverted
  36353. */
  36354. reverseLeftRight: boolean;
  36355. /**
  36356. * Gets or sets a boolean indicating that up and down values must be inverted
  36357. */
  36358. reverseUpDown: boolean;
  36359. /**
  36360. * Gets the offset value for the position (ie. the change of the position value)
  36361. */
  36362. deltaPosition: Vector3;
  36363. /**
  36364. * Gets a boolean indicating if the virtual joystick was pressed
  36365. */
  36366. pressed: boolean;
  36367. /**
  36368. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36369. */
  36370. static Canvas: Nullable<HTMLCanvasElement>;
  36371. private static _globalJoystickIndex;
  36372. private static vjCanvasContext;
  36373. private static vjCanvasWidth;
  36374. private static vjCanvasHeight;
  36375. private static halfWidth;
  36376. private _action;
  36377. private _axisTargetedByLeftAndRight;
  36378. private _axisTargetedByUpAndDown;
  36379. private _joystickSensibility;
  36380. private _inversedSensibility;
  36381. private _joystickPointerID;
  36382. private _joystickColor;
  36383. private _joystickPointerPos;
  36384. private _joystickPreviousPointerPos;
  36385. private _joystickPointerStartPos;
  36386. private _deltaJoystickVector;
  36387. private _leftJoystick;
  36388. private _touches;
  36389. private _onPointerDownHandlerRef;
  36390. private _onPointerMoveHandlerRef;
  36391. private _onPointerUpHandlerRef;
  36392. private _onResize;
  36393. /**
  36394. * Creates a new virtual joystick
  36395. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36396. */
  36397. constructor(leftJoystick?: boolean);
  36398. /**
  36399. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36400. * @param newJoystickSensibility defines the new sensibility
  36401. */
  36402. setJoystickSensibility(newJoystickSensibility: number): void;
  36403. private _onPointerDown;
  36404. private _onPointerMove;
  36405. private _onPointerUp;
  36406. /**
  36407. * Change the color of the virtual joystick
  36408. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36409. */
  36410. setJoystickColor(newColor: string): void;
  36411. /**
  36412. * Defines a callback to call when the joystick is touched
  36413. * @param action defines the callback
  36414. */
  36415. setActionOnTouch(action: () => any): void;
  36416. /**
  36417. * Defines which axis you'd like to control for left & right
  36418. * @param axis defines the axis to use
  36419. */
  36420. setAxisForLeftRight(axis: JoystickAxis): void;
  36421. /**
  36422. * Defines which axis you'd like to control for up & down
  36423. * @param axis defines the axis to use
  36424. */
  36425. setAxisForUpDown(axis: JoystickAxis): void;
  36426. private _drawVirtualJoystick;
  36427. /**
  36428. * Release internal HTML canvas
  36429. */
  36430. releaseCanvas(): void;
  36431. }
  36432. }
  36433. declare module BABYLON {
  36434. interface FreeCameraInputsManager {
  36435. /**
  36436. * Add virtual joystick input support to the input manager.
  36437. * @returns the current input manager
  36438. */
  36439. addVirtualJoystick(): FreeCameraInputsManager;
  36440. }
  36441. /**
  36442. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36444. */
  36445. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36446. /**
  36447. * Defines the camera the input is attached to.
  36448. */
  36449. camera: FreeCamera;
  36450. private _leftjoystick;
  36451. private _rightjoystick;
  36452. /**
  36453. * Gets the left stick of the virtual joystick.
  36454. * @returns The virtual Joystick
  36455. */
  36456. getLeftJoystick(): VirtualJoystick;
  36457. /**
  36458. * Gets the right stick of the virtual joystick.
  36459. * @returns The virtual Joystick
  36460. */
  36461. getRightJoystick(): VirtualJoystick;
  36462. /**
  36463. * Update the current camera state depending on the inputs that have been used this frame.
  36464. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36465. */
  36466. checkInputs(): void;
  36467. /**
  36468. * Attach the input controls to a specific dom element to get the input from.
  36469. * @param element Defines the element the controls should be listened from
  36470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36471. */
  36472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36473. /**
  36474. * Detach the current controls from the specified dom element.
  36475. * @param element Defines the element to stop listening the inputs from
  36476. */
  36477. detachControl(element: Nullable<HTMLElement>): void;
  36478. /**
  36479. * Gets the class name of the current intput.
  36480. * @returns the class name
  36481. */
  36482. getClassName(): string;
  36483. /**
  36484. * Get the friendly name associated with the input class.
  36485. * @returns the input friendly name
  36486. */
  36487. getSimpleName(): string;
  36488. }
  36489. }
  36490. declare module BABYLON {
  36491. /**
  36492. * This represents a FPS type of camera controlled by touch.
  36493. * This is like a universal camera minus the Gamepad controls.
  36494. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36495. */
  36496. export class TouchCamera extends FreeCamera {
  36497. /**
  36498. * Defines the touch sensibility for rotation.
  36499. * The higher the faster.
  36500. */
  36501. touchAngularSensibility: number;
  36502. /**
  36503. * Defines the touch sensibility for move.
  36504. * The higher the faster.
  36505. */
  36506. touchMoveSensibility: number;
  36507. /**
  36508. * Instantiates a new touch camera.
  36509. * This represents a FPS type of camera controlled by touch.
  36510. * This is like a universal camera minus the Gamepad controls.
  36511. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36512. * @param name Define the name of the camera in the scene
  36513. * @param position Define the start position of the camera in the scene
  36514. * @param scene Define the scene the camera belongs to
  36515. */
  36516. constructor(name: string, position: Vector3, scene: Scene);
  36517. /**
  36518. * Gets the current object class name.
  36519. * @return the class name
  36520. */
  36521. getClassName(): string;
  36522. /** @hidden */ setupInputs(): void;
  36523. }
  36524. }
  36525. declare module BABYLON {
  36526. /**
  36527. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36528. * being tilted forward or back and left or right.
  36529. */
  36530. export class DeviceOrientationCamera extends FreeCamera {
  36531. private _initialQuaternion;
  36532. private _quaternionCache;
  36533. private _tmpDragQuaternion;
  36534. /**
  36535. * Creates a new device orientation camera
  36536. * @param name The name of the camera
  36537. * @param position The start position camera
  36538. * @param scene The scene the camera belongs to
  36539. */
  36540. constructor(name: string, position: Vector3, scene: Scene);
  36541. /**
  36542. * @hidden
  36543. * Disabled pointer input on first orientation sensor update (Default: true)
  36544. */ disablePointerInputWhenUsingDeviceOrientation: boolean;
  36545. private _dragFactor;
  36546. /**
  36547. * Enabled turning on the y axis when the orientation sensor is active
  36548. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  36549. */
  36550. enableHorizontalDragging(dragFactor?: number): void;
  36551. /**
  36552. * Gets the current instance class name ("DeviceOrientationCamera").
  36553. * This helps avoiding instanceof at run time.
  36554. * @returns the class name
  36555. */
  36556. getClassName(): string;
  36557. /**
  36558. * @hidden
  36559. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36560. */ checkInputs(): void;
  36561. /**
  36562. * Reset the camera to its default orientation on the specified axis only.
  36563. * @param axis The axis to reset
  36564. */
  36565. resetToCurrentRotation(axis?: Axis): void;
  36566. }
  36567. }
  36568. declare module BABYLON {
  36569. /**
  36570. * 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,
  36571. * which still works and will still be found in many Playgrounds.
  36572. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36573. */
  36574. export class UniversalCamera extends TouchCamera {
  36575. /**
  36576. * Defines the gamepad rotation sensiblity.
  36577. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36578. */
  36579. gamepadAngularSensibility: number;
  36580. /**
  36581. * Defines the gamepad move sensiblity.
  36582. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36583. */
  36584. gamepadMoveSensibility: number;
  36585. /**
  36586. * 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,
  36587. * which still works and will still be found in many Playgrounds.
  36588. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36589. * @param name Define the name of the camera in the scene
  36590. * @param position Define the start position of the camera in the scene
  36591. * @param scene Define the scene the camera belongs to
  36592. */
  36593. constructor(name: string, position: Vector3, scene: Scene);
  36594. /**
  36595. * Gets the current object class name.
  36596. * @return the class name
  36597. */
  36598. getClassName(): string;
  36599. }
  36600. }
  36601. declare module BABYLON {
  36602. /**
  36603. * This represents a FPS type of camera. This is only here for back compat purpose.
  36604. * Please use the UniversalCamera instead as both are identical.
  36605. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36606. */
  36607. export class GamepadCamera extends UniversalCamera {
  36608. /**
  36609. * Instantiates a new Gamepad Camera
  36610. * This represents a FPS type of camera. This is only here for back compat purpose.
  36611. * Please use the UniversalCamera instead as both are identical.
  36612. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36613. * @param name Define the name of the camera in the scene
  36614. * @param position Define the start position of the camera in the scene
  36615. * @param scene Define the scene the camera belongs to
  36616. */
  36617. constructor(name: string, position: Vector3, scene: Scene);
  36618. /**
  36619. * Gets the current object class name.
  36620. * @return the class name
  36621. */
  36622. getClassName(): string;
  36623. }
  36624. }
  36625. declare module BABYLON {
  36626. /** @hidden */
  36627. export var passPixelShader: {
  36628. name: string;
  36629. shader: string;
  36630. };
  36631. }
  36632. declare module BABYLON {
  36633. /** @hidden */
  36634. export var passCubePixelShader: {
  36635. name: string;
  36636. shader: string;
  36637. };
  36638. }
  36639. declare module BABYLON {
  36640. /**
  36641. * PassPostProcess which produces an output the same as it's input
  36642. */
  36643. export class PassPostProcess extends PostProcess {
  36644. /**
  36645. * Creates the PassPostProcess
  36646. * @param name The name of the effect.
  36647. * @param options The required width/height ratio to downsize to before computing the render pass.
  36648. * @param camera The camera to apply the render pass to.
  36649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36650. * @param engine The engine which the post process will be applied. (default: current engine)
  36651. * @param reusable If the post process can be reused on the same frame. (default: false)
  36652. * @param textureType The type of texture to be used when performing the post processing.
  36653. * @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)
  36654. */
  36655. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36656. }
  36657. /**
  36658. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36659. */
  36660. export class PassCubePostProcess extends PostProcess {
  36661. private _face;
  36662. /**
  36663. * Gets or sets the cube face to display.
  36664. * * 0 is +X
  36665. * * 1 is -X
  36666. * * 2 is +Y
  36667. * * 3 is -Y
  36668. * * 4 is +Z
  36669. * * 5 is -Z
  36670. */
  36671. face: number;
  36672. /**
  36673. * Creates the PassCubePostProcess
  36674. * @param name The name of the effect.
  36675. * @param options The required width/height ratio to downsize to before computing the render pass.
  36676. * @param camera The camera to apply the render pass to.
  36677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36678. * @param engine The engine which the post process will be applied. (default: current engine)
  36679. * @param reusable If the post process can be reused on the same frame. (default: false)
  36680. * @param textureType The type of texture to be used when performing the post processing.
  36681. * @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)
  36682. */
  36683. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36684. }
  36685. }
  36686. declare module BABYLON {
  36687. /** @hidden */
  36688. export var anaglyphPixelShader: {
  36689. name: string;
  36690. shader: string;
  36691. };
  36692. }
  36693. declare module BABYLON {
  36694. /**
  36695. * Postprocess used to generate anaglyphic rendering
  36696. */
  36697. export class AnaglyphPostProcess extends PostProcess {
  36698. private _passedProcess;
  36699. /**
  36700. * Creates a new AnaglyphPostProcess
  36701. * @param name defines postprocess name
  36702. * @param options defines creation options or target ratio scale
  36703. * @param rigCameras defines cameras using this postprocess
  36704. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36705. * @param engine defines hosting engine
  36706. * @param reusable defines if the postprocess will be reused multiple times per frame
  36707. */
  36708. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36709. }
  36710. }
  36711. declare module BABYLON {
  36712. /**
  36713. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36714. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36715. */
  36716. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36717. /**
  36718. * Creates a new AnaglyphArcRotateCamera
  36719. * @param name defines camera name
  36720. * @param alpha defines alpha angle (in radians)
  36721. * @param beta defines beta angle (in radians)
  36722. * @param radius defines radius
  36723. * @param target defines camera target
  36724. * @param interaxialDistance defines distance between each color axis
  36725. * @param scene defines the hosting scene
  36726. */
  36727. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36728. /**
  36729. * Gets camera class name
  36730. * @returns AnaglyphArcRotateCamera
  36731. */
  36732. getClassName(): string;
  36733. }
  36734. }
  36735. declare module BABYLON {
  36736. /**
  36737. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36738. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36739. */
  36740. export class AnaglyphFreeCamera extends FreeCamera {
  36741. /**
  36742. * Creates a new AnaglyphFreeCamera
  36743. * @param name defines camera name
  36744. * @param position defines initial position
  36745. * @param interaxialDistance defines distance between each color axis
  36746. * @param scene defines the hosting scene
  36747. */
  36748. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36749. /**
  36750. * Gets camera class name
  36751. * @returns AnaglyphFreeCamera
  36752. */
  36753. getClassName(): string;
  36754. }
  36755. }
  36756. declare module BABYLON {
  36757. /**
  36758. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36759. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36760. */
  36761. export class AnaglyphGamepadCamera extends GamepadCamera {
  36762. /**
  36763. * Creates a new AnaglyphGamepadCamera
  36764. * @param name defines camera name
  36765. * @param position defines initial position
  36766. * @param interaxialDistance defines distance between each color axis
  36767. * @param scene defines the hosting scene
  36768. */
  36769. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36770. /**
  36771. * Gets camera class name
  36772. * @returns AnaglyphGamepadCamera
  36773. */
  36774. getClassName(): string;
  36775. }
  36776. }
  36777. declare module BABYLON {
  36778. /**
  36779. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36780. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36781. */
  36782. export class AnaglyphUniversalCamera extends UniversalCamera {
  36783. /**
  36784. * Creates a new AnaglyphUniversalCamera
  36785. * @param name defines camera name
  36786. * @param position defines initial position
  36787. * @param interaxialDistance defines distance between each color axis
  36788. * @param scene defines the hosting scene
  36789. */
  36790. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36791. /**
  36792. * Gets camera class name
  36793. * @returns AnaglyphUniversalCamera
  36794. */
  36795. getClassName(): string;
  36796. }
  36797. }
  36798. declare module BABYLON {
  36799. /** @hidden */
  36800. export var stereoscopicInterlacePixelShader: {
  36801. name: string;
  36802. shader: string;
  36803. };
  36804. }
  36805. declare module BABYLON {
  36806. /**
  36807. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36808. */
  36809. export class StereoscopicInterlacePostProcess extends PostProcess {
  36810. private _stepSize;
  36811. private _passedProcess;
  36812. /**
  36813. * Initializes a StereoscopicInterlacePostProcess
  36814. * @param name The name of the effect.
  36815. * @param rigCameras The rig cameras to be appled to the post process
  36816. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36818. * @param engine The engine which the post process will be applied. (default: current engine)
  36819. * @param reusable If the post process can be reused on the same frame. (default: false)
  36820. */
  36821. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36822. }
  36823. }
  36824. declare module BABYLON {
  36825. /**
  36826. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  36827. * @see http://doc.babylonjs.com/features/cameras
  36828. */
  36829. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  36830. /**
  36831. * Creates a new StereoscopicArcRotateCamera
  36832. * @param name defines camera name
  36833. * @param alpha defines alpha angle (in radians)
  36834. * @param beta defines beta angle (in radians)
  36835. * @param radius defines radius
  36836. * @param target defines camera target
  36837. * @param interaxialDistance defines distance between each color axis
  36838. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36839. * @param scene defines the hosting scene
  36840. */
  36841. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36842. /**
  36843. * Gets camera class name
  36844. * @returns StereoscopicArcRotateCamera
  36845. */
  36846. getClassName(): string;
  36847. }
  36848. }
  36849. declare module BABYLON {
  36850. /**
  36851. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  36852. * @see http://doc.babylonjs.com/features/cameras
  36853. */
  36854. export class StereoscopicFreeCamera extends FreeCamera {
  36855. /**
  36856. * Creates a new StereoscopicFreeCamera
  36857. * @param name defines camera name
  36858. * @param position defines initial position
  36859. * @param interaxialDistance defines distance between each color axis
  36860. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36861. * @param scene defines the hosting scene
  36862. */
  36863. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36864. /**
  36865. * Gets camera class name
  36866. * @returns StereoscopicFreeCamera
  36867. */
  36868. getClassName(): string;
  36869. }
  36870. }
  36871. declare module BABYLON {
  36872. /**
  36873. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  36874. * @see http://doc.babylonjs.com/features/cameras
  36875. */
  36876. export class StereoscopicGamepadCamera extends GamepadCamera {
  36877. /**
  36878. * Creates a new StereoscopicGamepadCamera
  36879. * @param name defines camera name
  36880. * @param position defines initial position
  36881. * @param interaxialDistance defines distance between each color axis
  36882. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36883. * @param scene defines the hosting scene
  36884. */
  36885. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36886. /**
  36887. * Gets camera class name
  36888. * @returns StereoscopicGamepadCamera
  36889. */
  36890. getClassName(): string;
  36891. }
  36892. }
  36893. declare module BABYLON {
  36894. /**
  36895. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  36896. * @see http://doc.babylonjs.com/features/cameras
  36897. */
  36898. export class StereoscopicUniversalCamera extends UniversalCamera {
  36899. /**
  36900. * Creates a new StereoscopicUniversalCamera
  36901. * @param name defines camera name
  36902. * @param position defines initial position
  36903. * @param interaxialDistance defines distance between each color axis
  36904. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36905. * @param scene defines the hosting scene
  36906. */
  36907. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36908. /**
  36909. * Gets camera class name
  36910. * @returns StereoscopicUniversalCamera
  36911. */
  36912. getClassName(): string;
  36913. }
  36914. }
  36915. declare module BABYLON {
  36916. /**
  36917. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  36918. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36919. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36920. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36921. */
  36922. export class VirtualJoysticksCamera extends FreeCamera {
  36923. /**
  36924. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  36925. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36926. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36927. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36928. * @param name Define the name of the camera in the scene
  36929. * @param position Define the start position of the camera in the scene
  36930. * @param scene Define the scene the camera belongs to
  36931. */
  36932. constructor(name: string, position: Vector3, scene: Scene);
  36933. /**
  36934. * Gets the current object class name.
  36935. * @return the class name
  36936. */
  36937. getClassName(): string;
  36938. }
  36939. }
  36940. declare module BABYLON {
  36941. /**
  36942. * This represents all the required metrics to create a VR camera.
  36943. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  36944. */
  36945. export class VRCameraMetrics {
  36946. /**
  36947. * Define the horizontal resolution off the screen.
  36948. */
  36949. hResolution: number;
  36950. /**
  36951. * Define the vertical resolution off the screen.
  36952. */
  36953. vResolution: number;
  36954. /**
  36955. * Define the horizontal screen size.
  36956. */
  36957. hScreenSize: number;
  36958. /**
  36959. * Define the vertical screen size.
  36960. */
  36961. vScreenSize: number;
  36962. /**
  36963. * Define the vertical screen center position.
  36964. */
  36965. vScreenCenter: number;
  36966. /**
  36967. * Define the distance of the eyes to the screen.
  36968. */
  36969. eyeToScreenDistance: number;
  36970. /**
  36971. * Define the distance between both lenses
  36972. */
  36973. lensSeparationDistance: number;
  36974. /**
  36975. * Define the distance between both viewer's eyes.
  36976. */
  36977. interpupillaryDistance: number;
  36978. /**
  36979. * Define the distortion factor of the VR postprocess.
  36980. * Please, touch with care.
  36981. */
  36982. distortionK: number[];
  36983. /**
  36984. * Define the chromatic aberration correction factors for the VR post process.
  36985. */
  36986. chromaAbCorrection: number[];
  36987. /**
  36988. * Define the scale factor of the post process.
  36989. * The smaller the better but the slower.
  36990. */
  36991. postProcessScaleFactor: number;
  36992. /**
  36993. * Define an offset for the lens center.
  36994. */
  36995. lensCenterOffset: number;
  36996. /**
  36997. * Define if the current vr camera should compensate the distortion of the lense or not.
  36998. */
  36999. compensateDistortion: boolean;
  37000. /**
  37001. * Defines if multiview should be enabled when rendering (Default: false)
  37002. */
  37003. multiviewEnabled: boolean;
  37004. /**
  37005. * Gets the rendering aspect ratio based on the provided resolutions.
  37006. */
  37007. readonly aspectRatio: number;
  37008. /**
  37009. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37010. */
  37011. readonly aspectRatioFov: number;
  37012. /**
  37013. * @hidden
  37014. */
  37015. readonly leftHMatrix: Matrix;
  37016. /**
  37017. * @hidden
  37018. */
  37019. readonly rightHMatrix: Matrix;
  37020. /**
  37021. * @hidden
  37022. */
  37023. readonly leftPreViewMatrix: Matrix;
  37024. /**
  37025. * @hidden
  37026. */
  37027. readonly rightPreViewMatrix: Matrix;
  37028. /**
  37029. * Get the default VRMetrics based on the most generic setup.
  37030. * @returns the default vr metrics
  37031. */
  37032. static GetDefault(): VRCameraMetrics;
  37033. }
  37034. }
  37035. declare module BABYLON {
  37036. /** @hidden */
  37037. export var vrDistortionCorrectionPixelShader: {
  37038. name: string;
  37039. shader: string;
  37040. };
  37041. }
  37042. declare module BABYLON {
  37043. /**
  37044. * VRDistortionCorrectionPostProcess used for mobile VR
  37045. */
  37046. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37047. private _isRightEye;
  37048. private _distortionFactors;
  37049. private _postProcessScaleFactor;
  37050. private _lensCenterOffset;
  37051. private _scaleIn;
  37052. private _scaleFactor;
  37053. private _lensCenter;
  37054. /**
  37055. * Initializes the VRDistortionCorrectionPostProcess
  37056. * @param name The name of the effect.
  37057. * @param camera The camera to apply the render pass to.
  37058. * @param isRightEye If this is for the right eye distortion
  37059. * @param vrMetrics All the required metrics for the VR camera
  37060. */
  37061. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37062. }
  37063. }
  37064. declare module BABYLON {
  37065. /**
  37066. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37067. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37068. */
  37069. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37070. /**
  37071. * Creates a new VRDeviceOrientationArcRotateCamera
  37072. * @param name defines camera name
  37073. * @param alpha defines the camera rotation along the logitudinal axis
  37074. * @param beta defines the camera rotation along the latitudinal axis
  37075. * @param radius defines the camera distance from its target
  37076. * @param target defines the camera target
  37077. * @param scene defines the scene the camera belongs to
  37078. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37079. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37080. */
  37081. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37082. /**
  37083. * Gets camera class name
  37084. * @returns VRDeviceOrientationArcRotateCamera
  37085. */
  37086. getClassName(): string;
  37087. }
  37088. }
  37089. declare module BABYLON {
  37090. /**
  37091. * Camera used to simulate VR rendering (based on FreeCamera)
  37092. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37093. */
  37094. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37095. /**
  37096. * Creates a new VRDeviceOrientationFreeCamera
  37097. * @param name defines camera name
  37098. * @param position defines the start position of the camera
  37099. * @param scene defines the scene the camera belongs to
  37100. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37101. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37102. */
  37103. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37104. /**
  37105. * Gets camera class name
  37106. * @returns VRDeviceOrientationFreeCamera
  37107. */
  37108. getClassName(): string;
  37109. }
  37110. }
  37111. declare module BABYLON {
  37112. /**
  37113. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37114. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37115. */
  37116. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37117. /**
  37118. * Creates a new VRDeviceOrientationGamepadCamera
  37119. * @param name defines camera name
  37120. * @param position defines the start position of the camera
  37121. * @param scene defines the scene the camera belongs to
  37122. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37123. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37124. */
  37125. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37126. /**
  37127. * Gets camera class name
  37128. * @returns VRDeviceOrientationGamepadCamera
  37129. */
  37130. getClassName(): string;
  37131. }
  37132. }
  37133. declare module BABYLON {
  37134. /**
  37135. * Defines supported buttons for XBox360 compatible gamepads
  37136. */
  37137. export enum Xbox360Button {
  37138. /** A */
  37139. A = 0,
  37140. /** B */
  37141. B = 1,
  37142. /** X */
  37143. X = 2,
  37144. /** Y */
  37145. Y = 3,
  37146. /** Start */
  37147. Start = 4,
  37148. /** Back */
  37149. Back = 5,
  37150. /** Left button */
  37151. LB = 6,
  37152. /** Right button */
  37153. RB = 7,
  37154. /** Left stick */
  37155. LeftStick = 8,
  37156. /** Right stick */
  37157. RightStick = 9
  37158. }
  37159. /** Defines values for XBox360 DPad */
  37160. export enum Xbox360Dpad {
  37161. /** Up */
  37162. Up = 0,
  37163. /** Down */
  37164. Down = 1,
  37165. /** Left */
  37166. Left = 2,
  37167. /** Right */
  37168. Right = 3
  37169. }
  37170. /**
  37171. * Defines a XBox360 gamepad
  37172. */
  37173. export class Xbox360Pad extends Gamepad {
  37174. private _leftTrigger;
  37175. private _rightTrigger;
  37176. private _onlefttriggerchanged;
  37177. private _onrighttriggerchanged;
  37178. private _onbuttondown;
  37179. private _onbuttonup;
  37180. private _ondpaddown;
  37181. private _ondpadup;
  37182. /** Observable raised when a button is pressed */
  37183. onButtonDownObservable: Observable<Xbox360Button>;
  37184. /** Observable raised when a button is released */
  37185. onButtonUpObservable: Observable<Xbox360Button>;
  37186. /** Observable raised when a pad is pressed */
  37187. onPadDownObservable: Observable<Xbox360Dpad>;
  37188. /** Observable raised when a pad is released */
  37189. onPadUpObservable: Observable<Xbox360Dpad>;
  37190. private _buttonA;
  37191. private _buttonB;
  37192. private _buttonX;
  37193. private _buttonY;
  37194. private _buttonBack;
  37195. private _buttonStart;
  37196. private _buttonLB;
  37197. private _buttonRB;
  37198. private _buttonLeftStick;
  37199. private _buttonRightStick;
  37200. private _dPadUp;
  37201. private _dPadDown;
  37202. private _dPadLeft;
  37203. private _dPadRight;
  37204. private _isXboxOnePad;
  37205. /**
  37206. * Creates a new XBox360 gamepad object
  37207. * @param id defines the id of this gamepad
  37208. * @param index defines its index
  37209. * @param gamepad defines the internal HTML gamepad object
  37210. * @param xboxOne defines if it is a XBox One gamepad
  37211. */
  37212. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37213. /**
  37214. * Defines the callback to call when left trigger is pressed
  37215. * @param callback defines the callback to use
  37216. */
  37217. onlefttriggerchanged(callback: (value: number) => void): void;
  37218. /**
  37219. * Defines the callback to call when right trigger is pressed
  37220. * @param callback defines the callback to use
  37221. */
  37222. onrighttriggerchanged(callback: (value: number) => void): void;
  37223. /**
  37224. * Gets the left trigger value
  37225. */
  37226. /**
  37227. * Sets the left trigger value
  37228. */
  37229. leftTrigger: number;
  37230. /**
  37231. * Gets the right trigger value
  37232. */
  37233. /**
  37234. * Sets the right trigger value
  37235. */
  37236. rightTrigger: number;
  37237. /**
  37238. * Defines the callback to call when a button is pressed
  37239. * @param callback defines the callback to use
  37240. */
  37241. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37242. /**
  37243. * Defines the callback to call when a button is released
  37244. * @param callback defines the callback to use
  37245. */
  37246. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37247. /**
  37248. * Defines the callback to call when a pad is pressed
  37249. * @param callback defines the callback to use
  37250. */
  37251. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37252. /**
  37253. * Defines the callback to call when a pad is released
  37254. * @param callback defines the callback to use
  37255. */
  37256. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37257. private _setButtonValue;
  37258. private _setDPadValue;
  37259. /**
  37260. * Gets the value of the `A` button
  37261. */
  37262. /**
  37263. * Sets the value of the `A` button
  37264. */
  37265. buttonA: number;
  37266. /**
  37267. * Gets the value of the `B` button
  37268. */
  37269. /**
  37270. * Sets the value of the `B` button
  37271. */
  37272. buttonB: number;
  37273. /**
  37274. * Gets the value of the `X` button
  37275. */
  37276. /**
  37277. * Sets the value of the `X` button
  37278. */
  37279. buttonX: number;
  37280. /**
  37281. * Gets the value of the `Y` button
  37282. */
  37283. /**
  37284. * Sets the value of the `Y` button
  37285. */
  37286. buttonY: number;
  37287. /**
  37288. * Gets the value of the `Start` button
  37289. */
  37290. /**
  37291. * Sets the value of the `Start` button
  37292. */
  37293. buttonStart: number;
  37294. /**
  37295. * Gets the value of the `Back` button
  37296. */
  37297. /**
  37298. * Sets the value of the `Back` button
  37299. */
  37300. buttonBack: number;
  37301. /**
  37302. * Gets the value of the `Left` button
  37303. */
  37304. /**
  37305. * Sets the value of the `Left` button
  37306. */
  37307. buttonLB: number;
  37308. /**
  37309. * Gets the value of the `Right` button
  37310. */
  37311. /**
  37312. * Sets the value of the `Right` button
  37313. */
  37314. buttonRB: number;
  37315. /**
  37316. * Gets the value of the Left joystick
  37317. */
  37318. /**
  37319. * Sets the value of the Left joystick
  37320. */
  37321. buttonLeftStick: number;
  37322. /**
  37323. * Gets the value of the Right joystick
  37324. */
  37325. /**
  37326. * Sets the value of the Right joystick
  37327. */
  37328. buttonRightStick: number;
  37329. /**
  37330. * Gets the value of D-pad up
  37331. */
  37332. /**
  37333. * Sets the value of D-pad up
  37334. */
  37335. dPadUp: number;
  37336. /**
  37337. * Gets the value of D-pad down
  37338. */
  37339. /**
  37340. * Sets the value of D-pad down
  37341. */
  37342. dPadDown: number;
  37343. /**
  37344. * Gets the value of D-pad left
  37345. */
  37346. /**
  37347. * Sets the value of D-pad left
  37348. */
  37349. dPadLeft: number;
  37350. /**
  37351. * Gets the value of D-pad right
  37352. */
  37353. /**
  37354. * Sets the value of D-pad right
  37355. */
  37356. dPadRight: number;
  37357. /**
  37358. * Force the gamepad to synchronize with device values
  37359. */
  37360. update(): void;
  37361. /**
  37362. * Disposes the gamepad
  37363. */
  37364. dispose(): void;
  37365. }
  37366. }
  37367. declare module BABYLON {
  37368. /**
  37369. * Base class of materials working in push mode in babylon JS
  37370. * @hidden
  37371. */
  37372. export class PushMaterial extends Material {
  37373. protected _activeEffect: Effect;
  37374. protected _normalMatrix: Matrix;
  37375. /**
  37376. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37377. * This means that the material can keep using a previous shader while a new one is being compiled.
  37378. * This is mostly used when shader parallel compilation is supported (true by default)
  37379. */
  37380. allowShaderHotSwapping: boolean;
  37381. constructor(name: string, scene: Scene);
  37382. getEffect(): Effect;
  37383. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37384. /**
  37385. * Binds the given world matrix to the active effect
  37386. *
  37387. * @param world the matrix to bind
  37388. */
  37389. bindOnlyWorldMatrix(world: Matrix): void;
  37390. /**
  37391. * Binds the given normal matrix to the active effect
  37392. *
  37393. * @param normalMatrix the matrix to bind
  37394. */
  37395. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37396. bind(world: Matrix, mesh?: Mesh): void;
  37397. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37398. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37399. }
  37400. }
  37401. declare module BABYLON {
  37402. /**
  37403. * This groups all the flags used to control the materials channel.
  37404. */
  37405. export class MaterialFlags {
  37406. private static _DiffuseTextureEnabled;
  37407. /**
  37408. * Are diffuse textures enabled in the application.
  37409. */
  37410. static DiffuseTextureEnabled: boolean;
  37411. private static _AmbientTextureEnabled;
  37412. /**
  37413. * Are ambient textures enabled in the application.
  37414. */
  37415. static AmbientTextureEnabled: boolean;
  37416. private static _OpacityTextureEnabled;
  37417. /**
  37418. * Are opacity textures enabled in the application.
  37419. */
  37420. static OpacityTextureEnabled: boolean;
  37421. private static _ReflectionTextureEnabled;
  37422. /**
  37423. * Are reflection textures enabled in the application.
  37424. */
  37425. static ReflectionTextureEnabled: boolean;
  37426. private static _EmissiveTextureEnabled;
  37427. /**
  37428. * Are emissive textures enabled in the application.
  37429. */
  37430. static EmissiveTextureEnabled: boolean;
  37431. private static _SpecularTextureEnabled;
  37432. /**
  37433. * Are specular textures enabled in the application.
  37434. */
  37435. static SpecularTextureEnabled: boolean;
  37436. private static _BumpTextureEnabled;
  37437. /**
  37438. * Are bump textures enabled in the application.
  37439. */
  37440. static BumpTextureEnabled: boolean;
  37441. private static _LightmapTextureEnabled;
  37442. /**
  37443. * Are lightmap textures enabled in the application.
  37444. */
  37445. static LightmapTextureEnabled: boolean;
  37446. private static _RefractionTextureEnabled;
  37447. /**
  37448. * Are refraction textures enabled in the application.
  37449. */
  37450. static RefractionTextureEnabled: boolean;
  37451. private static _ColorGradingTextureEnabled;
  37452. /**
  37453. * Are color grading textures enabled in the application.
  37454. */
  37455. static ColorGradingTextureEnabled: boolean;
  37456. private static _FresnelEnabled;
  37457. /**
  37458. * Are fresnels enabled in the application.
  37459. */
  37460. static FresnelEnabled: boolean;
  37461. private static _ClearCoatTextureEnabled;
  37462. /**
  37463. * Are clear coat textures enabled in the application.
  37464. */
  37465. static ClearCoatTextureEnabled: boolean;
  37466. private static _ClearCoatBumpTextureEnabled;
  37467. /**
  37468. * Are clear coat bump textures enabled in the application.
  37469. */
  37470. static ClearCoatBumpTextureEnabled: boolean;
  37471. private static _ClearCoatTintTextureEnabled;
  37472. /**
  37473. * Are clear coat tint textures enabled in the application.
  37474. */
  37475. static ClearCoatTintTextureEnabled: boolean;
  37476. private static _SheenTextureEnabled;
  37477. /**
  37478. * Are sheen textures enabled in the application.
  37479. */
  37480. static SheenTextureEnabled: boolean;
  37481. private static _AnisotropicTextureEnabled;
  37482. /**
  37483. * Are anisotropic textures enabled in the application.
  37484. */
  37485. static AnisotropicTextureEnabled: boolean;
  37486. private static _ThicknessTextureEnabled;
  37487. /**
  37488. * Are thickness textures enabled in the application.
  37489. */
  37490. static ThicknessTextureEnabled: boolean;
  37491. }
  37492. }
  37493. declare module BABYLON {
  37494. /** @hidden */
  37495. export var defaultFragmentDeclaration: {
  37496. name: string;
  37497. shader: string;
  37498. };
  37499. }
  37500. declare module BABYLON {
  37501. /** @hidden */
  37502. export var defaultUboDeclaration: {
  37503. name: string;
  37504. shader: string;
  37505. };
  37506. }
  37507. declare module BABYLON {
  37508. /** @hidden */
  37509. export var lightFragmentDeclaration: {
  37510. name: string;
  37511. shader: string;
  37512. };
  37513. }
  37514. declare module BABYLON {
  37515. /** @hidden */
  37516. export var lightUboDeclaration: {
  37517. name: string;
  37518. shader: string;
  37519. };
  37520. }
  37521. declare module BABYLON {
  37522. /** @hidden */
  37523. export var lightsFragmentFunctions: {
  37524. name: string;
  37525. shader: string;
  37526. };
  37527. }
  37528. declare module BABYLON {
  37529. /** @hidden */
  37530. export var shadowsFragmentFunctions: {
  37531. name: string;
  37532. shader: string;
  37533. };
  37534. }
  37535. declare module BABYLON {
  37536. /** @hidden */
  37537. export var fresnelFunction: {
  37538. name: string;
  37539. shader: string;
  37540. };
  37541. }
  37542. declare module BABYLON {
  37543. /** @hidden */
  37544. export var reflectionFunction: {
  37545. name: string;
  37546. shader: string;
  37547. };
  37548. }
  37549. declare module BABYLON {
  37550. /** @hidden */
  37551. export var bumpFragmentFunctions: {
  37552. name: string;
  37553. shader: string;
  37554. };
  37555. }
  37556. declare module BABYLON {
  37557. /** @hidden */
  37558. export var logDepthDeclaration: {
  37559. name: string;
  37560. shader: string;
  37561. };
  37562. }
  37563. declare module BABYLON {
  37564. /** @hidden */
  37565. export var bumpFragment: {
  37566. name: string;
  37567. shader: string;
  37568. };
  37569. }
  37570. declare module BABYLON {
  37571. /** @hidden */
  37572. export var depthPrePass: {
  37573. name: string;
  37574. shader: string;
  37575. };
  37576. }
  37577. declare module BABYLON {
  37578. /** @hidden */
  37579. export var lightFragment: {
  37580. name: string;
  37581. shader: string;
  37582. };
  37583. }
  37584. declare module BABYLON {
  37585. /** @hidden */
  37586. export var logDepthFragment: {
  37587. name: string;
  37588. shader: string;
  37589. };
  37590. }
  37591. declare module BABYLON {
  37592. /** @hidden */
  37593. export var defaultPixelShader: {
  37594. name: string;
  37595. shader: string;
  37596. };
  37597. }
  37598. declare module BABYLON {
  37599. /** @hidden */
  37600. export var defaultVertexDeclaration: {
  37601. name: string;
  37602. shader: string;
  37603. };
  37604. }
  37605. declare module BABYLON {
  37606. /** @hidden */
  37607. export var bumpVertexDeclaration: {
  37608. name: string;
  37609. shader: string;
  37610. };
  37611. }
  37612. declare module BABYLON {
  37613. /** @hidden */
  37614. export var bumpVertex: {
  37615. name: string;
  37616. shader: string;
  37617. };
  37618. }
  37619. declare module BABYLON {
  37620. /** @hidden */
  37621. export var fogVertex: {
  37622. name: string;
  37623. shader: string;
  37624. };
  37625. }
  37626. declare module BABYLON {
  37627. /** @hidden */
  37628. export var shadowsVertex: {
  37629. name: string;
  37630. shader: string;
  37631. };
  37632. }
  37633. declare module BABYLON {
  37634. /** @hidden */
  37635. export var pointCloudVertex: {
  37636. name: string;
  37637. shader: string;
  37638. };
  37639. }
  37640. declare module BABYLON {
  37641. /** @hidden */
  37642. export var logDepthVertex: {
  37643. name: string;
  37644. shader: string;
  37645. };
  37646. }
  37647. declare module BABYLON {
  37648. /** @hidden */
  37649. export var defaultVertexShader: {
  37650. name: string;
  37651. shader: string;
  37652. };
  37653. }
  37654. declare module BABYLON {
  37655. /** @hidden */
  37656. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37657. MAINUV1: boolean;
  37658. MAINUV2: boolean;
  37659. DIFFUSE: boolean;
  37660. DIFFUSEDIRECTUV: number;
  37661. AMBIENT: boolean;
  37662. AMBIENTDIRECTUV: number;
  37663. OPACITY: boolean;
  37664. OPACITYDIRECTUV: number;
  37665. OPACITYRGB: boolean;
  37666. REFLECTION: boolean;
  37667. EMISSIVE: boolean;
  37668. EMISSIVEDIRECTUV: number;
  37669. SPECULAR: boolean;
  37670. SPECULARDIRECTUV: number;
  37671. BUMP: boolean;
  37672. BUMPDIRECTUV: number;
  37673. PARALLAX: boolean;
  37674. PARALLAXOCCLUSION: boolean;
  37675. SPECULAROVERALPHA: boolean;
  37676. CLIPPLANE: boolean;
  37677. CLIPPLANE2: boolean;
  37678. CLIPPLANE3: boolean;
  37679. CLIPPLANE4: boolean;
  37680. ALPHATEST: boolean;
  37681. DEPTHPREPASS: boolean;
  37682. ALPHAFROMDIFFUSE: boolean;
  37683. POINTSIZE: boolean;
  37684. FOG: boolean;
  37685. SPECULARTERM: boolean;
  37686. DIFFUSEFRESNEL: boolean;
  37687. OPACITYFRESNEL: boolean;
  37688. REFLECTIONFRESNEL: boolean;
  37689. REFRACTIONFRESNEL: boolean;
  37690. EMISSIVEFRESNEL: boolean;
  37691. FRESNEL: boolean;
  37692. NORMAL: boolean;
  37693. UV1: boolean;
  37694. UV2: boolean;
  37695. VERTEXCOLOR: boolean;
  37696. VERTEXALPHA: boolean;
  37697. NUM_BONE_INFLUENCERS: number;
  37698. BonesPerMesh: number;
  37699. BONETEXTURE: boolean;
  37700. INSTANCES: boolean;
  37701. GLOSSINESS: boolean;
  37702. ROUGHNESS: boolean;
  37703. EMISSIVEASILLUMINATION: boolean;
  37704. LINKEMISSIVEWITHDIFFUSE: boolean;
  37705. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37706. LIGHTMAP: boolean;
  37707. LIGHTMAPDIRECTUV: number;
  37708. OBJECTSPACE_NORMALMAP: boolean;
  37709. USELIGHTMAPASSHADOWMAP: boolean;
  37710. REFLECTIONMAP_3D: boolean;
  37711. REFLECTIONMAP_SPHERICAL: boolean;
  37712. REFLECTIONMAP_PLANAR: boolean;
  37713. REFLECTIONMAP_CUBIC: boolean;
  37714. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37715. REFLECTIONMAP_PROJECTION: boolean;
  37716. REFLECTIONMAP_SKYBOX: boolean;
  37717. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37718. REFLECTIONMAP_EXPLICIT: boolean;
  37719. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37720. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37721. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37722. INVERTCUBICMAP: boolean;
  37723. LOGARITHMICDEPTH: boolean;
  37724. REFRACTION: boolean;
  37725. REFRACTIONMAP_3D: boolean;
  37726. REFLECTIONOVERALPHA: boolean;
  37727. TWOSIDEDLIGHTING: boolean;
  37728. SHADOWFLOAT: boolean;
  37729. MORPHTARGETS: boolean;
  37730. MORPHTARGETS_NORMAL: boolean;
  37731. MORPHTARGETS_TANGENT: boolean;
  37732. NUM_MORPH_INFLUENCERS: number;
  37733. NONUNIFORMSCALING: boolean;
  37734. PREMULTIPLYALPHA: boolean;
  37735. IMAGEPROCESSING: boolean;
  37736. VIGNETTE: boolean;
  37737. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37738. VIGNETTEBLENDMODEOPAQUE: boolean;
  37739. TONEMAPPING: boolean;
  37740. TONEMAPPING_ACES: boolean;
  37741. CONTRAST: boolean;
  37742. COLORCURVES: boolean;
  37743. COLORGRADING: boolean;
  37744. COLORGRADING3D: boolean;
  37745. SAMPLER3DGREENDEPTH: boolean;
  37746. SAMPLER3DBGRMAP: boolean;
  37747. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37748. MULTIVIEW: boolean;
  37749. /**
  37750. * If the reflection texture on this material is in linear color space
  37751. * @hidden
  37752. */
  37753. IS_REFLECTION_LINEAR: boolean;
  37754. /**
  37755. * If the refraction texture on this material is in linear color space
  37756. * @hidden
  37757. */
  37758. IS_REFRACTION_LINEAR: boolean;
  37759. EXPOSURE: boolean;
  37760. constructor();
  37761. setReflectionMode(modeToEnable: string): void;
  37762. }
  37763. /**
  37764. * This is the default material used in Babylon. It is the best trade off between quality
  37765. * and performances.
  37766. * @see http://doc.babylonjs.com/babylon101/materials
  37767. */
  37768. export class StandardMaterial extends PushMaterial {
  37769. private _diffuseTexture;
  37770. /**
  37771. * The basic texture of the material as viewed under a light.
  37772. */
  37773. diffuseTexture: Nullable<BaseTexture>;
  37774. private _ambientTexture;
  37775. /**
  37776. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37777. */
  37778. ambientTexture: Nullable<BaseTexture>;
  37779. private _opacityTexture;
  37780. /**
  37781. * Define the transparency of the material from a texture.
  37782. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37783. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37784. */
  37785. opacityTexture: Nullable<BaseTexture>;
  37786. private _reflectionTexture;
  37787. /**
  37788. * Define the texture used to display the reflection.
  37789. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37790. */
  37791. reflectionTexture: Nullable<BaseTexture>;
  37792. private _emissiveTexture;
  37793. /**
  37794. * Define texture of the material as if self lit.
  37795. * This will be mixed in the final result even in the absence of light.
  37796. */
  37797. emissiveTexture: Nullable<BaseTexture>;
  37798. private _specularTexture;
  37799. /**
  37800. * Define how the color and intensity of the highlight given by the light in the material.
  37801. */
  37802. specularTexture: Nullable<BaseTexture>;
  37803. private _bumpTexture;
  37804. /**
  37805. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  37806. * 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.
  37807. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  37808. */
  37809. bumpTexture: Nullable<BaseTexture>;
  37810. private _lightmapTexture;
  37811. /**
  37812. * Complex lighting can be computationally expensive to compute at runtime.
  37813. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  37814. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  37815. */
  37816. lightmapTexture: Nullable<BaseTexture>;
  37817. private _refractionTexture;
  37818. /**
  37819. * Define the texture used to display the refraction.
  37820. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37821. */
  37822. refractionTexture: Nullable<BaseTexture>;
  37823. /**
  37824. * The color of the material lit by the environmental background lighting.
  37825. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  37826. */
  37827. ambientColor: Color3;
  37828. /**
  37829. * The basic color of the material as viewed under a light.
  37830. */
  37831. diffuseColor: Color3;
  37832. /**
  37833. * Define how the color and intensity of the highlight given by the light in the material.
  37834. */
  37835. specularColor: Color3;
  37836. /**
  37837. * Define the color of the material as if self lit.
  37838. * This will be mixed in the final result even in the absence of light.
  37839. */
  37840. emissiveColor: Color3;
  37841. /**
  37842. * Defines how sharp are the highlights in the material.
  37843. * The bigger the value the sharper giving a more glossy feeling to the result.
  37844. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  37845. */
  37846. specularPower: number;
  37847. private _useAlphaFromDiffuseTexture;
  37848. /**
  37849. * Does the transparency come from the diffuse texture alpha channel.
  37850. */
  37851. useAlphaFromDiffuseTexture: boolean;
  37852. private _useEmissiveAsIllumination;
  37853. /**
  37854. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  37855. */
  37856. useEmissiveAsIllumination: boolean;
  37857. private _linkEmissiveWithDiffuse;
  37858. /**
  37859. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  37860. * the emissive level when the final color is close to one.
  37861. */
  37862. linkEmissiveWithDiffuse: boolean;
  37863. private _useSpecularOverAlpha;
  37864. /**
  37865. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  37866. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  37867. */
  37868. useSpecularOverAlpha: boolean;
  37869. private _useReflectionOverAlpha;
  37870. /**
  37871. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  37872. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  37873. */
  37874. useReflectionOverAlpha: boolean;
  37875. private _disableLighting;
  37876. /**
  37877. * Does lights from the scene impacts this material.
  37878. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  37879. */
  37880. disableLighting: boolean;
  37881. private _useObjectSpaceNormalMap;
  37882. /**
  37883. * Allows using an object space normal map (instead of tangent space).
  37884. */
  37885. useObjectSpaceNormalMap: boolean;
  37886. private _useParallax;
  37887. /**
  37888. * Is parallax enabled or not.
  37889. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37890. */
  37891. useParallax: boolean;
  37892. private _useParallaxOcclusion;
  37893. /**
  37894. * Is parallax occlusion enabled or not.
  37895. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  37896. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37897. */
  37898. useParallaxOcclusion: boolean;
  37899. /**
  37900. * 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.
  37901. */
  37902. parallaxScaleBias: number;
  37903. private _roughness;
  37904. /**
  37905. * Helps to define how blurry the reflections should appears in the material.
  37906. */
  37907. roughness: number;
  37908. /**
  37909. * In case of refraction, define the value of the indice of refraction.
  37910. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37911. */
  37912. indexOfRefraction: number;
  37913. /**
  37914. * Invert the refraction texture alongside the y axis.
  37915. * It can be useful with procedural textures or probe for instance.
  37916. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37917. */
  37918. invertRefractionY: boolean;
  37919. /**
  37920. * Defines the alpha limits in alpha test mode.
  37921. */
  37922. alphaCutOff: number;
  37923. private _useLightmapAsShadowmap;
  37924. /**
  37925. * In case of light mapping, define whether the map contains light or shadow informations.
  37926. */
  37927. useLightmapAsShadowmap: boolean;
  37928. private _diffuseFresnelParameters;
  37929. /**
  37930. * Define the diffuse fresnel parameters of the material.
  37931. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37932. */
  37933. diffuseFresnelParameters: FresnelParameters;
  37934. private _opacityFresnelParameters;
  37935. /**
  37936. * Define the opacity fresnel parameters of the material.
  37937. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37938. */
  37939. opacityFresnelParameters: FresnelParameters;
  37940. private _reflectionFresnelParameters;
  37941. /**
  37942. * Define the reflection fresnel parameters of the material.
  37943. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37944. */
  37945. reflectionFresnelParameters: FresnelParameters;
  37946. private _refractionFresnelParameters;
  37947. /**
  37948. * Define the refraction fresnel parameters of the material.
  37949. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37950. */
  37951. refractionFresnelParameters: FresnelParameters;
  37952. private _emissiveFresnelParameters;
  37953. /**
  37954. * Define the emissive fresnel parameters of the material.
  37955. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37956. */
  37957. emissiveFresnelParameters: FresnelParameters;
  37958. private _useReflectionFresnelFromSpecular;
  37959. /**
  37960. * If true automatically deducts the fresnels values from the material specularity.
  37961. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37962. */
  37963. useReflectionFresnelFromSpecular: boolean;
  37964. private _useGlossinessFromSpecularMapAlpha;
  37965. /**
  37966. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  37967. */
  37968. useGlossinessFromSpecularMapAlpha: boolean;
  37969. private _maxSimultaneousLights;
  37970. /**
  37971. * Defines the maximum number of lights that can be used in the material
  37972. */
  37973. maxSimultaneousLights: number;
  37974. private _invertNormalMapX;
  37975. /**
  37976. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  37977. */
  37978. invertNormalMapX: boolean;
  37979. private _invertNormalMapY;
  37980. /**
  37981. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  37982. */
  37983. invertNormalMapY: boolean;
  37984. private _twoSidedLighting;
  37985. /**
  37986. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  37987. */
  37988. twoSidedLighting: boolean;
  37989. /**
  37990. * Default configuration related to image processing available in the standard Material.
  37991. */
  37992. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37993. /**
  37994. * Gets the image processing configuration used either in this material.
  37995. */
  37996. /**
  37997. * Sets the Default image processing configuration used either in the this material.
  37998. *
  37999. * If sets to null, the scene one is in use.
  38000. */
  38001. imageProcessingConfiguration: ImageProcessingConfiguration;
  38002. /**
  38003. * Keep track of the image processing observer to allow dispose and replace.
  38004. */
  38005. private _imageProcessingObserver;
  38006. /**
  38007. * Attaches a new image processing configuration to the Standard Material.
  38008. * @param configuration
  38009. */
  38010. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38011. /**
  38012. * Gets wether the color curves effect is enabled.
  38013. */
  38014. /**
  38015. * Sets wether the color curves effect is enabled.
  38016. */
  38017. cameraColorCurvesEnabled: boolean;
  38018. /**
  38019. * Gets wether the color grading effect is enabled.
  38020. */
  38021. /**
  38022. * Gets wether the color grading effect is enabled.
  38023. */
  38024. cameraColorGradingEnabled: boolean;
  38025. /**
  38026. * Gets wether tonemapping is enabled or not.
  38027. */
  38028. /**
  38029. * Sets wether tonemapping is enabled or not
  38030. */
  38031. cameraToneMappingEnabled: boolean;
  38032. /**
  38033. * The camera exposure used on this material.
  38034. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38035. * This corresponds to a photographic exposure.
  38036. */
  38037. /**
  38038. * The camera exposure used on this material.
  38039. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38040. * This corresponds to a photographic exposure.
  38041. */
  38042. cameraExposure: number;
  38043. /**
  38044. * Gets The camera contrast used on this material.
  38045. */
  38046. /**
  38047. * Sets The camera contrast used on this material.
  38048. */
  38049. cameraContrast: number;
  38050. /**
  38051. * Gets the Color Grading 2D Lookup Texture.
  38052. */
  38053. /**
  38054. * Sets the Color Grading 2D Lookup Texture.
  38055. */
  38056. cameraColorGradingTexture: Nullable<BaseTexture>;
  38057. /**
  38058. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38059. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38060. * 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;
  38061. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38062. */
  38063. /**
  38064. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38065. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38066. * 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;
  38067. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38068. */
  38069. cameraColorCurves: Nullable<ColorCurves>;
  38070. /**
  38071. * Custom callback helping to override the default shader used in the material.
  38072. */
  38073. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38074. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38075. protected _worldViewProjectionMatrix: Matrix;
  38076. protected _globalAmbientColor: Color3;
  38077. protected _useLogarithmicDepth: boolean;
  38078. /**
  38079. * Instantiates a new standard material.
  38080. * This is the default material used in Babylon. It is the best trade off between quality
  38081. * and performances.
  38082. * @see http://doc.babylonjs.com/babylon101/materials
  38083. * @param name Define the name of the material in the scene
  38084. * @param scene Define the scene the material belong to
  38085. */
  38086. constructor(name: string, scene: Scene);
  38087. /**
  38088. * Gets a boolean indicating that current material needs to register RTT
  38089. */
  38090. readonly hasRenderTargetTextures: boolean;
  38091. /**
  38092. * Gets the current class name of the material e.g. "StandardMaterial"
  38093. * Mainly use in serialization.
  38094. * @returns the class name
  38095. */
  38096. getClassName(): string;
  38097. /**
  38098. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38099. * You can try switching to logarithmic depth.
  38100. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38101. */
  38102. useLogarithmicDepth: boolean;
  38103. /**
  38104. * Specifies if the material will require alpha blending
  38105. * @returns a boolean specifying if alpha blending is needed
  38106. */
  38107. needAlphaBlending(): boolean;
  38108. /**
  38109. * Specifies if this material should be rendered in alpha test mode
  38110. * @returns a boolean specifying if an alpha test is needed.
  38111. */
  38112. needAlphaTesting(): boolean;
  38113. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38114. /**
  38115. * Get the texture used for alpha test purpose.
  38116. * @returns the diffuse texture in case of the standard material.
  38117. */
  38118. getAlphaTestTexture(): Nullable<BaseTexture>;
  38119. /**
  38120. * Get if the submesh is ready to be used and all its information available.
  38121. * Child classes can use it to update shaders
  38122. * @param mesh defines the mesh to check
  38123. * @param subMesh defines which submesh to check
  38124. * @param useInstances specifies that instances should be used
  38125. * @returns a boolean indicating that the submesh is ready or not
  38126. */
  38127. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38128. /**
  38129. * Builds the material UBO layouts.
  38130. * Used internally during the effect preparation.
  38131. */
  38132. buildUniformLayout(): void;
  38133. /**
  38134. * Unbinds the material from the mesh
  38135. */
  38136. unbind(): void;
  38137. /**
  38138. * Binds the submesh to this material by preparing the effect and shader to draw
  38139. * @param world defines the world transformation matrix
  38140. * @param mesh defines the mesh containing the submesh
  38141. * @param subMesh defines the submesh to bind the material to
  38142. */
  38143. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38144. /**
  38145. * Get the list of animatables in the material.
  38146. * @returns the list of animatables object used in the material
  38147. */
  38148. getAnimatables(): IAnimatable[];
  38149. /**
  38150. * Gets the active textures from the material
  38151. * @returns an array of textures
  38152. */
  38153. getActiveTextures(): BaseTexture[];
  38154. /**
  38155. * Specifies if the material uses a texture
  38156. * @param texture defines the texture to check against the material
  38157. * @returns a boolean specifying if the material uses the texture
  38158. */
  38159. hasTexture(texture: BaseTexture): boolean;
  38160. /**
  38161. * Disposes the material
  38162. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38163. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38164. */
  38165. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38166. /**
  38167. * Makes a duplicate of the material, and gives it a new name
  38168. * @param name defines the new name for the duplicated material
  38169. * @returns the cloned material
  38170. */
  38171. clone(name: string): StandardMaterial;
  38172. /**
  38173. * Serializes this material in a JSON representation
  38174. * @returns the serialized material object
  38175. */
  38176. serialize(): any;
  38177. /**
  38178. * Creates a standard material from parsed material data
  38179. * @param source defines the JSON representation of the material
  38180. * @param scene defines the hosting scene
  38181. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38182. * @returns a new standard material
  38183. */
  38184. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38185. /**
  38186. * Are diffuse textures enabled in the application.
  38187. */
  38188. static DiffuseTextureEnabled: boolean;
  38189. /**
  38190. * Are ambient textures enabled in the application.
  38191. */
  38192. static AmbientTextureEnabled: boolean;
  38193. /**
  38194. * Are opacity textures enabled in the application.
  38195. */
  38196. static OpacityTextureEnabled: boolean;
  38197. /**
  38198. * Are reflection textures enabled in the application.
  38199. */
  38200. static ReflectionTextureEnabled: boolean;
  38201. /**
  38202. * Are emissive textures enabled in the application.
  38203. */
  38204. static EmissiveTextureEnabled: boolean;
  38205. /**
  38206. * Are specular textures enabled in the application.
  38207. */
  38208. static SpecularTextureEnabled: boolean;
  38209. /**
  38210. * Are bump textures enabled in the application.
  38211. */
  38212. static BumpTextureEnabled: boolean;
  38213. /**
  38214. * Are lightmap textures enabled in the application.
  38215. */
  38216. static LightmapTextureEnabled: boolean;
  38217. /**
  38218. * Are refraction textures enabled in the application.
  38219. */
  38220. static RefractionTextureEnabled: boolean;
  38221. /**
  38222. * Are color grading textures enabled in the application.
  38223. */
  38224. static ColorGradingTextureEnabled: boolean;
  38225. /**
  38226. * Are fresnels enabled in the application.
  38227. */
  38228. static FresnelEnabled: boolean;
  38229. }
  38230. }
  38231. declare module BABYLON {
  38232. /**
  38233. * A class extending Texture allowing drawing on a texture
  38234. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38235. */
  38236. export class DynamicTexture extends Texture {
  38237. private _generateMipMaps;
  38238. private _canvas;
  38239. private _context;
  38240. private _engine;
  38241. /**
  38242. * Creates a DynamicTexture
  38243. * @param name defines the name of the texture
  38244. * @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
  38245. * @param scene defines the scene where you want the texture
  38246. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38247. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38248. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38249. */
  38250. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38251. /**
  38252. * Get the current class name of the texture useful for serialization or dynamic coding.
  38253. * @returns "DynamicTexture"
  38254. */
  38255. getClassName(): string;
  38256. /**
  38257. * Gets the current state of canRescale
  38258. */
  38259. readonly canRescale: boolean;
  38260. private _recreate;
  38261. /**
  38262. * Scales the texture
  38263. * @param ratio the scale factor to apply to both width and height
  38264. */
  38265. scale(ratio: number): void;
  38266. /**
  38267. * Resizes the texture
  38268. * @param width the new width
  38269. * @param height the new height
  38270. */
  38271. scaleTo(width: number, height: number): void;
  38272. /**
  38273. * Gets the context of the canvas used by the texture
  38274. * @returns the canvas context of the dynamic texture
  38275. */
  38276. getContext(): CanvasRenderingContext2D;
  38277. /**
  38278. * Clears the texture
  38279. */
  38280. clear(): void;
  38281. /**
  38282. * Updates the texture
  38283. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38284. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38285. */
  38286. update(invertY?: boolean, premulAlpha?: boolean): void;
  38287. /**
  38288. * Draws text onto the texture
  38289. * @param text defines the text to be drawn
  38290. * @param x defines the placement of the text from the left
  38291. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38292. * @param font defines the font to be used with font-style, font-size, font-name
  38293. * @param color defines the color used for the text
  38294. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38295. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38296. * @param update defines whether texture is immediately update (default is true)
  38297. */
  38298. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38299. /**
  38300. * Clones the texture
  38301. * @returns the clone of the texture.
  38302. */
  38303. clone(): DynamicTexture;
  38304. /**
  38305. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38306. * @returns a serialized dynamic texture object
  38307. */
  38308. serialize(): any;
  38309. /** @hidden */ rebuild(): void;
  38310. }
  38311. }
  38312. declare module BABYLON {
  38313. /** @hidden */
  38314. export var imageProcessingPixelShader: {
  38315. name: string;
  38316. shader: string;
  38317. };
  38318. }
  38319. declare module BABYLON {
  38320. /**
  38321. * ImageProcessingPostProcess
  38322. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38323. */
  38324. export class ImageProcessingPostProcess extends PostProcess {
  38325. /**
  38326. * Default configuration related to image processing available in the PBR Material.
  38327. */
  38328. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38329. /**
  38330. * Gets the image processing configuration used either in this material.
  38331. */
  38332. /**
  38333. * Sets the Default image processing configuration used either in the this material.
  38334. *
  38335. * If sets to null, the scene one is in use.
  38336. */
  38337. imageProcessingConfiguration: ImageProcessingConfiguration;
  38338. /**
  38339. * Keep track of the image processing observer to allow dispose and replace.
  38340. */
  38341. private _imageProcessingObserver;
  38342. /**
  38343. * Attaches a new image processing configuration to the PBR Material.
  38344. * @param configuration
  38345. */
  38346. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38347. /**
  38348. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38349. */
  38350. /**
  38351. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38352. */
  38353. colorCurves: Nullable<ColorCurves>;
  38354. /**
  38355. * Gets wether the color curves effect is enabled.
  38356. */
  38357. /**
  38358. * Sets wether the color curves effect is enabled.
  38359. */
  38360. colorCurvesEnabled: boolean;
  38361. /**
  38362. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38363. */
  38364. /**
  38365. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38366. */
  38367. colorGradingTexture: Nullable<BaseTexture>;
  38368. /**
  38369. * Gets wether the color grading effect is enabled.
  38370. */
  38371. /**
  38372. * Gets wether the color grading effect is enabled.
  38373. */
  38374. colorGradingEnabled: boolean;
  38375. /**
  38376. * Gets exposure used in the effect.
  38377. */
  38378. /**
  38379. * Sets exposure used in the effect.
  38380. */
  38381. exposure: number;
  38382. /**
  38383. * Gets wether tonemapping is enabled or not.
  38384. */
  38385. /**
  38386. * Sets wether tonemapping is enabled or not
  38387. */
  38388. toneMappingEnabled: boolean;
  38389. /**
  38390. * Gets the type of tone mapping effect.
  38391. */
  38392. /**
  38393. * Sets the type of tone mapping effect.
  38394. */
  38395. toneMappingType: number;
  38396. /**
  38397. * Gets contrast used in the effect.
  38398. */
  38399. /**
  38400. * Sets contrast used in the effect.
  38401. */
  38402. contrast: number;
  38403. /**
  38404. * Gets Vignette stretch size.
  38405. */
  38406. /**
  38407. * Sets Vignette stretch size.
  38408. */
  38409. vignetteStretch: number;
  38410. /**
  38411. * Gets Vignette centre X Offset.
  38412. */
  38413. /**
  38414. * Sets Vignette centre X Offset.
  38415. */
  38416. vignetteCentreX: number;
  38417. /**
  38418. * Gets Vignette centre Y Offset.
  38419. */
  38420. /**
  38421. * Sets Vignette centre Y Offset.
  38422. */
  38423. vignetteCentreY: number;
  38424. /**
  38425. * Gets Vignette weight or intensity of the vignette effect.
  38426. */
  38427. /**
  38428. * Sets Vignette weight or intensity of the vignette effect.
  38429. */
  38430. vignetteWeight: number;
  38431. /**
  38432. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38433. * if vignetteEnabled is set to true.
  38434. */
  38435. /**
  38436. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38437. * if vignetteEnabled is set to true.
  38438. */
  38439. vignetteColor: Color4;
  38440. /**
  38441. * Gets Camera field of view used by the Vignette effect.
  38442. */
  38443. /**
  38444. * Sets Camera field of view used by the Vignette effect.
  38445. */
  38446. vignetteCameraFov: number;
  38447. /**
  38448. * Gets the vignette blend mode allowing different kind of effect.
  38449. */
  38450. /**
  38451. * Sets the vignette blend mode allowing different kind of effect.
  38452. */
  38453. vignetteBlendMode: number;
  38454. /**
  38455. * Gets wether the vignette effect is enabled.
  38456. */
  38457. /**
  38458. * Sets wether the vignette effect is enabled.
  38459. */
  38460. vignetteEnabled: boolean;
  38461. private _fromLinearSpace;
  38462. /**
  38463. * Gets wether the input of the processing is in Gamma or Linear Space.
  38464. */
  38465. /**
  38466. * Sets wether the input of the processing is in Gamma or Linear Space.
  38467. */
  38468. fromLinearSpace: boolean;
  38469. /**
  38470. * Defines cache preventing GC.
  38471. */
  38472. private _defines;
  38473. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38474. /**
  38475. * "ImageProcessingPostProcess"
  38476. * @returns "ImageProcessingPostProcess"
  38477. */
  38478. getClassName(): string;
  38479. protected _updateParameters(): void;
  38480. dispose(camera?: Camera): void;
  38481. }
  38482. }
  38483. declare module BABYLON {
  38484. /**
  38485. * Class containing static functions to help procedurally build meshes
  38486. */
  38487. export class GroundBuilder {
  38488. /**
  38489. * Creates a ground mesh
  38490. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38491. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38493. * @param name defines the name of the mesh
  38494. * @param options defines the options used to create the mesh
  38495. * @param scene defines the hosting scene
  38496. * @returns the ground mesh
  38497. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38498. */
  38499. static CreateGround(name: string, options: {
  38500. width?: number;
  38501. height?: number;
  38502. subdivisions?: number;
  38503. subdivisionsX?: number;
  38504. subdivisionsY?: number;
  38505. updatable?: boolean;
  38506. }, scene: any): Mesh;
  38507. /**
  38508. * Creates a tiled ground mesh
  38509. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38510. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38511. * * 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
  38512. * * 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
  38513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38514. * @param name defines the name of the mesh
  38515. * @param options defines the options used to create the mesh
  38516. * @param scene defines the hosting scene
  38517. * @returns the tiled ground mesh
  38518. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38519. */
  38520. static CreateTiledGround(name: string, options: {
  38521. xmin: number;
  38522. zmin: number;
  38523. xmax: number;
  38524. zmax: number;
  38525. subdivisions?: {
  38526. w: number;
  38527. h: number;
  38528. };
  38529. precision?: {
  38530. w: number;
  38531. h: number;
  38532. };
  38533. updatable?: boolean;
  38534. }, scene?: Nullable<Scene>): Mesh;
  38535. /**
  38536. * Creates a ground mesh from a height map
  38537. * * The parameter `url` sets the URL of the height map image resource.
  38538. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38539. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38540. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38541. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38542. * * 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.
  38543. * * 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).
  38544. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38546. * @param name defines the name of the mesh
  38547. * @param url defines the url to the height map
  38548. * @param options defines the options used to create the mesh
  38549. * @param scene defines the hosting scene
  38550. * @returns the ground mesh
  38551. * @see https://doc.babylonjs.com/babylon101/height_map
  38552. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38553. */
  38554. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38555. width?: number;
  38556. height?: number;
  38557. subdivisions?: number;
  38558. minHeight?: number;
  38559. maxHeight?: number;
  38560. colorFilter?: Color3;
  38561. alphaFilter?: number;
  38562. updatable?: boolean;
  38563. onReady?: (mesh: GroundMesh) => void;
  38564. }, scene?: Nullable<Scene>): GroundMesh;
  38565. }
  38566. }
  38567. declare module BABYLON {
  38568. /**
  38569. * Class containing static functions to help procedurally build meshes
  38570. */
  38571. export class TorusBuilder {
  38572. /**
  38573. * Creates a torus mesh
  38574. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38575. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38576. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38578. * * 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
  38579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38580. * @param name defines the name of the mesh
  38581. * @param options defines the options used to create the mesh
  38582. * @param scene defines the hosting scene
  38583. * @returns the torus mesh
  38584. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38585. */
  38586. static CreateTorus(name: string, options: {
  38587. diameter?: number;
  38588. thickness?: number;
  38589. tessellation?: number;
  38590. updatable?: boolean;
  38591. sideOrientation?: number;
  38592. frontUVs?: Vector4;
  38593. backUVs?: Vector4;
  38594. }, scene: any): Mesh;
  38595. }
  38596. }
  38597. declare module BABYLON {
  38598. /**
  38599. * Class containing static functions to help procedurally build meshes
  38600. */
  38601. export class CylinderBuilder {
  38602. /**
  38603. * Creates a cylinder or a cone mesh
  38604. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38605. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38606. * * 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.
  38607. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38608. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38609. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38610. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38611. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38612. * * 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).
  38613. * * 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
  38614. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38615. * * 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
  38616. * * 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.
  38617. * * If `enclose` is false, a ring surface is one element.
  38618. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38619. * * 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
  38620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38621. * * 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
  38622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38623. * @param name defines the name of the mesh
  38624. * @param options defines the options used to create the mesh
  38625. * @param scene defines the hosting scene
  38626. * @returns the cylinder mesh
  38627. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38628. */
  38629. static CreateCylinder(name: string, options: {
  38630. height?: number;
  38631. diameterTop?: number;
  38632. diameterBottom?: number;
  38633. diameter?: number;
  38634. tessellation?: number;
  38635. subdivisions?: number;
  38636. arc?: number;
  38637. faceColors?: Color4[];
  38638. faceUV?: Vector4[];
  38639. updatable?: boolean;
  38640. hasRings?: boolean;
  38641. enclose?: boolean;
  38642. sideOrientation?: number;
  38643. frontUVs?: Vector4;
  38644. backUVs?: Vector4;
  38645. }, scene: any): Mesh;
  38646. }
  38647. }
  38648. declare module BABYLON {
  38649. /**
  38650. * Manager for handling gamepads
  38651. */
  38652. export class GamepadManager {
  38653. private _scene?;
  38654. private _babylonGamepads;
  38655. private _oneGamepadConnected;
  38656. /** @hidden */ isMonitoring: boolean;
  38657. private _gamepadEventSupported;
  38658. private _gamepadSupport;
  38659. /**
  38660. * observable to be triggered when the gamepad controller has been connected
  38661. */
  38662. onGamepadConnectedObservable: Observable<Gamepad>;
  38663. /**
  38664. * observable to be triggered when the gamepad controller has been disconnected
  38665. */
  38666. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38667. private _onGamepadConnectedEvent;
  38668. private _onGamepadDisconnectedEvent;
  38669. /**
  38670. * Initializes the gamepad manager
  38671. * @param _scene BabylonJS scene
  38672. */
  38673. constructor(_scene?: Scene | undefined);
  38674. /**
  38675. * The gamepads in the game pad manager
  38676. */
  38677. readonly gamepads: Gamepad[];
  38678. /**
  38679. * Get the gamepad controllers based on type
  38680. * @param type The type of gamepad controller
  38681. * @returns Nullable gamepad
  38682. */
  38683. getGamepadByType(type?: number): Nullable<Gamepad>;
  38684. /**
  38685. * Disposes the gamepad manager
  38686. */
  38687. dispose(): void;
  38688. private _addNewGamepad;
  38689. private _startMonitoringGamepads;
  38690. private _stopMonitoringGamepads;
  38691. /** @hidden */ checkGamepadsStatus(): void;
  38692. private _updateGamepadObjects;
  38693. }
  38694. }
  38695. declare module BABYLON {
  38696. interface Scene {
  38697. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  38698. /**
  38699. * Gets the gamepad manager associated with the scene
  38700. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38701. */
  38702. gamepadManager: GamepadManager;
  38703. }
  38704. /**
  38705. * Interface representing a free camera inputs manager
  38706. */
  38707. interface FreeCameraInputsManager {
  38708. /**
  38709. * Adds gamepad input support to the FreeCameraInputsManager.
  38710. * @returns the FreeCameraInputsManager
  38711. */
  38712. addGamepad(): FreeCameraInputsManager;
  38713. }
  38714. /**
  38715. * Interface representing an arc rotate camera inputs manager
  38716. */
  38717. interface ArcRotateCameraInputsManager {
  38718. /**
  38719. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38720. * @returns the camera inputs manager
  38721. */
  38722. addGamepad(): ArcRotateCameraInputsManager;
  38723. }
  38724. /**
  38725. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38726. */
  38727. export class GamepadSystemSceneComponent implements ISceneComponent {
  38728. /**
  38729. * The component name helpfull to identify the component in the list of scene components.
  38730. */
  38731. readonly name: string;
  38732. /**
  38733. * The scene the component belongs to.
  38734. */
  38735. scene: Scene;
  38736. /**
  38737. * Creates a new instance of the component for the given scene
  38738. * @param scene Defines the scene to register the component in
  38739. */
  38740. constructor(scene: Scene);
  38741. /**
  38742. * Registers the component in a given scene
  38743. */
  38744. register(): void;
  38745. /**
  38746. * Rebuilds the elements related to this component in case of
  38747. * context lost for instance.
  38748. */
  38749. rebuild(): void;
  38750. /**
  38751. * Disposes the component and the associated ressources
  38752. */
  38753. dispose(): void;
  38754. private _beforeCameraUpdate;
  38755. }
  38756. }
  38757. declare module BABYLON {
  38758. /**
  38759. * Options to modify the vr teleportation behavior.
  38760. */
  38761. export interface VRTeleportationOptions {
  38762. /**
  38763. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38764. */
  38765. floorMeshName?: string;
  38766. /**
  38767. * A list of meshes to be used as the teleportation floor. (default: empty)
  38768. */
  38769. floorMeshes?: Mesh[];
  38770. }
  38771. /**
  38772. * Options to modify the vr experience helper's behavior.
  38773. */
  38774. export interface VRExperienceHelperOptions extends WebVROptions {
  38775. /**
  38776. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38777. */
  38778. createDeviceOrientationCamera?: boolean;
  38779. /**
  38780. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38781. */
  38782. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38783. /**
  38784. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38785. */
  38786. laserToggle?: boolean;
  38787. /**
  38788. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38789. */
  38790. floorMeshes?: Mesh[];
  38791. /**
  38792. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  38793. */
  38794. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  38795. }
  38796. /**
  38797. * Event containing information after VR has been entered
  38798. */
  38799. export class OnAfterEnteringVRObservableEvent {
  38800. /**
  38801. * If entering vr was successful
  38802. */
  38803. success: boolean;
  38804. }
  38805. /**
  38806. * Helps to quickly add VR support to an existing scene.
  38807. * See http://doc.babylonjs.com/how_to/webvr_helper
  38808. */
  38809. export class VRExperienceHelper {
  38810. /** Options to modify the vr experience helper's behavior. */
  38811. webVROptions: VRExperienceHelperOptions;
  38812. private _scene;
  38813. private _position;
  38814. private _btnVR;
  38815. private _btnVRDisplayed;
  38816. private _webVRsupported;
  38817. private _webVRready;
  38818. private _webVRrequesting;
  38819. private _webVRpresenting;
  38820. private _hasEnteredVR;
  38821. private _fullscreenVRpresenting;
  38822. private _canvas;
  38823. private _webVRCamera;
  38824. private _vrDeviceOrientationCamera;
  38825. private _deviceOrientationCamera;
  38826. private _existingCamera;
  38827. private _onKeyDown;
  38828. private _onVrDisplayPresentChange;
  38829. private _onVRDisplayChanged;
  38830. private _onVRRequestPresentStart;
  38831. private _onVRRequestPresentComplete;
  38832. /**
  38833. * Observable raised right before entering VR.
  38834. */
  38835. onEnteringVRObservable: Observable<VRExperienceHelper>;
  38836. /**
  38837. * Observable raised when entering VR has completed.
  38838. */
  38839. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  38840. /**
  38841. * Observable raised when exiting VR.
  38842. */
  38843. onExitingVRObservable: Observable<VRExperienceHelper>;
  38844. /**
  38845. * Observable raised when controller mesh is loaded.
  38846. */
  38847. onControllerMeshLoadedObservable: Observable<WebVRController>;
  38848. /** Return this.onEnteringVRObservable
  38849. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  38850. */
  38851. readonly onEnteringVR: Observable<VRExperienceHelper>;
  38852. /** Return this.onExitingVRObservable
  38853. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  38854. */
  38855. readonly onExitingVR: Observable<VRExperienceHelper>;
  38856. /** Return this.onControllerMeshLoadedObservable
  38857. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  38858. */
  38859. readonly onControllerMeshLoaded: Observable<WebVRController>;
  38860. private _rayLength;
  38861. private _useCustomVRButton;
  38862. private _teleportationRequested;
  38863. private _teleportActive;
  38864. private _floorMeshName;
  38865. private _floorMeshesCollection;
  38866. private _rotationAllowed;
  38867. private _teleportBackwardsVector;
  38868. private _teleportationTarget;
  38869. private _isDefaultTeleportationTarget;
  38870. private _postProcessMove;
  38871. private _teleportationFillColor;
  38872. private _teleportationBorderColor;
  38873. private _rotationAngle;
  38874. private _haloCenter;
  38875. private _cameraGazer;
  38876. private _padSensibilityUp;
  38877. private _padSensibilityDown;
  38878. private _leftController;
  38879. private _rightController;
  38880. /**
  38881. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  38882. */
  38883. onNewMeshSelected: Observable<AbstractMesh>;
  38884. /**
  38885. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  38886. */
  38887. onNewMeshPicked: Observable<PickingInfo>;
  38888. private _circleEase;
  38889. /**
  38890. * Observable raised before camera teleportation
  38891. */
  38892. onBeforeCameraTeleport: Observable<Vector3>;
  38893. /**
  38894. * Observable raised after camera teleportation
  38895. */
  38896. onAfterCameraTeleport: Observable<Vector3>;
  38897. /**
  38898. * Observable raised when current selected mesh gets unselected
  38899. */
  38900. onSelectedMeshUnselected: Observable<AbstractMesh>;
  38901. private _raySelectionPredicate;
  38902. /**
  38903. * To be optionaly changed by user to define custom ray selection
  38904. */
  38905. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  38906. /**
  38907. * To be optionaly changed by user to define custom selection logic (after ray selection)
  38908. */
  38909. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  38910. /**
  38911. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  38912. */
  38913. teleportationEnabled: boolean;
  38914. private _defaultHeight;
  38915. private _teleportationInitialized;
  38916. private _interactionsEnabled;
  38917. private _interactionsRequested;
  38918. private _displayGaze;
  38919. private _displayLaserPointer;
  38920. /**
  38921. * The mesh used to display where the user is going to teleport.
  38922. */
  38923. /**
  38924. * Sets the mesh to be used to display where the user is going to teleport.
  38925. */
  38926. teleportationTarget: Mesh;
  38927. /**
  38928. * 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
  38929. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  38930. * See http://doc.babylonjs.com/resources/baking_transformations
  38931. */
  38932. gazeTrackerMesh: Mesh;
  38933. /**
  38934. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  38935. */
  38936. updateGazeTrackerScale: boolean;
  38937. /**
  38938. * If the gaze trackers color should be updated when selecting meshes
  38939. */
  38940. updateGazeTrackerColor: boolean;
  38941. /**
  38942. * The gaze tracking mesh corresponding to the left controller
  38943. */
  38944. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  38945. /**
  38946. * The gaze tracking mesh corresponding to the right controller
  38947. */
  38948. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  38949. /**
  38950. * If the ray of the gaze should be displayed.
  38951. */
  38952. /**
  38953. * Sets if the ray of the gaze should be displayed.
  38954. */
  38955. displayGaze: boolean;
  38956. /**
  38957. * If the ray of the LaserPointer should be displayed.
  38958. */
  38959. /**
  38960. * Sets if the ray of the LaserPointer should be displayed.
  38961. */
  38962. displayLaserPointer: boolean;
  38963. /**
  38964. * The deviceOrientationCamera used as the camera when not in VR.
  38965. */
  38966. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  38967. /**
  38968. * Based on the current WebVR support, returns the current VR camera used.
  38969. */
  38970. readonly currentVRCamera: Nullable<Camera>;
  38971. /**
  38972. * The webVRCamera which is used when in VR.
  38973. */
  38974. readonly webVRCamera: WebVRFreeCamera;
  38975. /**
  38976. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  38977. */
  38978. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  38979. private readonly _teleportationRequestInitiated;
  38980. /**
  38981. * Defines wether or not Pointer lock should be requested when switching to
  38982. * full screen.
  38983. */
  38984. requestPointerLockOnFullScreen: boolean;
  38985. /**
  38986. * Instantiates a VRExperienceHelper.
  38987. * Helps to quickly add VR support to an existing scene.
  38988. * @param scene The scene the VRExperienceHelper belongs to.
  38989. * @param webVROptions Options to modify the vr experience helper's behavior.
  38990. */
  38991. constructor(scene: Scene,
  38992. /** Options to modify the vr experience helper's behavior. */
  38993. webVROptions?: VRExperienceHelperOptions);
  38994. private _onDefaultMeshLoaded;
  38995. private _onResize;
  38996. private _onFullscreenChange;
  38997. /**
  38998. * Gets a value indicating if we are currently in VR mode.
  38999. */
  39000. readonly isInVRMode: boolean;
  39001. private onVrDisplayPresentChange;
  39002. private onVRDisplayChanged;
  39003. private moveButtonToBottomRight;
  39004. private displayVRButton;
  39005. private updateButtonVisibility;
  39006. private _cachedAngularSensibility;
  39007. /**
  39008. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39009. * Otherwise, will use the fullscreen API.
  39010. */
  39011. enterVR(): void;
  39012. /**
  39013. * Attempt to exit VR, or fullscreen.
  39014. */
  39015. exitVR(): void;
  39016. /**
  39017. * The position of the vr experience helper.
  39018. */
  39019. /**
  39020. * Sets the position of the vr experience helper.
  39021. */
  39022. position: Vector3;
  39023. /**
  39024. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39025. */
  39026. enableInteractions(): void;
  39027. private readonly _noControllerIsActive;
  39028. private beforeRender;
  39029. private _isTeleportationFloor;
  39030. /**
  39031. * Adds a floor mesh to be used for teleportation.
  39032. * @param floorMesh the mesh to be used for teleportation.
  39033. */
  39034. addFloorMesh(floorMesh: Mesh): void;
  39035. /**
  39036. * Removes a floor mesh from being used for teleportation.
  39037. * @param floorMesh the mesh to be removed.
  39038. */
  39039. removeFloorMesh(floorMesh: Mesh): void;
  39040. /**
  39041. * Enables interactions and teleportation using the VR controllers and gaze.
  39042. * @param vrTeleportationOptions options to modify teleportation behavior.
  39043. */
  39044. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39045. private _onNewGamepadConnected;
  39046. private _tryEnableInteractionOnController;
  39047. private _onNewGamepadDisconnected;
  39048. private _enableInteractionOnController;
  39049. private _checkTeleportWithRay;
  39050. private _checkRotate;
  39051. private _checkTeleportBackwards;
  39052. private _enableTeleportationOnController;
  39053. private _createTeleportationCircles;
  39054. private _displayTeleportationTarget;
  39055. private _hideTeleportationTarget;
  39056. private _rotateCamera;
  39057. private _moveTeleportationSelectorTo;
  39058. private _workingVector;
  39059. private _workingQuaternion;
  39060. private _workingMatrix;
  39061. /**
  39062. * Teleports the users feet to the desired location
  39063. * @param location The location where the user's feet should be placed
  39064. */
  39065. teleportCamera(location: Vector3): void;
  39066. private _convertNormalToDirectionOfRay;
  39067. private _castRayAndSelectObject;
  39068. private _notifySelectedMeshUnselected;
  39069. /**
  39070. * Sets the color of the laser ray from the vr controllers.
  39071. * @param color new color for the ray.
  39072. */
  39073. changeLaserColor(color: Color3): void;
  39074. /**
  39075. * Sets the color of the ray from the vr headsets gaze.
  39076. * @param color new color for the ray.
  39077. */
  39078. changeGazeColor(color: Color3): void;
  39079. /**
  39080. * Exits VR and disposes of the vr experience helper
  39081. */
  39082. dispose(): void;
  39083. /**
  39084. * Gets the name of the VRExperienceHelper class
  39085. * @returns "VRExperienceHelper"
  39086. */
  39087. getClassName(): string;
  39088. }
  39089. }
  39090. declare module BABYLON {
  39091. /**
  39092. * Manages an XRSession
  39093. * @see https://doc.babylonjs.com/how_to/webxr
  39094. */
  39095. export class WebXRSessionManager implements IDisposable {
  39096. private scene;
  39097. /**
  39098. * Fires every time a new xrFrame arrives which can be used to update the camera
  39099. */
  39100. onXRFrameObservable: Observable<any>;
  39101. /**
  39102. * Fires when the xr session is ended either by the device or manually done
  39103. */
  39104. onXRSessionEnded: Observable<any>;
  39105. /** @hidden */ xrSession: XRSession;
  39106. /** @hidden */ frameOfReference: XRFrameOfReference;
  39107. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39108. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  39109. private _xrNavigator;
  39110. private _xrDevice;
  39111. private _tmpMatrix;
  39112. /**
  39113. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39114. * @param scene The scene which the session should be created for
  39115. */
  39116. constructor(scene: Scene);
  39117. /**
  39118. * Initializes the manager
  39119. * After initialization enterXR can be called to start an XR session
  39120. * @returns Promise which resolves after it is initialized
  39121. */
  39122. initializeAsync(): Promise<void>;
  39123. /**
  39124. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39125. * @param sessionCreationOptions xr options to create the session with
  39126. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39127. * @returns Promise which resolves after it enters XR
  39128. */
  39129. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39130. /**
  39131. * Stops the xrSession and restores the renderloop
  39132. * @returns Promise which resolves after it exits XR
  39133. */
  39134. exitXRAsync(): Promise<void>;
  39135. /**
  39136. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39137. * @param ray ray to cast into the environment
  39138. * @returns Promise which resolves with a collision point in the environment if it exists
  39139. */
  39140. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39141. /**
  39142. * Checks if a session would be supported for the creation options specified
  39143. * @param options creation options to check if they are supported
  39144. * @returns true if supported
  39145. */
  39146. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39147. /**
  39148. * @hidden
  39149. * Converts the render layer of xrSession to a render target
  39150. * @param session session to create render target for
  39151. * @param scene scene the new render target should be created for
  39152. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39153. /**
  39154. * Disposes of the session manager
  39155. */
  39156. dispose(): void;
  39157. }
  39158. }
  39159. declare module BABYLON {
  39160. /**
  39161. * WebXR Camera which holds the views for the xrSession
  39162. * @see https://doc.babylonjs.com/how_to/webxr
  39163. */
  39164. export class WebXRCamera extends FreeCamera {
  39165. private static _TmpMatrix;
  39166. /**
  39167. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39168. * @param name the name of the camera
  39169. * @param scene the scene to add the camera to
  39170. */
  39171. constructor(name: string, scene: Scene);
  39172. private _updateNumberOfRigCameras;
  39173. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  39174. /**
  39175. * Updates the cameras position from the current pose information of the XR session
  39176. * @param xrSessionManager the session containing pose information
  39177. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39178. */
  39179. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39180. }
  39181. }
  39182. declare module BABYLON {
  39183. /**
  39184. * States of the webXR experience
  39185. */
  39186. export enum WebXRState {
  39187. /**
  39188. * Transitioning to being in XR mode
  39189. */
  39190. ENTERING_XR = 0,
  39191. /**
  39192. * Transitioning to non XR mode
  39193. */
  39194. EXITING_XR = 1,
  39195. /**
  39196. * In XR mode and presenting
  39197. */
  39198. IN_XR = 2,
  39199. /**
  39200. * Not entered XR mode
  39201. */
  39202. NOT_IN_XR = 3
  39203. }
  39204. /**
  39205. * Helper class used to enable XR
  39206. * @see https://doc.babylonjs.com/how_to/webxr
  39207. */
  39208. export class WebXRExperienceHelper implements IDisposable {
  39209. private scene;
  39210. /**
  39211. * 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
  39212. */
  39213. container: AbstractMesh;
  39214. /**
  39215. * Camera used to render xr content
  39216. */
  39217. camera: WebXRCamera;
  39218. /**
  39219. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39220. */
  39221. state: WebXRState;
  39222. private _setState;
  39223. private static _TmpVector;
  39224. /**
  39225. * Fires when the state of the experience helper has changed
  39226. */
  39227. onStateChangedObservable: Observable<WebXRState>;
  39228. /** @hidden */ sessionManager: WebXRSessionManager;
  39229. private _nonVRCamera;
  39230. private _originalSceneAutoClear;
  39231. private _supported;
  39232. /**
  39233. * Creates the experience helper
  39234. * @param scene the scene to attach the experience helper to
  39235. * @returns a promise for the experience helper
  39236. */
  39237. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39238. /**
  39239. * Creates a WebXRExperienceHelper
  39240. * @param scene The scene the helper should be created in
  39241. */
  39242. private constructor();
  39243. /**
  39244. * Exits XR mode and returns the scene to its original state
  39245. * @returns promise that resolves after xr mode has exited
  39246. */
  39247. exitXRAsync(): Promise<void>;
  39248. /**
  39249. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39250. * @param sessionCreationOptions options for the XR session
  39251. * @param frameOfReference frame of reference of the XR session
  39252. * @returns promise that resolves after xr mode has entered
  39253. */
  39254. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39255. /**
  39256. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39257. * @param ray ray to cast into the environment
  39258. * @returns Promise which resolves with a collision point in the environment if it exists
  39259. */
  39260. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39261. /**
  39262. * Updates the global position of the camera by moving the camera's container
  39263. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39264. * @param position The desired global position of the camera
  39265. */
  39266. setPositionOfCameraUsingContainer(position: Vector3): void;
  39267. /**
  39268. * Rotates the xr camera by rotating the camera's container around the camera's position
  39269. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39270. * @param rotation the desired quaternion rotation to apply to the camera
  39271. */
  39272. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39273. /**
  39274. * Checks if the creation options are supported by the xr session
  39275. * @param options creation options
  39276. * @returns true if supported
  39277. */
  39278. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39279. /**
  39280. * Disposes of the experience helper
  39281. */
  39282. dispose(): void;
  39283. }
  39284. }
  39285. declare module BABYLON {
  39286. /**
  39287. * Button which can be used to enter a different mode of XR
  39288. */
  39289. export class WebXREnterExitUIButton {
  39290. /** button element */
  39291. element: HTMLElement;
  39292. /** XR initialization options for the button */
  39293. initializationOptions: XRSessionCreationOptions;
  39294. /**
  39295. * Creates a WebXREnterExitUIButton
  39296. * @param element button element
  39297. * @param initializationOptions XR initialization options for the button
  39298. */
  39299. constructor(
  39300. /** button element */
  39301. element: HTMLElement,
  39302. /** XR initialization options for the button */
  39303. initializationOptions: XRSessionCreationOptions);
  39304. /**
  39305. * Overwritable function which can be used to update the button's visuals when the state changes
  39306. * @param activeButton the current active button in the UI
  39307. */
  39308. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39309. }
  39310. /**
  39311. * Options to create the webXR UI
  39312. */
  39313. export class WebXREnterExitUIOptions {
  39314. /**
  39315. * Context to enter xr with
  39316. */
  39317. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39318. /**
  39319. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39320. */
  39321. customButtons?: Array<WebXREnterExitUIButton>;
  39322. }
  39323. /**
  39324. * UI to allow the user to enter/exit XR mode
  39325. */
  39326. export class WebXREnterExitUI implements IDisposable {
  39327. private scene;
  39328. private _overlay;
  39329. private _buttons;
  39330. private _activeButton;
  39331. /**
  39332. * Fired every time the active button is changed.
  39333. *
  39334. * When xr is entered via a button that launches xr that button will be the callback parameter
  39335. *
  39336. * When exiting xr the callback parameter will be null)
  39337. */
  39338. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39339. /**
  39340. * Creates UI to allow the user to enter/exit XR mode
  39341. * @param scene the scene to add the ui to
  39342. * @param helper the xr experience helper to enter/exit xr with
  39343. * @param options options to configure the UI
  39344. * @returns the created ui
  39345. */
  39346. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39347. private constructor();
  39348. private _updateButtons;
  39349. /**
  39350. * Disposes of the object
  39351. */
  39352. dispose(): void;
  39353. }
  39354. }
  39355. declare module BABYLON {
  39356. /**
  39357. * Represents an XR input
  39358. */
  39359. export class WebXRController {
  39360. /**
  39361. * 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
  39362. */
  39363. grip?: AbstractMesh;
  39364. /**
  39365. * Pointer which can be used to select objects or attach a visible laser to
  39366. */
  39367. pointer: AbstractMesh;
  39368. /**
  39369. * Creates the controller
  39370. * @see https://doc.babylonjs.com/how_to/webxr
  39371. * @param scene the scene which the controller should be associated to
  39372. */
  39373. constructor(scene: Scene);
  39374. /**
  39375. * Disposes of the object
  39376. */
  39377. dispose(): void;
  39378. }
  39379. /**
  39380. * XR input used to track XR inputs such as controllers/rays
  39381. */
  39382. export class WebXRInput implements IDisposable {
  39383. private helper;
  39384. /**
  39385. * XR controllers being tracked
  39386. */
  39387. controllers: Array<WebXRController>;
  39388. private _tmpMatrix;
  39389. private _frameObserver;
  39390. /**
  39391. * Initializes the WebXRInput
  39392. * @param helper experience helper which the input should be created for
  39393. */
  39394. constructor(helper: WebXRExperienceHelper);
  39395. /**
  39396. * Disposes of the object
  39397. */
  39398. dispose(): void;
  39399. }
  39400. }
  39401. declare module BABYLON {
  39402. /**
  39403. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39404. */
  39405. export class WebXRManagedOutputCanvas implements IDisposable {
  39406. private _canvas;
  39407. /**
  39408. * xrpresent context of the canvas which can be used to display/mirror xr content
  39409. */
  39410. canvasContext: Nullable<WebGLRenderingContext>;
  39411. /**
  39412. * Initializes the canvas to be added/removed upon entering/exiting xr
  39413. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39414. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39415. */
  39416. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39417. /**
  39418. * Disposes of the object
  39419. */
  39420. dispose(): void;
  39421. private _setManagedOutputCanvas;
  39422. private _addCanvas;
  39423. private _removeCanvas;
  39424. }
  39425. }
  39426. declare module BABYLON {
  39427. /**
  39428. * Contains an array of blocks representing the octree
  39429. */
  39430. export interface IOctreeContainer<T> {
  39431. /**
  39432. * Blocks within the octree
  39433. */
  39434. blocks: Array<OctreeBlock<T>>;
  39435. }
  39436. /**
  39437. * Class used to store a cell in an octree
  39438. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39439. */
  39440. export class OctreeBlock<T> {
  39441. /**
  39442. * Gets the content of the current block
  39443. */
  39444. entries: T[];
  39445. /**
  39446. * Gets the list of block children
  39447. */
  39448. blocks: Array<OctreeBlock<T>>;
  39449. private _depth;
  39450. private _maxDepth;
  39451. private _capacity;
  39452. private _minPoint;
  39453. private _maxPoint;
  39454. private _boundingVectors;
  39455. private _creationFunc;
  39456. /**
  39457. * Creates a new block
  39458. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39459. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39460. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39461. * @param depth defines the current depth of this block in the octree
  39462. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39463. * @param creationFunc defines a callback to call when an element is added to the block
  39464. */
  39465. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39466. /**
  39467. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39468. */
  39469. readonly capacity: number;
  39470. /**
  39471. * Gets the minimum vector (in world space) of the block's bounding box
  39472. */
  39473. readonly minPoint: Vector3;
  39474. /**
  39475. * Gets the maximum vector (in world space) of the block's bounding box
  39476. */
  39477. readonly maxPoint: Vector3;
  39478. /**
  39479. * Add a new element to this block
  39480. * @param entry defines the element to add
  39481. */
  39482. addEntry(entry: T): void;
  39483. /**
  39484. * Remove an element from this block
  39485. * @param entry defines the element to remove
  39486. */
  39487. removeEntry(entry: T): void;
  39488. /**
  39489. * Add an array of elements to this block
  39490. * @param entries defines the array of elements to add
  39491. */
  39492. addEntries(entries: T[]): void;
  39493. /**
  39494. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39495. * @param frustumPlanes defines the frustum planes to test
  39496. * @param selection defines the array to store current content if selection is positive
  39497. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39498. */
  39499. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39500. /**
  39501. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39502. * @param sphereCenter defines the bounding sphere center
  39503. * @param sphereRadius defines the bounding sphere radius
  39504. * @param selection defines the array to store current content if selection is positive
  39505. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39506. */
  39507. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39508. /**
  39509. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39510. * @param ray defines the ray to test with
  39511. * @param selection defines the array to store current content if selection is positive
  39512. */
  39513. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39514. /**
  39515. * Subdivide the content into child blocks (this block will then be empty)
  39516. */
  39517. createInnerBlocks(): void;
  39518. /**
  39519. * @hidden
  39520. */ 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;
  39521. }
  39522. }
  39523. declare module BABYLON {
  39524. /**
  39525. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39526. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39527. */
  39528. export class Octree<T> {
  39529. /** 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.) */
  39530. maxDepth: number;
  39531. /**
  39532. * Blocks within the octree containing objects
  39533. */
  39534. blocks: Array<OctreeBlock<T>>;
  39535. /**
  39536. * Content stored in the octree
  39537. */
  39538. dynamicContent: T[];
  39539. private _maxBlockCapacity;
  39540. private _selectionContent;
  39541. private _creationFunc;
  39542. /**
  39543. * Creates a octree
  39544. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39545. * @param creationFunc function to be used to instatiate the octree
  39546. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39547. * @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.)
  39548. */
  39549. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39550. /** 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.) */
  39551. maxDepth?: number);
  39552. /**
  39553. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39554. * @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);
  39555. * @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);
  39556. * @param entries meshes to be added to the octree blocks
  39557. */
  39558. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39559. /**
  39560. * Adds a mesh to the octree
  39561. * @param entry Mesh to add to the octree
  39562. */
  39563. addMesh(entry: T): void;
  39564. /**
  39565. * Remove an element from the octree
  39566. * @param entry defines the element to remove
  39567. */
  39568. removeMesh(entry: T): void;
  39569. /**
  39570. * Selects an array of meshes within the frustum
  39571. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39572. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39573. * @returns array of meshes within the frustum
  39574. */
  39575. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39576. /**
  39577. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39578. * @param sphereCenter defines the bounding sphere center
  39579. * @param sphereRadius defines the bounding sphere radius
  39580. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39581. * @returns an array of objects that intersect the sphere
  39582. */
  39583. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39584. /**
  39585. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39586. * @param ray defines the ray to test with
  39587. * @returns array of intersected objects
  39588. */
  39589. intersectsRay(ray: Ray): SmartArray<T>;
  39590. /**
  39591. * Adds a mesh into the octree block if it intersects the block
  39592. */
  39593. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39594. /**
  39595. * Adds a submesh into the octree block if it intersects the block
  39596. */
  39597. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39598. }
  39599. }
  39600. declare module BABYLON {
  39601. interface Scene {
  39602. /**
  39603. * @hidden
  39604. * Backing Filed
  39605. */ selectionOctree: Octree<AbstractMesh>;
  39606. /**
  39607. * Gets the octree used to boost mesh selection (picking)
  39608. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39609. */
  39610. selectionOctree: Octree<AbstractMesh>;
  39611. /**
  39612. * Creates or updates the octree used to boost selection (picking)
  39613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39614. * @param maxCapacity defines the maximum capacity per leaf
  39615. * @param maxDepth defines the maximum depth of the octree
  39616. * @returns an octree of AbstractMesh
  39617. */
  39618. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39619. }
  39620. interface AbstractMesh {
  39621. /**
  39622. * @hidden
  39623. * Backing Field
  39624. */ submeshesOctree: Octree<SubMesh>;
  39625. /**
  39626. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39627. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39628. * @param maxCapacity defines the maximum size of each block (64 by default)
  39629. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39630. * @returns the new octree
  39631. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39632. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39633. */
  39634. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39635. }
  39636. /**
  39637. * Defines the octree scene component responsible to manage any octrees
  39638. * in a given scene.
  39639. */
  39640. export class OctreeSceneComponent {
  39641. /**
  39642. * The component name helpfull to identify the component in the list of scene components.
  39643. */
  39644. readonly name: string;
  39645. /**
  39646. * The scene the component belongs to.
  39647. */
  39648. scene: Scene;
  39649. /**
  39650. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39651. */
  39652. readonly checksIsEnabled: boolean;
  39653. /**
  39654. * Creates a new instance of the component for the given scene
  39655. * @param scene Defines the scene to register the component in
  39656. */
  39657. constructor(scene: Scene);
  39658. /**
  39659. * Registers the component in a given scene
  39660. */
  39661. register(): void;
  39662. /**
  39663. * Return the list of active meshes
  39664. * @returns the list of active meshes
  39665. */
  39666. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39667. /**
  39668. * Return the list of active sub meshes
  39669. * @param mesh The mesh to get the candidates sub meshes from
  39670. * @returns the list of active sub meshes
  39671. */
  39672. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39673. private _tempRay;
  39674. /**
  39675. * Return the list of sub meshes intersecting with a given local ray
  39676. * @param mesh defines the mesh to find the submesh for
  39677. * @param localRay defines the ray in local space
  39678. * @returns the list of intersecting sub meshes
  39679. */
  39680. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39681. /**
  39682. * Return the list of sub meshes colliding with a collider
  39683. * @param mesh defines the mesh to find the submesh for
  39684. * @param collider defines the collider to evaluate the collision against
  39685. * @returns the list of colliding sub meshes
  39686. */
  39687. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39688. /**
  39689. * Rebuilds the elements related to this component in case of
  39690. * context lost for instance.
  39691. */
  39692. rebuild(): void;
  39693. /**
  39694. * Disposes the component and the associated ressources.
  39695. */
  39696. dispose(): void;
  39697. }
  39698. }
  39699. declare module BABYLON {
  39700. /**
  39701. * Renders a layer on top of an existing scene
  39702. */
  39703. export class UtilityLayerRenderer implements IDisposable {
  39704. /** the original scene that will be rendered on top of */
  39705. originalScene: Scene;
  39706. private _pointerCaptures;
  39707. private _lastPointerEvents;
  39708. private static _DefaultUtilityLayer;
  39709. private static _DefaultKeepDepthUtilityLayer;
  39710. private _sharedGizmoLight;
  39711. /**
  39712. * @hidden
  39713. * Light which used by gizmos to get light shading
  39714. */ getSharedGizmoLight(): HemisphericLight;
  39715. /**
  39716. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39717. */
  39718. pickUtilitySceneFirst: boolean;
  39719. /**
  39720. * 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)
  39721. */
  39722. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39723. /**
  39724. * 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)
  39725. */
  39726. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39727. /**
  39728. * The scene that is rendered on top of the original scene
  39729. */
  39730. utilityLayerScene: Scene;
  39731. /**
  39732. * If the utility layer should automatically be rendered on top of existing scene
  39733. */
  39734. shouldRender: boolean;
  39735. /**
  39736. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39737. */
  39738. onlyCheckPointerDownEvents: boolean;
  39739. /**
  39740. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39741. */
  39742. processAllEvents: boolean;
  39743. /**
  39744. * Observable raised when the pointer move from the utility layer scene to the main scene
  39745. */
  39746. onPointerOutObservable: Observable<number>;
  39747. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39748. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39749. private _afterRenderObserver;
  39750. private _sceneDisposeObserver;
  39751. private _originalPointerObserver;
  39752. /**
  39753. * Instantiates a UtilityLayerRenderer
  39754. * @param originalScene the original scene that will be rendered on top of
  39755. * @param handleEvents boolean indicating if the utility layer should handle events
  39756. */
  39757. constructor(
  39758. /** the original scene that will be rendered on top of */
  39759. originalScene: Scene, handleEvents?: boolean);
  39760. private _notifyObservers;
  39761. /**
  39762. * Renders the utility layers scene on top of the original scene
  39763. */
  39764. render(): void;
  39765. /**
  39766. * Disposes of the renderer
  39767. */
  39768. dispose(): void;
  39769. private _updateCamera;
  39770. }
  39771. }
  39772. declare module BABYLON {
  39773. /**
  39774. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39775. */
  39776. export class Gizmo implements IDisposable {
  39777. /** The utility layer the gizmo will be added to */
  39778. gizmoLayer: UtilityLayerRenderer;
  39779. /**
  39780. * The root mesh of the gizmo
  39781. */ rootMesh: Mesh;
  39782. private _attachedMesh;
  39783. /**
  39784. * Ratio for the scale of the gizmo (Default: 1)
  39785. */
  39786. scaleRatio: number;
  39787. /**
  39788. * If a custom mesh has been set (Default: false)
  39789. */
  39790. protected _customMeshSet: boolean;
  39791. /**
  39792. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39793. * * When set, interactions will be enabled
  39794. */
  39795. attachedMesh: Nullable<AbstractMesh>;
  39796. /**
  39797. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39798. * @param mesh The mesh to replace the default mesh of the gizmo
  39799. */
  39800. setCustomMesh(mesh: Mesh): void;
  39801. /**
  39802. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39803. */
  39804. updateGizmoRotationToMatchAttachedMesh: boolean;
  39805. /**
  39806. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39807. */
  39808. updateGizmoPositionToMatchAttachedMesh: boolean;
  39809. /**
  39810. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39811. */
  39812. protected _updateScale: boolean;
  39813. protected _interactionsEnabled: boolean;
  39814. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39815. private _beforeRenderObserver;
  39816. private _tempVector;
  39817. /**
  39818. * Creates a gizmo
  39819. * @param gizmoLayer The utility layer the gizmo will be added to
  39820. */
  39821. constructor(
  39822. /** The utility layer the gizmo will be added to */
  39823. gizmoLayer?: UtilityLayerRenderer);
  39824. /**
  39825. * Updates the gizmo to match the attached mesh's position/rotation
  39826. */
  39827. protected _update(): void;
  39828. /**
  39829. * Disposes of the gizmo
  39830. */
  39831. dispose(): void;
  39832. }
  39833. }
  39834. declare module BABYLON {
  39835. /**
  39836. * Single axis drag gizmo
  39837. */
  39838. export class AxisDragGizmo extends Gizmo {
  39839. /**
  39840. * Drag behavior responsible for the gizmos dragging interactions
  39841. */
  39842. dragBehavior: PointerDragBehavior;
  39843. private _pointerObserver;
  39844. /**
  39845. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39846. */
  39847. snapDistance: number;
  39848. /**
  39849. * Event that fires each time the gizmo snaps to a new location.
  39850. * * snapDistance is the the change in distance
  39851. */
  39852. onSnapObservable: Observable<{
  39853. snapDistance: number;
  39854. }>;
  39855. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  39856. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  39857. /**
  39858. * Creates an AxisDragGizmo
  39859. * @param gizmoLayer The utility layer the gizmo will be added to
  39860. * @param dragAxis The axis which the gizmo will be able to drag on
  39861. * @param color The color of the gizmo
  39862. */
  39863. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  39864. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39865. /**
  39866. * Disposes of the gizmo
  39867. */
  39868. dispose(): void;
  39869. }
  39870. }
  39871. declare module BABYLON.Debug {
  39872. /**
  39873. * The Axes viewer will show 3 axes in a specific point in space
  39874. */
  39875. export class AxesViewer {
  39876. private _xAxis;
  39877. private _yAxis;
  39878. private _zAxis;
  39879. private _scaleLinesFactor;
  39880. private _instanced;
  39881. /**
  39882. * Gets the hosting scene
  39883. */
  39884. scene: Scene;
  39885. /**
  39886. * Gets or sets a number used to scale line length
  39887. */
  39888. scaleLines: number;
  39889. /** Gets the node hierarchy used to render x-axis */
  39890. readonly xAxis: TransformNode;
  39891. /** Gets the node hierarchy used to render y-axis */
  39892. readonly yAxis: TransformNode;
  39893. /** Gets the node hierarchy used to render z-axis */
  39894. readonly zAxis: TransformNode;
  39895. /**
  39896. * Creates a new AxesViewer
  39897. * @param scene defines the hosting scene
  39898. * @param scaleLines defines a number used to scale line length (1 by default)
  39899. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  39900. * @param xAxis defines the node hierarchy used to render the x-axis
  39901. * @param yAxis defines the node hierarchy used to render the y-axis
  39902. * @param zAxis defines the node hierarchy used to render the z-axis
  39903. */
  39904. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  39905. /**
  39906. * Force the viewer to update
  39907. * @param position defines the position of the viewer
  39908. * @param xaxis defines the x axis of the viewer
  39909. * @param yaxis defines the y axis of the viewer
  39910. * @param zaxis defines the z axis of the viewer
  39911. */
  39912. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  39913. /**
  39914. * Creates an instance of this axes viewer.
  39915. * @returns a new axes viewer with instanced meshes
  39916. */
  39917. createInstance(): AxesViewer;
  39918. /** Releases resources */
  39919. dispose(): void;
  39920. private static _SetRenderingGroupId;
  39921. }
  39922. }
  39923. declare module BABYLON.Debug {
  39924. /**
  39925. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  39926. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  39927. */
  39928. export class BoneAxesViewer extends AxesViewer {
  39929. /**
  39930. * Gets or sets the target mesh where to display the axes viewer
  39931. */
  39932. mesh: Nullable<Mesh>;
  39933. /**
  39934. * Gets or sets the target bone where to display the axes viewer
  39935. */
  39936. bone: Nullable<Bone>;
  39937. /** Gets current position */
  39938. pos: Vector3;
  39939. /** Gets direction of X axis */
  39940. xaxis: Vector3;
  39941. /** Gets direction of Y axis */
  39942. yaxis: Vector3;
  39943. /** Gets direction of Z axis */
  39944. zaxis: Vector3;
  39945. /**
  39946. * Creates a new BoneAxesViewer
  39947. * @param scene defines the hosting scene
  39948. * @param bone defines the target bone
  39949. * @param mesh defines the target mesh
  39950. * @param scaleLines defines a scaling factor for line length (1 by default)
  39951. */
  39952. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  39953. /**
  39954. * Force the viewer to update
  39955. */
  39956. update(): void;
  39957. /** Releases resources */
  39958. dispose(): void;
  39959. }
  39960. }
  39961. declare module BABYLON {
  39962. /**
  39963. * Interface used to define scene explorer extensibility option
  39964. */
  39965. export interface IExplorerExtensibilityOption {
  39966. /**
  39967. * Define the option label
  39968. */
  39969. label: string;
  39970. /**
  39971. * Defines the action to execute on click
  39972. */
  39973. action: (entity: any) => void;
  39974. }
  39975. /**
  39976. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  39977. */
  39978. export interface IExplorerExtensibilityGroup {
  39979. /**
  39980. * Defines a predicate to test if a given type mut be extended
  39981. */
  39982. predicate: (entity: any) => boolean;
  39983. /**
  39984. * Gets the list of options added to a type
  39985. */
  39986. entries: IExplorerExtensibilityOption[];
  39987. }
  39988. /**
  39989. * Interface used to define the options to use to create the Inspector
  39990. */
  39991. export interface IInspectorOptions {
  39992. /**
  39993. * Display in overlay mode (default: false)
  39994. */
  39995. overlay?: boolean;
  39996. /**
  39997. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  39998. */
  39999. globalRoot?: HTMLElement;
  40000. /**
  40001. * Display the Scene explorer
  40002. */
  40003. showExplorer?: boolean;
  40004. /**
  40005. * Display the property inspector
  40006. */
  40007. showInspector?: boolean;
  40008. /**
  40009. * Display in embed mode (both panes on the right)
  40010. */
  40011. embedMode?: boolean;
  40012. /**
  40013. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40014. */
  40015. handleResize?: boolean;
  40016. /**
  40017. * Allow the panes to popup (default: true)
  40018. */
  40019. enablePopup?: boolean;
  40020. /**
  40021. * Allow the panes to be closed by users (default: true)
  40022. */
  40023. enableClose?: boolean;
  40024. /**
  40025. * Optional list of extensibility entries
  40026. */
  40027. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40028. /**
  40029. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40030. */
  40031. inspectorURL?: string;
  40032. }
  40033. interface Scene {
  40034. /**
  40035. * @hidden
  40036. * Backing field
  40037. */ debugLayer: DebugLayer;
  40038. /**
  40039. * Gets the debug layer (aka Inspector) associated with the scene
  40040. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40041. */
  40042. debugLayer: DebugLayer;
  40043. }
  40044. /**
  40045. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40046. * what is happening in your scene
  40047. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40048. */
  40049. export class DebugLayer {
  40050. /**
  40051. * Define the url to get the inspector script from.
  40052. * By default it uses the babylonjs CDN.
  40053. * @ignoreNaming
  40054. */
  40055. static InspectorURL: string;
  40056. private _scene;
  40057. private BJSINSPECTOR;
  40058. /**
  40059. * Observable triggered when a property is changed through the inspector.
  40060. */
  40061. onPropertyChangedObservable: Observable<{
  40062. object: any;
  40063. property: string;
  40064. value: any;
  40065. initialValue: any;
  40066. }>;
  40067. /**
  40068. * Instantiates a new debug layer.
  40069. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40070. * what is happening in your scene
  40071. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40072. * @param scene Defines the scene to inspect
  40073. */
  40074. constructor(scene: Scene);
  40075. /** Creates the inspector window. */
  40076. private _createInspector;
  40077. /**
  40078. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40079. * @param entity defines the entity to select
  40080. * @param lineContainerTitle defines the specific block to highlight
  40081. */
  40082. select(entity: any, lineContainerTitle?: string): void;
  40083. /** Get the inspector from bundle or global */
  40084. private _getGlobalInspector;
  40085. /**
  40086. * Get if the inspector is visible or not.
  40087. * @returns true if visible otherwise, false
  40088. */
  40089. isVisible(): boolean;
  40090. /**
  40091. * Hide the inspector and close its window.
  40092. */
  40093. hide(): void;
  40094. /**
  40095. * Launch the debugLayer.
  40096. * @param config Define the configuration of the inspector
  40097. * @return a promise fulfilled when the debug layer is visible
  40098. */
  40099. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40100. }
  40101. }
  40102. declare module BABYLON {
  40103. /**
  40104. * Class containing static functions to help procedurally build meshes
  40105. */
  40106. export class BoxBuilder {
  40107. /**
  40108. * Creates a box mesh
  40109. * * The parameter `size` sets the size (float) of each box side (default 1)
  40110. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40111. * * 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)
  40112. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40114. * * 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
  40115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40116. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40117. * @param name defines the name of the mesh
  40118. * @param options defines the options used to create the mesh
  40119. * @param scene defines the hosting scene
  40120. * @returns the box mesh
  40121. */
  40122. static CreateBox(name: string, options: {
  40123. size?: number;
  40124. width?: number;
  40125. height?: number;
  40126. depth?: number;
  40127. faceUV?: Vector4[];
  40128. faceColors?: Color4[];
  40129. sideOrientation?: number;
  40130. frontUVs?: Vector4;
  40131. backUVs?: Vector4;
  40132. wrap?: boolean;
  40133. topBaseAt?: number;
  40134. bottomBaseAt?: number;
  40135. updatable?: boolean;
  40136. }, scene?: Nullable<Scene>): Mesh;
  40137. }
  40138. }
  40139. declare module BABYLON {
  40140. /**
  40141. * Class containing static functions to help procedurally build meshes
  40142. */
  40143. export class SphereBuilder {
  40144. /**
  40145. * Creates a sphere mesh
  40146. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40147. * * 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`)
  40148. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40149. * * 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
  40150. * * 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)
  40151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40152. * * 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
  40153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40154. * @param name defines the name of the mesh
  40155. * @param options defines the options used to create the mesh
  40156. * @param scene defines the hosting scene
  40157. * @returns the sphere mesh
  40158. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40159. */
  40160. static CreateSphere(name: string, options: {
  40161. segments?: number;
  40162. diameter?: number;
  40163. diameterX?: number;
  40164. diameterY?: number;
  40165. diameterZ?: number;
  40166. arc?: number;
  40167. slice?: number;
  40168. sideOrientation?: number;
  40169. frontUVs?: Vector4;
  40170. backUVs?: Vector4;
  40171. updatable?: boolean;
  40172. }, scene: any): Mesh;
  40173. }
  40174. }
  40175. declare module BABYLON.Debug {
  40176. /**
  40177. * Used to show the physics impostor around the specific mesh
  40178. */
  40179. export class PhysicsViewer {
  40180. /** @hidden */
  40181. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40182. /** @hidden */
  40183. protected _meshes: Array<Nullable<AbstractMesh>>;
  40184. /** @hidden */
  40185. protected _scene: Nullable<Scene>;
  40186. /** @hidden */
  40187. protected _numMeshes: number;
  40188. /** @hidden */
  40189. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40190. private _renderFunction;
  40191. private _utilityLayer;
  40192. private _debugBoxMesh;
  40193. private _debugSphereMesh;
  40194. private _debugCylinderMesh;
  40195. private _debugMaterial;
  40196. private _debugMeshMeshes;
  40197. /**
  40198. * Creates a new PhysicsViewer
  40199. * @param scene defines the hosting scene
  40200. */
  40201. constructor(scene: Scene);
  40202. /** @hidden */
  40203. protected _updateDebugMeshes(): void;
  40204. /**
  40205. * Renders a specified physic impostor
  40206. * @param impostor defines the impostor to render
  40207. * @param targetMesh defines the mesh represented by the impostor
  40208. * @returns the new debug mesh used to render the impostor
  40209. */
  40210. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40211. /**
  40212. * Hides a specified physic impostor
  40213. * @param impostor defines the impostor to hide
  40214. */
  40215. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40216. private _getDebugMaterial;
  40217. private _getDebugBoxMesh;
  40218. private _getDebugSphereMesh;
  40219. private _getDebugCylinderMesh;
  40220. private _getDebugMeshMesh;
  40221. private _getDebugMesh;
  40222. /** Releases all resources */
  40223. dispose(): void;
  40224. }
  40225. }
  40226. declare module BABYLON {
  40227. /**
  40228. * Class containing static functions to help procedurally build meshes
  40229. */
  40230. export class LinesBuilder {
  40231. /**
  40232. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40233. * * 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
  40234. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40235. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40236. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40237. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40238. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40239. * * 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
  40240. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40242. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40243. * @param name defines the name of the new line system
  40244. * @param options defines the options used to create the line system
  40245. * @param scene defines the hosting scene
  40246. * @returns a new line system mesh
  40247. */
  40248. static CreateLineSystem(name: string, options: {
  40249. lines: Vector3[][];
  40250. updatable?: boolean;
  40251. instance?: Nullable<LinesMesh>;
  40252. colors?: Nullable<Color4[][]>;
  40253. useVertexAlpha?: boolean;
  40254. }, scene: Nullable<Scene>): LinesMesh;
  40255. /**
  40256. * Creates a line mesh
  40257. * 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
  40258. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40259. * * The parameter `points` is an array successive Vector3
  40260. * * 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
  40261. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40262. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40263. * * When updating an instance, remember that only point positions can change, not the number of points
  40264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40265. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40266. * @param name defines the name of the new line system
  40267. * @param options defines the options used to create the line system
  40268. * @param scene defines the hosting scene
  40269. * @returns a new line mesh
  40270. */
  40271. static CreateLines(name: string, options: {
  40272. points: Vector3[];
  40273. updatable?: boolean;
  40274. instance?: Nullable<LinesMesh>;
  40275. colors?: Color4[];
  40276. useVertexAlpha?: boolean;
  40277. }, scene?: Nullable<Scene>): LinesMesh;
  40278. /**
  40279. * Creates a dashed line mesh
  40280. * * 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
  40281. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40282. * * The parameter `points` is an array successive Vector3
  40283. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40284. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40285. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40286. * * 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
  40287. * * When updating an instance, remember that only point positions can change, not the number of points
  40288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40289. * @param name defines the name of the mesh
  40290. * @param options defines the options used to create the mesh
  40291. * @param scene defines the hosting scene
  40292. * @returns the dashed line mesh
  40293. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40294. */
  40295. static CreateDashedLines(name: string, options: {
  40296. points: Vector3[];
  40297. dashSize?: number;
  40298. gapSize?: number;
  40299. dashNb?: number;
  40300. updatable?: boolean;
  40301. instance?: LinesMesh;
  40302. }, scene?: Nullable<Scene>): LinesMesh;
  40303. }
  40304. }
  40305. declare module BABYLON {
  40306. /**
  40307. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40308. * in order to better appreciate the issue one might have.
  40309. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40310. */
  40311. export class RayHelper {
  40312. /**
  40313. * Defines the ray we are currently tryin to visualize.
  40314. */
  40315. ray: Nullable<Ray>;
  40316. private _renderPoints;
  40317. private _renderLine;
  40318. private _renderFunction;
  40319. private _scene;
  40320. private _updateToMeshFunction;
  40321. private _attachedToMesh;
  40322. private _meshSpaceDirection;
  40323. private _meshSpaceOrigin;
  40324. /**
  40325. * Helper function to create a colored helper in a scene in one line.
  40326. * @param ray Defines the ray we are currently tryin to visualize
  40327. * @param scene Defines the scene the ray is used in
  40328. * @param color Defines the color we want to see the ray in
  40329. * @returns The newly created ray helper.
  40330. */
  40331. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40332. /**
  40333. * Instantiate a new ray helper.
  40334. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40335. * in order to better appreciate the issue one might have.
  40336. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40337. * @param ray Defines the ray we are currently tryin to visualize
  40338. */
  40339. constructor(ray: Ray);
  40340. /**
  40341. * Shows the ray we are willing to debug.
  40342. * @param scene Defines the scene the ray needs to be rendered in
  40343. * @param color Defines the color the ray needs to be rendered in
  40344. */
  40345. show(scene: Scene, color?: Color3): void;
  40346. /**
  40347. * Hides the ray we are debugging.
  40348. */
  40349. hide(): void;
  40350. private _render;
  40351. /**
  40352. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40353. * @param mesh Defines the mesh we want the helper attached to
  40354. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40355. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40356. * @param length Defines the length of the ray
  40357. */
  40358. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40359. /**
  40360. * Detach the ray helper from the mesh it has previously been attached to.
  40361. */
  40362. detachFromMesh(): void;
  40363. private _updateToMesh;
  40364. /**
  40365. * Dispose the helper and release its associated resources.
  40366. */
  40367. dispose(): void;
  40368. }
  40369. }
  40370. declare module BABYLON.Debug {
  40371. /**
  40372. * Class used to render a debug view of a given skeleton
  40373. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40374. */
  40375. export class SkeletonViewer {
  40376. /** defines the skeleton to render */
  40377. skeleton: Skeleton;
  40378. /** defines the mesh attached to the skeleton */
  40379. mesh: AbstractMesh;
  40380. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40381. autoUpdateBonesMatrices: boolean;
  40382. /** defines the rendering group id to use with the viewer */
  40383. renderingGroupId: number;
  40384. /** Gets or sets the color used to render the skeleton */
  40385. color: Color3;
  40386. private _scene;
  40387. private _debugLines;
  40388. private _debugMesh;
  40389. private _isEnabled;
  40390. private _renderFunction;
  40391. private _utilityLayer;
  40392. /**
  40393. * Returns the mesh used to render the bones
  40394. */
  40395. readonly debugMesh: Nullable<LinesMesh>;
  40396. /**
  40397. * Creates a new SkeletonViewer
  40398. * @param skeleton defines the skeleton to render
  40399. * @param mesh defines the mesh attached to the skeleton
  40400. * @param scene defines the hosting scene
  40401. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40402. * @param renderingGroupId defines the rendering group id to use with the viewer
  40403. */
  40404. constructor(
  40405. /** defines the skeleton to render */
  40406. skeleton: Skeleton,
  40407. /** defines the mesh attached to the skeleton */
  40408. mesh: AbstractMesh, scene: Scene,
  40409. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40410. autoUpdateBonesMatrices?: boolean,
  40411. /** defines the rendering group id to use with the viewer */
  40412. renderingGroupId?: number);
  40413. /** Gets or sets a boolean indicating if the viewer is enabled */
  40414. isEnabled: boolean;
  40415. private _getBonePosition;
  40416. private _getLinesForBonesWithLength;
  40417. private _getLinesForBonesNoLength;
  40418. /** Update the viewer to sync with current skeleton state */
  40419. update(): void;
  40420. /** Release associated resources */
  40421. dispose(): void;
  40422. }
  40423. }
  40424. declare module BABYLON {
  40425. /**
  40426. * Options to create the null engine
  40427. */
  40428. export class NullEngineOptions {
  40429. /**
  40430. * Render width (Default: 512)
  40431. */
  40432. renderWidth: number;
  40433. /**
  40434. * Render height (Default: 256)
  40435. */
  40436. renderHeight: number;
  40437. /**
  40438. * Texture size (Default: 512)
  40439. */
  40440. textureSize: number;
  40441. /**
  40442. * If delta time between frames should be constant
  40443. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40444. */
  40445. deterministicLockstep: boolean;
  40446. /**
  40447. * Maximum about of steps between frames (Default: 4)
  40448. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40449. */
  40450. lockstepMaxSteps: number;
  40451. }
  40452. /**
  40453. * The null engine class provides support for headless version of babylon.js.
  40454. * This can be used in server side scenario or for testing purposes
  40455. */
  40456. export class NullEngine extends Engine {
  40457. private _options;
  40458. /**
  40459. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40460. */
  40461. isDeterministicLockStep(): boolean;
  40462. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40463. getLockstepMaxSteps(): number;
  40464. /**
  40465. * Sets hardware scaling, used to save performance if needed
  40466. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40467. */
  40468. getHardwareScalingLevel(): number;
  40469. constructor(options?: NullEngineOptions);
  40470. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40471. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  40472. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40473. getRenderWidth(useScreen?: boolean): number;
  40474. getRenderHeight(useScreen?: boolean): number;
  40475. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40476. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40477. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  40478. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  40479. bindSamplers(effect: Effect): void;
  40480. enableEffect(effect: Effect): void;
  40481. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40482. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40483. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40484. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40485. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40486. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40487. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40488. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40489. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40490. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40491. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40492. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40493. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40494. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40495. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40496. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40497. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40498. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40499. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40500. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40501. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40502. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40503. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40504. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40505. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40506. bindBuffers(vertexBuffers: {
  40507. [key: string]: VertexBuffer;
  40508. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  40509. wipeCaches(bruteForce?: boolean): void;
  40510. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40511. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40512. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40513. /** @hidden */ createTexture(): WebGLTexture;
  40514. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  40515. 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;
  40516. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40517. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40518. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40519. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40520. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40521. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40522. areAllEffectsReady(): boolean;
  40523. /**
  40524. * @hidden
  40525. * Get the current error code of the webGL context
  40526. * @returns the error code
  40527. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40528. */
  40529. getError(): number;
  40530. /** @hidden */ getUnpackAlignement(): number;
  40531. /** @hidden */ unpackFlipY(value: boolean): void;
  40532. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40533. /**
  40534. * Updates a dynamic vertex buffer.
  40535. * @param vertexBuffer the vertex buffer to update
  40536. * @param data the data used to update the vertex buffer
  40537. * @param byteOffset the byte offset of the data (optional)
  40538. * @param byteLength the byte length of the data (optional)
  40539. */
  40540. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40541. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  40542. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  40543. releaseEffects(): void;
  40544. displayLoadingUI(): void;
  40545. hideLoadingUI(): void;
  40546. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40547. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40548. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40549. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40550. }
  40551. }
  40552. declare module BABYLON {
  40553. /** @hidden */
  40554. export class _OcclusionDataStorage {
  40555. /** @hidden */
  40556. occlusionInternalRetryCounter: number;
  40557. /** @hidden */
  40558. isOcclusionQueryInProgress: boolean;
  40559. /** @hidden */
  40560. isOccluded: boolean;
  40561. /** @hidden */
  40562. occlusionRetryCount: number;
  40563. /** @hidden */
  40564. occlusionType: number;
  40565. /** @hidden */
  40566. occlusionQueryAlgorithmType: number;
  40567. }
  40568. interface Engine {
  40569. /**
  40570. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40571. * @return the new query
  40572. */
  40573. createQuery(): WebGLQuery;
  40574. /**
  40575. * Delete and release a webGL query
  40576. * @param query defines the query to delete
  40577. * @return the current engine
  40578. */
  40579. deleteQuery(query: WebGLQuery): Engine;
  40580. /**
  40581. * Check if a given query has resolved and got its value
  40582. * @param query defines the query to check
  40583. * @returns true if the query got its value
  40584. */
  40585. isQueryResultAvailable(query: WebGLQuery): boolean;
  40586. /**
  40587. * Gets the value of a given query
  40588. * @param query defines the query to check
  40589. * @returns the value of the query
  40590. */
  40591. getQueryResult(query: WebGLQuery): number;
  40592. /**
  40593. * Initiates an occlusion query
  40594. * @param algorithmType defines the algorithm to use
  40595. * @param query defines the query to use
  40596. * @returns the current engine
  40597. * @see http://doc.babylonjs.com/features/occlusionquery
  40598. */
  40599. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40600. /**
  40601. * Ends an occlusion query
  40602. * @see http://doc.babylonjs.com/features/occlusionquery
  40603. * @param algorithmType defines the algorithm to use
  40604. * @returns the current engine
  40605. */
  40606. endOcclusionQuery(algorithmType: number): Engine;
  40607. /**
  40608. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40609. * Please note that only one query can be issued at a time
  40610. * @returns a time token used to track the time span
  40611. */
  40612. startTimeQuery(): Nullable<_TimeToken>;
  40613. /**
  40614. * Ends a time query
  40615. * @param token defines the token used to measure the time span
  40616. * @returns the time spent (in ns)
  40617. */
  40618. endTimeQuery(token: _TimeToken): int;
  40619. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  40620. /** @hidden */ createTimeQuery(): WebGLQuery;
  40621. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  40622. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  40623. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  40624. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  40625. }
  40626. interface AbstractMesh {
  40627. /**
  40628. * Backing filed
  40629. * @hidden
  40630. */ private _occlusionDataStorage: _OcclusionDataStorage;
  40631. /**
  40632. * Access property
  40633. * @hidden
  40634. */ occlusionDataStorage: _OcclusionDataStorage;
  40635. /**
  40636. * 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.
  40637. * The default value is -1 which means don't break the query and wait till the result
  40638. * @see http://doc.babylonjs.com/features/occlusionquery
  40639. */
  40640. occlusionRetryCount: number;
  40641. /**
  40642. * 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:
  40643. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40644. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40645. * * 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.
  40646. * @see http://doc.babylonjs.com/features/occlusionquery
  40647. */
  40648. occlusionType: number;
  40649. /**
  40650. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40651. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40652. * * 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.
  40653. * @see http://doc.babylonjs.com/features/occlusionquery
  40654. */
  40655. occlusionQueryAlgorithmType: number;
  40656. /**
  40657. * 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
  40658. * @see http://doc.babylonjs.com/features/occlusionquery
  40659. */
  40660. isOccluded: boolean;
  40661. /**
  40662. * Flag to check the progress status of the query
  40663. * @see http://doc.babylonjs.com/features/occlusionquery
  40664. */
  40665. isOcclusionQueryInProgress: boolean;
  40666. }
  40667. }
  40668. declare module BABYLON {
  40669. /** @hidden */
  40670. export var _forceTransformFeedbackToBundle: boolean;
  40671. interface Engine {
  40672. /**
  40673. * Creates a webGL transform feedback object
  40674. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40675. * @returns the webGL transform feedback object
  40676. */
  40677. createTransformFeedback(): WebGLTransformFeedback;
  40678. /**
  40679. * Delete a webGL transform feedback object
  40680. * @param value defines the webGL transform feedback object to delete
  40681. */
  40682. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40683. /**
  40684. * Bind a webGL transform feedback object to the webgl context
  40685. * @param value defines the webGL transform feedback object to bind
  40686. */
  40687. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40688. /**
  40689. * Begins a transform feedback operation
  40690. * @param usePoints defines if points or triangles must be used
  40691. */
  40692. beginTransformFeedback(usePoints: boolean): void;
  40693. /**
  40694. * Ends a transform feedback operation
  40695. */
  40696. endTransformFeedback(): void;
  40697. /**
  40698. * Specify the varyings to use with transform feedback
  40699. * @param program defines the associated webGL program
  40700. * @param value defines the list of strings representing the varying names
  40701. */
  40702. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40703. /**
  40704. * Bind a webGL buffer for a transform feedback operation
  40705. * @param value defines the webGL buffer to bind
  40706. */
  40707. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40708. }
  40709. }
  40710. declare module BABYLON {
  40711. /**
  40712. * Creation options of the multi render target texture.
  40713. */
  40714. export interface IMultiRenderTargetOptions {
  40715. /**
  40716. * Define if the texture needs to create mip maps after render.
  40717. */
  40718. generateMipMaps?: boolean;
  40719. /**
  40720. * Define the types of all the draw buffers we want to create
  40721. */
  40722. types?: number[];
  40723. /**
  40724. * Define the sampling modes of all the draw buffers we want to create
  40725. */
  40726. samplingModes?: number[];
  40727. /**
  40728. * Define if a depth buffer is required
  40729. */
  40730. generateDepthBuffer?: boolean;
  40731. /**
  40732. * Define if a stencil buffer is required
  40733. */
  40734. generateStencilBuffer?: boolean;
  40735. /**
  40736. * Define if a depth texture is required instead of a depth buffer
  40737. */
  40738. generateDepthTexture?: boolean;
  40739. /**
  40740. * Define the number of desired draw buffers
  40741. */
  40742. textureCount?: number;
  40743. /**
  40744. * Define if aspect ratio should be adapted to the texture or stay the scene one
  40745. */
  40746. doNotChangeAspectRatio?: boolean;
  40747. /**
  40748. * Define the default type of the buffers we are creating
  40749. */
  40750. defaultType?: number;
  40751. }
  40752. /**
  40753. * A multi render target, like a render target provides the ability to render to a texture.
  40754. * Unlike the render target, it can render to several draw buffers in one draw.
  40755. * This is specially interesting in deferred rendering or for any effects requiring more than
  40756. * just one color from a single pass.
  40757. */
  40758. export class MultiRenderTarget extends RenderTargetTexture {
  40759. private _internalTextures;
  40760. private _textures;
  40761. private _multiRenderTargetOptions;
  40762. /**
  40763. * Get if draw buffers are currently supported by the used hardware and browser.
  40764. */
  40765. readonly isSupported: boolean;
  40766. /**
  40767. * Get the list of textures generated by the multi render target.
  40768. */
  40769. readonly textures: Texture[];
  40770. /**
  40771. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  40772. */
  40773. readonly depthTexture: Texture;
  40774. /**
  40775. * Set the wrapping mode on U of all the textures we are rendering to.
  40776. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40777. */
  40778. wrapU: number;
  40779. /**
  40780. * Set the wrapping mode on V of all the textures we are rendering to.
  40781. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40782. */
  40783. wrapV: number;
  40784. /**
  40785. * Instantiate a new multi render target texture.
  40786. * A multi render target, like a render target provides the ability to render to a texture.
  40787. * Unlike the render target, it can render to several draw buffers in one draw.
  40788. * This is specially interesting in deferred rendering or for any effects requiring more than
  40789. * just one color from a single pass.
  40790. * @param name Define the name of the texture
  40791. * @param size Define the size of the buffers to render to
  40792. * @param count Define the number of target we are rendering into
  40793. * @param scene Define the scene the texture belongs to
  40794. * @param options Define the options used to create the multi render target
  40795. */
  40796. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  40797. /** @hidden */ rebuild(): void;
  40798. private _createInternalTextures;
  40799. private _createTextures;
  40800. /**
  40801. * Define the number of samples used if MSAA is enabled.
  40802. */
  40803. samples: number;
  40804. /**
  40805. * Resize all the textures in the multi render target.
  40806. * Be carrefull as it will recreate all the data in the new texture.
  40807. * @param size Define the new size
  40808. */
  40809. resize(size: any): void;
  40810. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  40811. /**
  40812. * Dispose the render targets and their associated resources
  40813. */
  40814. dispose(): void;
  40815. /**
  40816. * Release all the underlying texture used as draw buffers.
  40817. */
  40818. releaseInternalTextures(): void;
  40819. }
  40820. }
  40821. declare module BABYLON {
  40822. interface Engine {
  40823. /**
  40824. * Unbind a list of render target textures from the webGL context
  40825. * This is used only when drawBuffer extension or webGL2 are active
  40826. * @param textures defines the render target textures to unbind
  40827. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40828. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40829. */
  40830. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  40831. /**
  40832. * Create a multi render target texture
  40833. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  40834. * @param size defines the size of the texture
  40835. * @param options defines the creation options
  40836. * @returns the cube texture as an InternalTexture
  40837. */
  40838. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  40839. /**
  40840. * Update the sample count for a given multiple render target texture
  40841. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  40842. * @param textures defines the textures to update
  40843. * @param samples defines the sample count to set
  40844. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  40845. */
  40846. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  40847. }
  40848. }
  40849. declare module BABYLON {
  40850. /**
  40851. * Gather the list of clipboard event types as constants.
  40852. */
  40853. export class ClipboardEventTypes {
  40854. /**
  40855. * The clipboard event is fired when a copy command is active (pressed).
  40856. */
  40857. static readonly COPY: number;
  40858. /**
  40859. * The clipboard event is fired when a cut command is active (pressed).
  40860. */
  40861. static readonly CUT: number;
  40862. /**
  40863. * The clipboard event is fired when a paste command is active (pressed).
  40864. */
  40865. static readonly PASTE: number;
  40866. }
  40867. /**
  40868. * This class is used to store clipboard related info for the onClipboardObservable event.
  40869. */
  40870. export class ClipboardInfo {
  40871. /**
  40872. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40873. */
  40874. type: number;
  40875. /**
  40876. * Defines the related dom event
  40877. */
  40878. event: ClipboardEvent;
  40879. /**
  40880. *Creates an instance of ClipboardInfo.
  40881. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  40882. * @param event Defines the related dom event
  40883. */
  40884. constructor(
  40885. /**
  40886. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40887. */
  40888. type: number,
  40889. /**
  40890. * Defines the related dom event
  40891. */
  40892. event: ClipboardEvent);
  40893. /**
  40894. * Get the clipboard event's type from the keycode.
  40895. * @param keyCode Defines the keyCode for the current keyboard event.
  40896. * @return {number}
  40897. */
  40898. static GetTypeFromCharacter(keyCode: number): number;
  40899. }
  40900. }
  40901. declare module BABYLON {
  40902. /**
  40903. * Class used to represent data loading progression
  40904. */
  40905. export class SceneLoaderProgressEvent {
  40906. /** defines if data length to load can be evaluated */
  40907. readonly lengthComputable: boolean;
  40908. /** defines the loaded data length */
  40909. readonly loaded: number;
  40910. /** defines the data length to load */
  40911. readonly total: number;
  40912. /**
  40913. * Create a new progress event
  40914. * @param lengthComputable defines if data length to load can be evaluated
  40915. * @param loaded defines the loaded data length
  40916. * @param total defines the data length to load
  40917. */
  40918. constructor(
  40919. /** defines if data length to load can be evaluated */
  40920. lengthComputable: boolean,
  40921. /** defines the loaded data length */
  40922. loaded: number,
  40923. /** defines the data length to load */
  40924. total: number);
  40925. /**
  40926. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40927. * @param event defines the source event
  40928. * @returns a new SceneLoaderProgressEvent
  40929. */
  40930. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40931. }
  40932. /**
  40933. * Interface used by SceneLoader plugins to define supported file extensions
  40934. */
  40935. export interface ISceneLoaderPluginExtensions {
  40936. /**
  40937. * Defines the list of supported extensions
  40938. */
  40939. [extension: string]: {
  40940. isBinary: boolean;
  40941. };
  40942. }
  40943. /**
  40944. * Interface used by SceneLoader plugin factory
  40945. */
  40946. export interface ISceneLoaderPluginFactory {
  40947. /**
  40948. * Defines the name of the factory
  40949. */
  40950. name: string;
  40951. /**
  40952. * Function called to create a new plugin
  40953. * @return the new plugin
  40954. */
  40955. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40956. /**
  40957. * Boolean indicating if the plugin can direct load specific data
  40958. */
  40959. canDirectLoad?: (data: string) => boolean;
  40960. }
  40961. /**
  40962. * Interface used to define a SceneLoader plugin
  40963. */
  40964. export interface ISceneLoaderPlugin {
  40965. /**
  40966. * The friendly name of this plugin.
  40967. */
  40968. name: string;
  40969. /**
  40970. * The file extensions supported by this plugin.
  40971. */
  40972. extensions: string | ISceneLoaderPluginExtensions;
  40973. /**
  40974. * Import meshes into a scene.
  40975. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40976. * @param scene The scene to import into
  40977. * @param data The data to import
  40978. * @param rootUrl The root url for scene and resources
  40979. * @param meshes The meshes array to import into
  40980. * @param particleSystems The particle systems array to import into
  40981. * @param skeletons The skeletons array to import into
  40982. * @param onError The callback when import fails
  40983. * @returns True if successful or false otherwise
  40984. */
  40985. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40986. /**
  40987. * Load into a scene.
  40988. * @param scene The scene to load into
  40989. * @param data The data to import
  40990. * @param rootUrl The root url for scene and resources
  40991. * @param onError The callback when import fails
  40992. * @returns true if successful or false otherwise
  40993. */
  40994. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40995. /**
  40996. * The callback that returns true if the data can be directly loaded.
  40997. */
  40998. canDirectLoad?: (data: string) => boolean;
  40999. /**
  41000. * The callback that allows custom handling of the root url based on the response url.
  41001. */
  41002. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41003. /**
  41004. * Load into an asset container.
  41005. * @param scene The scene to load into
  41006. * @param data The data to import
  41007. * @param rootUrl The root url for scene and resources
  41008. * @param onError The callback when import fails
  41009. * @returns The loaded asset container
  41010. */
  41011. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41012. }
  41013. /**
  41014. * Interface used to define an async SceneLoader plugin
  41015. */
  41016. export interface ISceneLoaderPluginAsync {
  41017. /**
  41018. * The friendly name of this plugin.
  41019. */
  41020. name: string;
  41021. /**
  41022. * The file extensions supported by this plugin.
  41023. */
  41024. extensions: string | ISceneLoaderPluginExtensions;
  41025. /**
  41026. * Import meshes into a scene.
  41027. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41028. * @param scene The scene to import into
  41029. * @param data The data to import
  41030. * @param rootUrl The root url for scene and resources
  41031. * @param onProgress The callback when the load progresses
  41032. * @param fileName Defines the name of the file to load
  41033. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41034. */
  41035. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41036. meshes: AbstractMesh[];
  41037. particleSystems: IParticleSystem[];
  41038. skeletons: Skeleton[];
  41039. animationGroups: AnimationGroup[];
  41040. }>;
  41041. /**
  41042. * Load into a scene.
  41043. * @param scene The scene to load into
  41044. * @param data The data to import
  41045. * @param rootUrl The root url for scene and resources
  41046. * @param onProgress The callback when the load progresses
  41047. * @param fileName Defines the name of the file to load
  41048. * @returns Nothing
  41049. */
  41050. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41051. /**
  41052. * The callback that returns true if the data can be directly loaded.
  41053. */
  41054. canDirectLoad?: (data: string) => boolean;
  41055. /**
  41056. * The callback that allows custom handling of the root url based on the response url.
  41057. */
  41058. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41059. /**
  41060. * Load into an asset container.
  41061. * @param scene The scene to load into
  41062. * @param data The data to import
  41063. * @param rootUrl The root url for scene and resources
  41064. * @param onProgress The callback when the load progresses
  41065. * @param fileName Defines the name of the file to load
  41066. * @returns The loaded asset container
  41067. */
  41068. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41069. }
  41070. /**
  41071. * Class used to load scene from various file formats using registered plugins
  41072. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41073. */
  41074. export class SceneLoader {
  41075. /**
  41076. * No logging while loading
  41077. */
  41078. static readonly NO_LOGGING: number;
  41079. /**
  41080. * Minimal logging while loading
  41081. */
  41082. static readonly MINIMAL_LOGGING: number;
  41083. /**
  41084. * Summary logging while loading
  41085. */
  41086. static readonly SUMMARY_LOGGING: number;
  41087. /**
  41088. * Detailled logging while loading
  41089. */
  41090. static readonly DETAILED_LOGGING: number;
  41091. /**
  41092. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41093. */
  41094. static ForceFullSceneLoadingForIncremental: boolean;
  41095. /**
  41096. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41097. */
  41098. static ShowLoadingScreen: boolean;
  41099. /**
  41100. * Defines the current logging level (while loading the scene)
  41101. * @ignorenaming
  41102. */
  41103. static loggingLevel: number;
  41104. /**
  41105. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41106. */
  41107. static CleanBoneMatrixWeights: boolean;
  41108. /**
  41109. * Event raised when a plugin is used to load a scene
  41110. */
  41111. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41112. private static _registeredPlugins;
  41113. private static _getDefaultPlugin;
  41114. private static _getPluginForExtension;
  41115. private static _getPluginForDirectLoad;
  41116. private static _getPluginForFilename;
  41117. private static _getDirectLoad;
  41118. private static _loadData;
  41119. private static _getFileInfo;
  41120. /**
  41121. * Gets a plugin that can load the given extension
  41122. * @param extension defines the extension to load
  41123. * @returns a plugin or null if none works
  41124. */
  41125. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41126. /**
  41127. * Gets a boolean indicating that the given extension can be loaded
  41128. * @param extension defines the extension to load
  41129. * @returns true if the extension is supported
  41130. */
  41131. static IsPluginForExtensionAvailable(extension: string): boolean;
  41132. /**
  41133. * Adds a new plugin to the list of registered plugins
  41134. * @param plugin defines the plugin to add
  41135. */
  41136. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41137. /**
  41138. * Import meshes into a scene
  41139. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41140. * @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)
  41141. * @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)
  41142. * @param scene the instance of BABYLON.Scene to append to
  41143. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41144. * @param onProgress a callback with a progress event for each file being loaded
  41145. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41146. * @param pluginExtension the extension used to determine the plugin
  41147. * @returns The loaded plugin
  41148. */
  41149. 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>;
  41150. /**
  41151. * Import meshes into a scene
  41152. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41153. * @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)
  41154. * @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)
  41155. * @param scene the instance of BABYLON.Scene to append to
  41156. * @param onProgress a callback with a progress event for each file being loaded
  41157. * @param pluginExtension the extension used to determine the plugin
  41158. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41159. */
  41160. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41161. meshes: AbstractMesh[];
  41162. particleSystems: IParticleSystem[];
  41163. skeletons: Skeleton[];
  41164. animationGroups: AnimationGroup[];
  41165. }>;
  41166. /**
  41167. * Load a scene
  41168. * @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)
  41169. * @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)
  41170. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41171. * @param onSuccess a callback with the scene when import succeeds
  41172. * @param onProgress a callback with a progress event for each file being loaded
  41173. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41174. * @param pluginExtension the extension used to determine the plugin
  41175. * @returns The loaded plugin
  41176. */
  41177. 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>;
  41178. /**
  41179. * Load a scene
  41180. * @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)
  41181. * @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)
  41182. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41183. * @param onProgress a callback with a progress event for each file being loaded
  41184. * @param pluginExtension the extension used to determine the plugin
  41185. * @returns The loaded scene
  41186. */
  41187. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41188. /**
  41189. * Append a scene
  41190. * @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)
  41191. * @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)
  41192. * @param scene is the instance of BABYLON.Scene to append to
  41193. * @param onSuccess a callback with the scene when import succeeds
  41194. * @param onProgress a callback with a progress event for each file being loaded
  41195. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41196. * @param pluginExtension the extension used to determine the plugin
  41197. * @returns The loaded plugin
  41198. */
  41199. 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>;
  41200. /**
  41201. * Append a scene
  41202. * @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)
  41203. * @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)
  41204. * @param scene is the instance of BABYLON.Scene to append to
  41205. * @param onProgress a callback with a progress event for each file being loaded
  41206. * @param pluginExtension the extension used to determine the plugin
  41207. * @returns The given scene
  41208. */
  41209. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41210. /**
  41211. * Load a scene into an asset container
  41212. * @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)
  41213. * @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)
  41214. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41215. * @param onSuccess a callback with the scene when import succeeds
  41216. * @param onProgress a callback with a progress event for each file being loaded
  41217. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41218. * @param pluginExtension the extension used to determine the plugin
  41219. * @returns The loaded plugin
  41220. */
  41221. 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>;
  41222. /**
  41223. * Load a scene into an asset container
  41224. * @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)
  41225. * @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)
  41226. * @param scene is the instance of Scene to append to
  41227. * @param onProgress a callback with a progress event for each file being loaded
  41228. * @param pluginExtension the extension used to determine the plugin
  41229. * @returns The loaded asset container
  41230. */
  41231. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41232. }
  41233. }
  41234. declare module BABYLON {
  41235. /**
  41236. * Google Daydream controller
  41237. */
  41238. export class DaydreamController extends WebVRController {
  41239. /**
  41240. * Base Url for the controller model.
  41241. */
  41242. static MODEL_BASE_URL: string;
  41243. /**
  41244. * File name for the controller model.
  41245. */
  41246. static MODEL_FILENAME: string;
  41247. /**
  41248. * Gamepad Id prefix used to identify Daydream Controller.
  41249. */
  41250. static readonly GAMEPAD_ID_PREFIX: string;
  41251. /**
  41252. * Creates a new DaydreamController from a gamepad
  41253. * @param vrGamepad the gamepad that the controller should be created from
  41254. */
  41255. constructor(vrGamepad: any);
  41256. /**
  41257. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41258. * @param scene scene in which to add meshes
  41259. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41260. */
  41261. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41262. /**
  41263. * Called once for each button that changed state since the last frame
  41264. * @param buttonIdx Which button index changed
  41265. * @param state New state of the button
  41266. * @param changes Which properties on the state changed since last frame
  41267. */
  41268. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41269. }
  41270. }
  41271. declare module BABYLON {
  41272. /**
  41273. * Gear VR Controller
  41274. */
  41275. export class GearVRController extends WebVRController {
  41276. /**
  41277. * Base Url for the controller model.
  41278. */
  41279. static MODEL_BASE_URL: string;
  41280. /**
  41281. * File name for the controller model.
  41282. */
  41283. static MODEL_FILENAME: string;
  41284. /**
  41285. * Gamepad Id prefix used to identify this controller.
  41286. */
  41287. static readonly GAMEPAD_ID_PREFIX: string;
  41288. private readonly _buttonIndexToObservableNameMap;
  41289. /**
  41290. * Creates a new GearVRController from a gamepad
  41291. * @param vrGamepad the gamepad that the controller should be created from
  41292. */
  41293. constructor(vrGamepad: any);
  41294. /**
  41295. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41296. * @param scene scene in which to add meshes
  41297. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41298. */
  41299. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41300. /**
  41301. * Called once for each button that changed state since the last frame
  41302. * @param buttonIdx Which button index changed
  41303. * @param state New state of the button
  41304. * @param changes Which properties on the state changed since last frame
  41305. */
  41306. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41307. }
  41308. }
  41309. declare module BABYLON {
  41310. /**
  41311. * Generic Controller
  41312. */
  41313. export class GenericController extends WebVRController {
  41314. /**
  41315. * Base Url for the controller model.
  41316. */
  41317. static readonly MODEL_BASE_URL: string;
  41318. /**
  41319. * File name for the controller model.
  41320. */
  41321. static readonly MODEL_FILENAME: string;
  41322. /**
  41323. * Creates a new GenericController from a gamepad
  41324. * @param vrGamepad the gamepad that the controller should be created from
  41325. */
  41326. constructor(vrGamepad: any);
  41327. /**
  41328. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41329. * @param scene scene in which to add meshes
  41330. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41331. */
  41332. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41333. /**
  41334. * Called once for each button that changed state since the last frame
  41335. * @param buttonIdx Which button index changed
  41336. * @param state New state of the button
  41337. * @param changes Which properties on the state changed since last frame
  41338. */
  41339. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41340. }
  41341. }
  41342. declare module BABYLON {
  41343. /**
  41344. * Oculus Touch Controller
  41345. */
  41346. export class OculusTouchController extends WebVRController {
  41347. /**
  41348. * Base Url for the controller model.
  41349. */
  41350. static MODEL_BASE_URL: string;
  41351. /**
  41352. * File name for the left controller model.
  41353. */
  41354. static MODEL_LEFT_FILENAME: string;
  41355. /**
  41356. * File name for the right controller model.
  41357. */
  41358. static MODEL_RIGHT_FILENAME: string;
  41359. /**
  41360. * Fired when the secondary trigger on this controller is modified
  41361. */
  41362. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41363. /**
  41364. * Fired when the thumb rest on this controller is modified
  41365. */
  41366. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41367. /**
  41368. * Creates a new OculusTouchController from a gamepad
  41369. * @param vrGamepad the gamepad that the controller should be created from
  41370. */
  41371. constructor(vrGamepad: any);
  41372. /**
  41373. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41374. * @param scene scene in which to add meshes
  41375. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41376. */
  41377. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41378. /**
  41379. * Fired when the A button on this controller is modified
  41380. */
  41381. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41382. /**
  41383. * Fired when the B button on this controller is modified
  41384. */
  41385. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41386. /**
  41387. * Fired when the X button on this controller is modified
  41388. */
  41389. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41390. /**
  41391. * Fired when the Y button on this controller is modified
  41392. */
  41393. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41394. /**
  41395. * Called once for each button that changed state since the last frame
  41396. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41397. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41398. * 2) secondary trigger (same)
  41399. * 3) A (right) X (left), touch, pressed = value
  41400. * 4) B / Y
  41401. * 5) thumb rest
  41402. * @param buttonIdx Which button index changed
  41403. * @param state New state of the button
  41404. * @param changes Which properties on the state changed since last frame
  41405. */
  41406. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41407. }
  41408. }
  41409. declare module BABYLON {
  41410. /**
  41411. * Vive Controller
  41412. */
  41413. export class ViveController extends WebVRController {
  41414. /**
  41415. * Base Url for the controller model.
  41416. */
  41417. static MODEL_BASE_URL: string;
  41418. /**
  41419. * File name for the controller model.
  41420. */
  41421. static MODEL_FILENAME: string;
  41422. /**
  41423. * Creates a new ViveController from a gamepad
  41424. * @param vrGamepad the gamepad that the controller should be created from
  41425. */
  41426. constructor(vrGamepad: any);
  41427. /**
  41428. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41429. * @param scene scene in which to add meshes
  41430. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41431. */
  41432. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41433. /**
  41434. * Fired when the left button on this controller is modified
  41435. */
  41436. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41437. /**
  41438. * Fired when the right button on this controller is modified
  41439. */
  41440. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41441. /**
  41442. * Fired when the menu button on this controller is modified
  41443. */
  41444. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41445. /**
  41446. * Called once for each button that changed state since the last frame
  41447. * Vive mapping:
  41448. * 0: touchpad
  41449. * 1: trigger
  41450. * 2: left AND right buttons
  41451. * 3: menu button
  41452. * @param buttonIdx Which button index changed
  41453. * @param state New state of the button
  41454. * @param changes Which properties on the state changed since last frame
  41455. */
  41456. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41457. }
  41458. }
  41459. declare module BABYLON {
  41460. /**
  41461. * Defines the WindowsMotionController object that the state of the windows motion controller
  41462. */
  41463. export class WindowsMotionController extends WebVRController {
  41464. /**
  41465. * The base url used to load the left and right controller models
  41466. */
  41467. static MODEL_BASE_URL: string;
  41468. /**
  41469. * The name of the left controller model file
  41470. */
  41471. static MODEL_LEFT_FILENAME: string;
  41472. /**
  41473. * The name of the right controller model file
  41474. */
  41475. static MODEL_RIGHT_FILENAME: string;
  41476. /**
  41477. * The controller name prefix for this controller type
  41478. */
  41479. static readonly GAMEPAD_ID_PREFIX: string;
  41480. /**
  41481. * The controller id pattern for this controller type
  41482. */
  41483. private static readonly GAMEPAD_ID_PATTERN;
  41484. private _loadedMeshInfo;
  41485. private readonly _mapping;
  41486. /**
  41487. * Fired when the trackpad on this controller is clicked
  41488. */
  41489. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41490. /**
  41491. * Fired when the trackpad on this controller is modified
  41492. */
  41493. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41494. /**
  41495. * The current x and y values of this controller's trackpad
  41496. */
  41497. trackpad: StickValues;
  41498. /**
  41499. * Creates a new WindowsMotionController from a gamepad
  41500. * @param vrGamepad the gamepad that the controller should be created from
  41501. */
  41502. constructor(vrGamepad: any);
  41503. /**
  41504. * Fired when the trigger on this controller is modified
  41505. */
  41506. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41507. /**
  41508. * Fired when the menu button on this controller is modified
  41509. */
  41510. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41511. /**
  41512. * Fired when the grip button on this controller is modified
  41513. */
  41514. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41515. /**
  41516. * Fired when the thumbstick button on this controller is modified
  41517. */
  41518. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41519. /**
  41520. * Fired when the touchpad button on this controller is modified
  41521. */
  41522. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41523. /**
  41524. * Fired when the touchpad values on this controller are modified
  41525. */
  41526. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41527. private _updateTrackpad;
  41528. /**
  41529. * Called once per frame by the engine.
  41530. */
  41531. update(): void;
  41532. /**
  41533. * Called once for each button that changed state since the last frame
  41534. * @param buttonIdx Which button index changed
  41535. * @param state New state of the button
  41536. * @param changes Which properties on the state changed since last frame
  41537. */
  41538. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41539. /**
  41540. * Moves the buttons on the controller mesh based on their current state
  41541. * @param buttonName the name of the button to move
  41542. * @param buttonValue the value of the button which determines the buttons new position
  41543. */
  41544. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41545. /**
  41546. * Moves the axis on the controller mesh based on its current state
  41547. * @param axis the index of the axis
  41548. * @param axisValue the value of the axis which determines the meshes new position
  41549. * @hidden
  41550. */
  41551. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41552. /**
  41553. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41554. * @param scene scene in which to add meshes
  41555. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41556. */
  41557. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41558. /**
  41559. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41560. * can be transformed by button presses and axes values, based on this._mapping.
  41561. *
  41562. * @param scene scene in which the meshes exist
  41563. * @param meshes list of meshes that make up the controller model to process
  41564. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41565. */
  41566. private processModel;
  41567. private createMeshInfo;
  41568. /**
  41569. * Gets the ray of the controller in the direction the controller is pointing
  41570. * @param length the length the resulting ray should be
  41571. * @returns a ray in the direction the controller is pointing
  41572. */
  41573. getForwardRay(length?: number): Ray;
  41574. /**
  41575. * Disposes of the controller
  41576. */
  41577. dispose(): void;
  41578. }
  41579. }
  41580. declare module BABYLON {
  41581. /**
  41582. * Single axis scale gizmo
  41583. */
  41584. export class AxisScaleGizmo extends Gizmo {
  41585. private _coloredMaterial;
  41586. /**
  41587. * Drag behavior responsible for the gizmos dragging interactions
  41588. */
  41589. dragBehavior: PointerDragBehavior;
  41590. private _pointerObserver;
  41591. /**
  41592. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41593. */
  41594. snapDistance: number;
  41595. /**
  41596. * Event that fires each time the gizmo snaps to a new location.
  41597. * * snapDistance is the the change in distance
  41598. */
  41599. onSnapObservable: Observable<{
  41600. snapDistance: number;
  41601. }>;
  41602. /**
  41603. * If the scaling operation should be done on all axis (default: false)
  41604. */
  41605. uniformScaling: boolean;
  41606. /**
  41607. * Creates an AxisScaleGizmo
  41608. * @param gizmoLayer The utility layer the gizmo will be added to
  41609. * @param dragAxis The axis which the gizmo will be able to scale on
  41610. * @param color The color of the gizmo
  41611. */
  41612. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41613. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41614. /**
  41615. * Disposes of the gizmo
  41616. */
  41617. dispose(): void;
  41618. /**
  41619. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41620. * @param mesh The mesh to replace the default mesh of the gizmo
  41621. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41622. */
  41623. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41624. }
  41625. }
  41626. declare module BABYLON {
  41627. /**
  41628. * Bounding box gizmo
  41629. */
  41630. export class BoundingBoxGizmo extends Gizmo {
  41631. private _lineBoundingBox;
  41632. private _rotateSpheresParent;
  41633. private _scaleBoxesParent;
  41634. private _boundingDimensions;
  41635. private _renderObserver;
  41636. private _pointerObserver;
  41637. private _scaleDragSpeed;
  41638. private _tmpQuaternion;
  41639. private _tmpVector;
  41640. private _tmpRotationMatrix;
  41641. /**
  41642. * 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)
  41643. */
  41644. ignoreChildren: boolean;
  41645. /**
  41646. * 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)
  41647. */
  41648. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41649. /**
  41650. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41651. */
  41652. rotationSphereSize: number;
  41653. /**
  41654. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41655. */
  41656. scaleBoxSize: number;
  41657. /**
  41658. * 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)
  41659. */
  41660. fixedDragMeshScreenSize: boolean;
  41661. /**
  41662. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41663. */
  41664. fixedDragMeshScreenSizeDistanceFactor: number;
  41665. /**
  41666. * Fired when a rotation sphere or scale box is dragged
  41667. */
  41668. onDragStartObservable: Observable<{}>;
  41669. /**
  41670. * Fired when a scale box is dragged
  41671. */
  41672. onScaleBoxDragObservable: Observable<{}>;
  41673. /**
  41674. * Fired when a scale box drag is ended
  41675. */
  41676. onScaleBoxDragEndObservable: Observable<{}>;
  41677. /**
  41678. * Fired when a rotation sphere is dragged
  41679. */
  41680. onRotationSphereDragObservable: Observable<{}>;
  41681. /**
  41682. * Fired when a rotation sphere drag is ended
  41683. */
  41684. onRotationSphereDragEndObservable: Observable<{}>;
  41685. /**
  41686. * 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)
  41687. */
  41688. scalePivot: Nullable<Vector3>;
  41689. /**
  41690. * Mesh used as a pivot to rotate the attached mesh
  41691. */
  41692. private _anchorMesh;
  41693. private _existingMeshScale;
  41694. private _dragMesh;
  41695. private pointerDragBehavior;
  41696. private coloredMaterial;
  41697. private hoverColoredMaterial;
  41698. /**
  41699. * Sets the color of the bounding box gizmo
  41700. * @param color the color to set
  41701. */
  41702. setColor(color: Color3): void;
  41703. /**
  41704. * Creates an BoundingBoxGizmo
  41705. * @param gizmoLayer The utility layer the gizmo will be added to
  41706. * @param color The color of the gizmo
  41707. */
  41708. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41709. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41710. private _selectNode;
  41711. /**
  41712. * Updates the bounding box information for the Gizmo
  41713. */
  41714. updateBoundingBox(): void;
  41715. private _updateRotationSpheres;
  41716. private _updateScaleBoxes;
  41717. /**
  41718. * Enables rotation on the specified axis and disables rotation on the others
  41719. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41720. */
  41721. setEnabledRotationAxis(axis: string): void;
  41722. /**
  41723. * Enables/disables scaling
  41724. * @param enable if scaling should be enabled
  41725. */
  41726. setEnabledScaling(enable: boolean): void;
  41727. private _updateDummy;
  41728. /**
  41729. * Enables a pointer drag behavior on the bounding box of the gizmo
  41730. */
  41731. enableDragBehavior(): void;
  41732. /**
  41733. * Disposes of the gizmo
  41734. */
  41735. dispose(): void;
  41736. /**
  41737. * 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)
  41738. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41739. * @returns the bounding box mesh with the passed in mesh as a child
  41740. */
  41741. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41742. /**
  41743. * CustomMeshes are not supported by this gizmo
  41744. * @param mesh The mesh to replace the default mesh of the gizmo
  41745. */
  41746. setCustomMesh(mesh: Mesh): void;
  41747. }
  41748. }
  41749. declare module BABYLON {
  41750. /**
  41751. * Single plane rotation gizmo
  41752. */
  41753. export class PlaneRotationGizmo extends Gizmo {
  41754. /**
  41755. * Drag behavior responsible for the gizmos dragging interactions
  41756. */
  41757. dragBehavior: PointerDragBehavior;
  41758. private _pointerObserver;
  41759. /**
  41760. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41761. */
  41762. snapDistance: number;
  41763. /**
  41764. * Event that fires each time the gizmo snaps to a new location.
  41765. * * snapDistance is the the change in distance
  41766. */
  41767. onSnapObservable: Observable<{
  41768. snapDistance: number;
  41769. }>;
  41770. /**
  41771. * Creates a PlaneRotationGizmo
  41772. * @param gizmoLayer The utility layer the gizmo will be added to
  41773. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41774. * @param color The color of the gizmo
  41775. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41776. */
  41777. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41778. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41779. /**
  41780. * Disposes of the gizmo
  41781. */
  41782. dispose(): void;
  41783. }
  41784. }
  41785. declare module BABYLON {
  41786. /**
  41787. * Gizmo that enables rotating a mesh along 3 axis
  41788. */
  41789. export class RotationGizmo extends Gizmo {
  41790. /**
  41791. * Internal gizmo used for interactions on the x axis
  41792. */
  41793. xGizmo: PlaneRotationGizmo;
  41794. /**
  41795. * Internal gizmo used for interactions on the y axis
  41796. */
  41797. yGizmo: PlaneRotationGizmo;
  41798. /**
  41799. * Internal gizmo used for interactions on the z axis
  41800. */
  41801. zGizmo: PlaneRotationGizmo;
  41802. /** Fires an event when any of it's sub gizmos are dragged */
  41803. onDragStartObservable: Observable<{}>;
  41804. /** Fires an event when any of it's sub gizmos are released from dragging */
  41805. onDragEndObservable: Observable<{}>;
  41806. attachedMesh: Nullable<AbstractMesh>;
  41807. /**
  41808. * Creates a RotationGizmo
  41809. * @param gizmoLayer The utility layer the gizmo will be added to
  41810. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41811. */
  41812. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41813. updateGizmoRotationToMatchAttachedMesh: boolean;
  41814. /**
  41815. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41816. */
  41817. snapDistance: number;
  41818. /**
  41819. * Ratio for the scale of the gizmo (Default: 1)
  41820. */
  41821. scaleRatio: number;
  41822. /**
  41823. * Disposes of the gizmo
  41824. */
  41825. dispose(): void;
  41826. /**
  41827. * CustomMeshes are not supported by this gizmo
  41828. * @param mesh The mesh to replace the default mesh of the gizmo
  41829. */
  41830. setCustomMesh(mesh: Mesh): void;
  41831. }
  41832. }
  41833. declare module BABYLON {
  41834. /**
  41835. * Gizmo that enables dragging a mesh along 3 axis
  41836. */
  41837. export class PositionGizmo extends Gizmo {
  41838. /**
  41839. * Internal gizmo used for interactions on the x axis
  41840. */
  41841. xGizmo: AxisDragGizmo;
  41842. /**
  41843. * Internal gizmo used for interactions on the y axis
  41844. */
  41845. yGizmo: AxisDragGizmo;
  41846. /**
  41847. * Internal gizmo used for interactions on the z axis
  41848. */
  41849. zGizmo: AxisDragGizmo;
  41850. /** Fires an event when any of it's sub gizmos are dragged */
  41851. onDragStartObservable: Observable<{}>;
  41852. /** Fires an event when any of it's sub gizmos are released from dragging */
  41853. onDragEndObservable: Observable<{}>;
  41854. attachedMesh: Nullable<AbstractMesh>;
  41855. /**
  41856. * Creates a PositionGizmo
  41857. * @param gizmoLayer The utility layer the gizmo will be added to
  41858. */
  41859. constructor(gizmoLayer?: UtilityLayerRenderer);
  41860. updateGizmoRotationToMatchAttachedMesh: boolean;
  41861. /**
  41862. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41863. */
  41864. snapDistance: number;
  41865. /**
  41866. * Ratio for the scale of the gizmo (Default: 1)
  41867. */
  41868. scaleRatio: number;
  41869. /**
  41870. * Disposes of the gizmo
  41871. */
  41872. dispose(): void;
  41873. /**
  41874. * CustomMeshes are not supported by this gizmo
  41875. * @param mesh The mesh to replace the default mesh of the gizmo
  41876. */
  41877. setCustomMesh(mesh: Mesh): void;
  41878. }
  41879. }
  41880. declare module BABYLON {
  41881. /**
  41882. * Class containing static functions to help procedurally build meshes
  41883. */
  41884. export class PolyhedronBuilder {
  41885. /**
  41886. * Creates a polyhedron mesh
  41887. * * 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
  41888. * * The parameter `size` (positive float, default 1) sets the polygon size
  41889. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  41890. * * 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`
  41891. * * 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
  41892. * * 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)`)
  41893. * * 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
  41894. * * 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
  41895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41896. * * 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
  41897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41898. * @param name defines the name of the mesh
  41899. * @param options defines the options used to create the mesh
  41900. * @param scene defines the hosting scene
  41901. * @returns the polyhedron mesh
  41902. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  41903. */
  41904. static CreatePolyhedron(name: string, options: {
  41905. type?: number;
  41906. size?: number;
  41907. sizeX?: number;
  41908. sizeY?: number;
  41909. sizeZ?: number;
  41910. custom?: any;
  41911. faceUV?: Vector4[];
  41912. faceColors?: Color4[];
  41913. flat?: boolean;
  41914. updatable?: boolean;
  41915. sideOrientation?: number;
  41916. frontUVs?: Vector4;
  41917. backUVs?: Vector4;
  41918. }, scene?: Nullable<Scene>): Mesh;
  41919. }
  41920. }
  41921. declare module BABYLON {
  41922. /**
  41923. * Gizmo that enables scaling a mesh along 3 axis
  41924. */
  41925. export class ScaleGizmo extends Gizmo {
  41926. /**
  41927. * Internal gizmo used for interactions on the x axis
  41928. */
  41929. xGizmo: AxisScaleGizmo;
  41930. /**
  41931. * Internal gizmo used for interactions on the y axis
  41932. */
  41933. yGizmo: AxisScaleGizmo;
  41934. /**
  41935. * Internal gizmo used for interactions on the z axis
  41936. */
  41937. zGizmo: AxisScaleGizmo;
  41938. /**
  41939. * Internal gizmo used to scale all axis equally
  41940. */
  41941. uniformScaleGizmo: AxisScaleGizmo;
  41942. /** Fires an event when any of it's sub gizmos are dragged */
  41943. onDragStartObservable: Observable<{}>;
  41944. /** Fires an event when any of it's sub gizmos are released from dragging */
  41945. onDragEndObservable: Observable<{}>;
  41946. attachedMesh: Nullable<AbstractMesh>;
  41947. /**
  41948. * Creates a ScaleGizmo
  41949. * @param gizmoLayer The utility layer the gizmo will be added to
  41950. */
  41951. constructor(gizmoLayer?: UtilityLayerRenderer);
  41952. updateGizmoRotationToMatchAttachedMesh: boolean;
  41953. /**
  41954. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41955. */
  41956. snapDistance: number;
  41957. /**
  41958. * Ratio for the scale of the gizmo (Default: 1)
  41959. */
  41960. scaleRatio: number;
  41961. /**
  41962. * Disposes of the gizmo
  41963. */
  41964. dispose(): void;
  41965. }
  41966. }
  41967. declare module BABYLON {
  41968. /**
  41969. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  41970. */
  41971. export class GizmoManager implements IDisposable {
  41972. private scene;
  41973. /**
  41974. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  41975. */
  41976. gizmos: {
  41977. positionGizmo: Nullable<PositionGizmo>;
  41978. rotationGizmo: Nullable<RotationGizmo>;
  41979. scaleGizmo: Nullable<ScaleGizmo>;
  41980. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  41981. };
  41982. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  41983. clearGizmoOnEmptyPointerEvent: boolean;
  41984. /** Fires an event when the manager is attached to a mesh */
  41985. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  41986. private _gizmosEnabled;
  41987. private _pointerObserver;
  41988. private _attachedMesh;
  41989. private _boundingBoxColor;
  41990. private _defaultUtilityLayer;
  41991. private _defaultKeepDepthUtilityLayer;
  41992. /**
  41993. * When bounding box gizmo is enabled, this can be used to track drag/end events
  41994. */
  41995. boundingBoxDragBehavior: SixDofDragBehavior;
  41996. /**
  41997. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  41998. */
  41999. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42000. /**
  42001. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42002. */
  42003. usePointerToAttachGizmos: boolean;
  42004. /**
  42005. * Instatiates a gizmo manager
  42006. * @param scene the scene to overlay the gizmos on top of
  42007. */
  42008. constructor(scene: Scene);
  42009. /**
  42010. * Attaches a set of gizmos to the specified mesh
  42011. * @param mesh The mesh the gizmo's should be attached to
  42012. */
  42013. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42014. /**
  42015. * If the position gizmo is enabled
  42016. */
  42017. positionGizmoEnabled: boolean;
  42018. /**
  42019. * If the rotation gizmo is enabled
  42020. */
  42021. rotationGizmoEnabled: boolean;
  42022. /**
  42023. * If the scale gizmo is enabled
  42024. */
  42025. scaleGizmoEnabled: boolean;
  42026. /**
  42027. * If the boundingBox gizmo is enabled
  42028. */
  42029. boundingBoxGizmoEnabled: boolean;
  42030. /**
  42031. * Disposes of the gizmo manager
  42032. */
  42033. dispose(): void;
  42034. }
  42035. }
  42036. declare module BABYLON {
  42037. /**
  42038. * A directional light is defined by a direction (what a surprise!).
  42039. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42040. * 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.
  42041. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42042. */
  42043. export class DirectionalLight extends ShadowLight {
  42044. private _shadowFrustumSize;
  42045. /**
  42046. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42047. */
  42048. /**
  42049. * Specifies a fix frustum size for the shadow generation.
  42050. */
  42051. shadowFrustumSize: number;
  42052. private _shadowOrthoScale;
  42053. /**
  42054. * Gets the shadow projection scale against the optimal computed one.
  42055. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42056. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42057. */
  42058. /**
  42059. * Sets the shadow projection scale against the optimal computed one.
  42060. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42061. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42062. */
  42063. shadowOrthoScale: number;
  42064. /**
  42065. * Automatically compute the projection matrix to best fit (including all the casters)
  42066. * on each frame.
  42067. */
  42068. autoUpdateExtends: boolean;
  42069. private _orthoLeft;
  42070. private _orthoRight;
  42071. private _orthoTop;
  42072. private _orthoBottom;
  42073. /**
  42074. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42075. * The directional light is emitted from everywhere in the given direction.
  42076. * It can cast shadows.
  42077. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42078. * @param name The friendly name of the light
  42079. * @param direction The direction of the light
  42080. * @param scene The scene the light belongs to
  42081. */
  42082. constructor(name: string, direction: Vector3, scene: Scene);
  42083. /**
  42084. * Returns the string "DirectionalLight".
  42085. * @return The class name
  42086. */
  42087. getClassName(): string;
  42088. /**
  42089. * Returns the integer 1.
  42090. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42091. */
  42092. getTypeID(): number;
  42093. /**
  42094. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42095. * Returns the DirectionalLight Shadow projection matrix.
  42096. */
  42097. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42098. /**
  42099. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42100. * Returns the DirectionalLight Shadow projection matrix.
  42101. */
  42102. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42103. /**
  42104. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42105. * Returns the DirectionalLight Shadow projection matrix.
  42106. */
  42107. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42108. protected _buildUniformLayout(): void;
  42109. /**
  42110. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42111. * @param effect The effect to update
  42112. * @param lightIndex The index of the light in the effect to update
  42113. * @returns The directional light
  42114. */
  42115. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42116. /**
  42117. * Gets the minZ used for shadow according to both the scene and the light.
  42118. *
  42119. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42120. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42121. * @param activeCamera The camera we are returning the min for
  42122. * @returns the depth min z
  42123. */
  42124. getDepthMinZ(activeCamera: Camera): number;
  42125. /**
  42126. * Gets the maxZ used for shadow according to both the scene and the light.
  42127. *
  42128. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42129. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42130. * @param activeCamera The camera we are returning the max for
  42131. * @returns the depth max z
  42132. */
  42133. getDepthMaxZ(activeCamera: Camera): number;
  42134. /**
  42135. * Prepares the list of defines specific to the light type.
  42136. * @param defines the list of defines
  42137. * @param lightIndex defines the index of the light for the effect
  42138. */
  42139. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42140. }
  42141. }
  42142. declare module BABYLON {
  42143. /**
  42144. * Class containing static functions to help procedurally build meshes
  42145. */
  42146. export class HemisphereBuilder {
  42147. /**
  42148. * Creates a hemisphere mesh
  42149. * @param name defines the name of the mesh
  42150. * @param options defines the options used to create the mesh
  42151. * @param scene defines the hosting scene
  42152. * @returns the hemisphere mesh
  42153. */
  42154. static CreateHemisphere(name: string, options: {
  42155. segments?: number;
  42156. diameter?: number;
  42157. sideOrientation?: number;
  42158. }, scene: any): Mesh;
  42159. }
  42160. }
  42161. declare module BABYLON {
  42162. /**
  42163. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42164. * These values define a cone of light starting from the position, emitting toward the direction.
  42165. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42166. * and the exponent defines the speed of the decay of the light with distance (reach).
  42167. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42168. */
  42169. export class SpotLight extends ShadowLight {
  42170. private _angle;
  42171. private _innerAngle;
  42172. private _cosHalfAngle;
  42173. private _lightAngleScale;
  42174. private _lightAngleOffset;
  42175. /**
  42176. * Gets the cone angle of the spot light in Radians.
  42177. */
  42178. /**
  42179. * Sets the cone angle of the spot light in Radians.
  42180. */
  42181. angle: number;
  42182. /**
  42183. * Only used in gltf falloff mode, this defines the angle where
  42184. * the directional falloff will start before cutting at angle which could be seen
  42185. * as outer angle.
  42186. */
  42187. /**
  42188. * Only used in gltf falloff mode, this defines the angle where
  42189. * the directional falloff will start before cutting at angle which could be seen
  42190. * as outer angle.
  42191. */
  42192. innerAngle: number;
  42193. private _shadowAngleScale;
  42194. /**
  42195. * Allows scaling the angle of the light for shadow generation only.
  42196. */
  42197. /**
  42198. * Allows scaling the angle of the light for shadow generation only.
  42199. */
  42200. shadowAngleScale: number;
  42201. /**
  42202. * The light decay speed with the distance from the emission spot.
  42203. */
  42204. exponent: number;
  42205. private _projectionTextureMatrix;
  42206. /**
  42207. * Allows reading the projecton texture
  42208. */
  42209. readonly projectionTextureMatrix: Matrix;
  42210. protected _projectionTextureLightNear: number;
  42211. /**
  42212. * Gets the near clip of the Spotlight for texture projection.
  42213. */
  42214. /**
  42215. * Sets the near clip of the Spotlight for texture projection.
  42216. */
  42217. projectionTextureLightNear: number;
  42218. protected _projectionTextureLightFar: number;
  42219. /**
  42220. * Gets the far clip of the Spotlight for texture projection.
  42221. */
  42222. /**
  42223. * Sets the far clip of the Spotlight for texture projection.
  42224. */
  42225. projectionTextureLightFar: number;
  42226. protected _projectionTextureUpDirection: Vector3;
  42227. /**
  42228. * Gets the Up vector of the Spotlight for texture projection.
  42229. */
  42230. /**
  42231. * Sets the Up vector of the Spotlight for texture projection.
  42232. */
  42233. projectionTextureUpDirection: Vector3;
  42234. private _projectionTexture;
  42235. /**
  42236. * Gets the projection texture of the light.
  42237. */
  42238. /**
  42239. * Sets the projection texture of the light.
  42240. */
  42241. projectionTexture: Nullable<BaseTexture>;
  42242. private _projectionTextureViewLightDirty;
  42243. private _projectionTextureProjectionLightDirty;
  42244. private _projectionTextureDirty;
  42245. private _projectionTextureViewTargetVector;
  42246. private _projectionTextureViewLightMatrix;
  42247. private _projectionTextureProjectionLightMatrix;
  42248. private _projectionTextureScalingMatrix;
  42249. /**
  42250. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42251. * It can cast shadows.
  42252. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42253. * @param name The light friendly name
  42254. * @param position The position of the spot light in the scene
  42255. * @param direction The direction of the light in the scene
  42256. * @param angle The cone angle of the light in Radians
  42257. * @param exponent The light decay speed with the distance from the emission spot
  42258. * @param scene The scene the lights belongs to
  42259. */
  42260. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42261. /**
  42262. * Returns the string "SpotLight".
  42263. * @returns the class name
  42264. */
  42265. getClassName(): string;
  42266. /**
  42267. * Returns the integer 2.
  42268. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42269. */
  42270. getTypeID(): number;
  42271. /**
  42272. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42273. */
  42274. protected _setDirection(value: Vector3): void;
  42275. /**
  42276. * Overrides the position setter to recompute the projection texture view light Matrix.
  42277. */
  42278. protected _setPosition(value: Vector3): void;
  42279. /**
  42280. * 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.
  42281. * Returns the SpotLight.
  42282. */
  42283. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42284. protected _computeProjectionTextureViewLightMatrix(): void;
  42285. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42286. /**
  42287. * Main function for light texture projection matrix computing.
  42288. */
  42289. protected _computeProjectionTextureMatrix(): void;
  42290. protected _buildUniformLayout(): void;
  42291. private _computeAngleValues;
  42292. /**
  42293. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42294. * @param effect The effect to update
  42295. * @param lightIndex The index of the light in the effect to update
  42296. * @returns The spot light
  42297. */
  42298. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42299. /**
  42300. * Disposes the light and the associated resources.
  42301. */
  42302. dispose(): void;
  42303. /**
  42304. * Prepares the list of defines specific to the light type.
  42305. * @param defines the list of defines
  42306. * @param lightIndex defines the index of the light for the effect
  42307. */
  42308. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42309. }
  42310. }
  42311. declare module BABYLON {
  42312. /**
  42313. * Gizmo that enables viewing a light
  42314. */
  42315. export class LightGizmo extends Gizmo {
  42316. private _lightMesh;
  42317. private _material;
  42318. /**
  42319. * Creates a LightGizmo
  42320. * @param gizmoLayer The utility layer the gizmo will be added to
  42321. */
  42322. constructor(gizmoLayer?: UtilityLayerRenderer);
  42323. private _light;
  42324. /**
  42325. * The light that the gizmo is attached to
  42326. */
  42327. light: Nullable<Light>;
  42328. /**
  42329. * @hidden
  42330. * Updates the gizmo to match the attached mesh's position/rotation
  42331. */
  42332. protected _update(): void;
  42333. private static _Scale;
  42334. /**
  42335. * Creates the lines for a light mesh
  42336. */
  42337. private static _createLightLines;
  42338. private static _CreateHemisphericLightMesh;
  42339. private static _CreatePointLightMesh;
  42340. private static _CreateSpotLightMesh;
  42341. private static _CreateDirectionalLightMesh;
  42342. }
  42343. }
  42344. declare module BABYLON {
  42345. /** @hidden */
  42346. export var backgroundFragmentDeclaration: {
  42347. name: string;
  42348. shader: string;
  42349. };
  42350. }
  42351. declare module BABYLON {
  42352. /** @hidden */
  42353. export var backgroundUboDeclaration: {
  42354. name: string;
  42355. shader: string;
  42356. };
  42357. }
  42358. declare module BABYLON {
  42359. /** @hidden */
  42360. export var backgroundPixelShader: {
  42361. name: string;
  42362. shader: string;
  42363. };
  42364. }
  42365. declare module BABYLON {
  42366. /** @hidden */
  42367. export var backgroundVertexDeclaration: {
  42368. name: string;
  42369. shader: string;
  42370. };
  42371. }
  42372. declare module BABYLON {
  42373. /** @hidden */
  42374. export var backgroundVertexShader: {
  42375. name: string;
  42376. shader: string;
  42377. };
  42378. }
  42379. declare module BABYLON {
  42380. /**
  42381. * Background material used to create an efficient environement around your scene.
  42382. */
  42383. export class BackgroundMaterial extends PushMaterial {
  42384. /**
  42385. * Standard reflectance value at parallel view angle.
  42386. */
  42387. static StandardReflectance0: number;
  42388. /**
  42389. * Standard reflectance value at grazing angle.
  42390. */
  42391. static StandardReflectance90: number;
  42392. protected _primaryColor: Color3;
  42393. /**
  42394. * Key light Color (multiply against the environement texture)
  42395. */
  42396. primaryColor: Color3;
  42397. protected __perceptualColor: Nullable<Color3>;
  42398. /**
  42399. * Experimental Internal Use Only.
  42400. *
  42401. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42402. * This acts as a helper to set the primary color to a more "human friendly" value.
  42403. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42404. * output color as close as possible from the chosen value.
  42405. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42406. * part of lighting setup.)
  42407. */ perceptualColor: Nullable<Color3>;
  42408. protected _primaryColorShadowLevel: float;
  42409. /**
  42410. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42411. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42412. */
  42413. primaryColorShadowLevel: float;
  42414. protected _primaryColorHighlightLevel: float;
  42415. /**
  42416. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42417. * The primary color is used at the level chosen to define what the white area would look.
  42418. */
  42419. primaryColorHighlightLevel: float;
  42420. protected _reflectionTexture: Nullable<BaseTexture>;
  42421. /**
  42422. * Reflection Texture used in the material.
  42423. * Should be author in a specific way for the best result (refer to the documentation).
  42424. */
  42425. reflectionTexture: Nullable<BaseTexture>;
  42426. protected _reflectionBlur: float;
  42427. /**
  42428. * Reflection Texture level of blur.
  42429. *
  42430. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42431. * texture twice.
  42432. */
  42433. reflectionBlur: float;
  42434. protected _diffuseTexture: Nullable<BaseTexture>;
  42435. /**
  42436. * Diffuse Texture used in the material.
  42437. * Should be author in a specific way for the best result (refer to the documentation).
  42438. */
  42439. diffuseTexture: Nullable<BaseTexture>;
  42440. protected _shadowLights: Nullable<IShadowLight[]>;
  42441. /**
  42442. * Specify the list of lights casting shadow on the material.
  42443. * All scene shadow lights will be included if null.
  42444. */
  42445. shadowLights: Nullable<IShadowLight[]>;
  42446. protected _shadowLevel: float;
  42447. /**
  42448. * Helps adjusting the shadow to a softer level if required.
  42449. * 0 means black shadows and 1 means no shadows.
  42450. */
  42451. shadowLevel: float;
  42452. protected _sceneCenter: Vector3;
  42453. /**
  42454. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42455. * It is usually zero but might be interesting to modify according to your setup.
  42456. */
  42457. sceneCenter: Vector3;
  42458. protected _opacityFresnel: boolean;
  42459. /**
  42460. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42461. * This helps ensuring a nice transition when the camera goes under the ground.
  42462. */
  42463. opacityFresnel: boolean;
  42464. protected _reflectionFresnel: boolean;
  42465. /**
  42466. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42467. * This helps adding a mirror texture on the ground.
  42468. */
  42469. reflectionFresnel: boolean;
  42470. protected _reflectionFalloffDistance: number;
  42471. /**
  42472. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42473. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42474. */
  42475. reflectionFalloffDistance: number;
  42476. protected _reflectionAmount: number;
  42477. /**
  42478. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42479. */
  42480. reflectionAmount: number;
  42481. protected _reflectionReflectance0: number;
  42482. /**
  42483. * This specifies the weight of the reflection at grazing angle.
  42484. */
  42485. reflectionReflectance0: number;
  42486. protected _reflectionReflectance90: number;
  42487. /**
  42488. * This specifies the weight of the reflection at a perpendicular point of view.
  42489. */
  42490. reflectionReflectance90: number;
  42491. /**
  42492. * Sets the reflection reflectance fresnel values according to the default standard
  42493. * empirically know to work well :-)
  42494. */
  42495. reflectionStandardFresnelWeight: number;
  42496. protected _useRGBColor: boolean;
  42497. /**
  42498. * Helps to directly use the maps channels instead of their level.
  42499. */
  42500. useRGBColor: boolean;
  42501. protected _enableNoise: boolean;
  42502. /**
  42503. * This helps reducing the banding effect that could occur on the background.
  42504. */
  42505. enableNoise: boolean;
  42506. /**
  42507. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42508. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42509. * Recommended to be keep at 1.0 except for special cases.
  42510. */
  42511. fovMultiplier: number;
  42512. private _fovMultiplier;
  42513. /**
  42514. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42515. */
  42516. useEquirectangularFOV: boolean;
  42517. private _maxSimultaneousLights;
  42518. /**
  42519. * Number of Simultaneous lights allowed on the material.
  42520. */
  42521. maxSimultaneousLights: int;
  42522. /**
  42523. * Default configuration related to image processing available in the Background Material.
  42524. */
  42525. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42526. /**
  42527. * Keep track of the image processing observer to allow dispose and replace.
  42528. */
  42529. private _imageProcessingObserver;
  42530. /**
  42531. * Attaches a new image processing configuration to the PBR Material.
  42532. * @param configuration (if null the scene configuration will be use)
  42533. */
  42534. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42535. /**
  42536. * Gets the image processing configuration used either in this material.
  42537. */
  42538. /**
  42539. * Sets the Default image processing configuration used either in the this material.
  42540. *
  42541. * If sets to null, the scene one is in use.
  42542. */
  42543. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42544. /**
  42545. * Gets wether the color curves effect is enabled.
  42546. */
  42547. /**
  42548. * Sets wether the color curves effect is enabled.
  42549. */
  42550. cameraColorCurvesEnabled: boolean;
  42551. /**
  42552. * Gets wether the color grading effect is enabled.
  42553. */
  42554. /**
  42555. * Gets wether the color grading effect is enabled.
  42556. */
  42557. cameraColorGradingEnabled: boolean;
  42558. /**
  42559. * Gets wether tonemapping is enabled or not.
  42560. */
  42561. /**
  42562. * Sets wether tonemapping is enabled or not
  42563. */
  42564. cameraToneMappingEnabled: boolean;
  42565. /**
  42566. * The camera exposure used on this material.
  42567. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42568. * This corresponds to a photographic exposure.
  42569. */
  42570. /**
  42571. * The camera exposure used on this material.
  42572. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42573. * This corresponds to a photographic exposure.
  42574. */
  42575. cameraExposure: float;
  42576. /**
  42577. * Gets The camera contrast used on this material.
  42578. */
  42579. /**
  42580. * Sets The camera contrast used on this material.
  42581. */
  42582. cameraContrast: float;
  42583. /**
  42584. * Gets the Color Grading 2D Lookup Texture.
  42585. */
  42586. /**
  42587. * Sets the Color Grading 2D Lookup Texture.
  42588. */
  42589. cameraColorGradingTexture: Nullable<BaseTexture>;
  42590. /**
  42591. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42592. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42593. * 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;
  42594. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42595. */
  42596. /**
  42597. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42598. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42599. * 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;
  42600. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42601. */
  42602. cameraColorCurves: Nullable<ColorCurves>;
  42603. /**
  42604. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42605. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42606. */
  42607. switchToBGR: boolean;
  42608. private _renderTargets;
  42609. private _reflectionControls;
  42610. private _white;
  42611. private _primaryShadowColor;
  42612. private _primaryHighlightColor;
  42613. /**
  42614. * Instantiates a Background Material in the given scene
  42615. * @param name The friendly name of the material
  42616. * @param scene The scene to add the material to
  42617. */
  42618. constructor(name: string, scene: Scene);
  42619. /**
  42620. * Gets a boolean indicating that current material needs to register RTT
  42621. */
  42622. readonly hasRenderTargetTextures: boolean;
  42623. /**
  42624. * The entire material has been created in order to prevent overdraw.
  42625. * @returns false
  42626. */
  42627. needAlphaTesting(): boolean;
  42628. /**
  42629. * The entire material has been created in order to prevent overdraw.
  42630. * @returns true if blending is enable
  42631. */
  42632. needAlphaBlending(): boolean;
  42633. /**
  42634. * Checks wether the material is ready to be rendered for a given mesh.
  42635. * @param mesh The mesh to render
  42636. * @param subMesh The submesh to check against
  42637. * @param useInstances Specify wether or not the material is used with instances
  42638. * @returns true if all the dependencies are ready (Textures, Effects...)
  42639. */
  42640. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42641. /**
  42642. * Compute the primary color according to the chosen perceptual color.
  42643. */
  42644. private _computePrimaryColorFromPerceptualColor;
  42645. /**
  42646. * Compute the highlights and shadow colors according to their chosen levels.
  42647. */
  42648. private _computePrimaryColors;
  42649. /**
  42650. * Build the uniform buffer used in the material.
  42651. */
  42652. buildUniformLayout(): void;
  42653. /**
  42654. * Unbind the material.
  42655. */
  42656. unbind(): void;
  42657. /**
  42658. * Bind only the world matrix to the material.
  42659. * @param world The world matrix to bind.
  42660. */
  42661. bindOnlyWorldMatrix(world: Matrix): void;
  42662. /**
  42663. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42664. * @param world The world matrix to bind.
  42665. * @param subMesh The submesh to bind for.
  42666. */
  42667. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42668. /**
  42669. * Dispose the material.
  42670. * @param forceDisposeEffect Force disposal of the associated effect.
  42671. * @param forceDisposeTextures Force disposal of the associated textures.
  42672. */
  42673. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42674. /**
  42675. * Clones the material.
  42676. * @param name The cloned name.
  42677. * @returns The cloned material.
  42678. */
  42679. clone(name: string): BackgroundMaterial;
  42680. /**
  42681. * Serializes the current material to its JSON representation.
  42682. * @returns The JSON representation.
  42683. */
  42684. serialize(): any;
  42685. /**
  42686. * Gets the class name of the material
  42687. * @returns "BackgroundMaterial"
  42688. */
  42689. getClassName(): string;
  42690. /**
  42691. * Parse a JSON input to create back a background material.
  42692. * @param source The JSON data to parse
  42693. * @param scene The scene to create the parsed material in
  42694. * @param rootUrl The root url of the assets the material depends upon
  42695. * @returns the instantiated BackgroundMaterial.
  42696. */
  42697. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42698. }
  42699. }
  42700. declare module BABYLON {
  42701. /**
  42702. * Represents the different options available during the creation of
  42703. * a Environment helper.
  42704. *
  42705. * This can control the default ground, skybox and image processing setup of your scene.
  42706. */
  42707. export interface IEnvironmentHelperOptions {
  42708. /**
  42709. * Specifies wether or not to create a ground.
  42710. * True by default.
  42711. */
  42712. createGround: boolean;
  42713. /**
  42714. * Specifies the ground size.
  42715. * 15 by default.
  42716. */
  42717. groundSize: number;
  42718. /**
  42719. * The texture used on the ground for the main color.
  42720. * Comes from the BabylonJS CDN by default.
  42721. *
  42722. * Remarks: Can be either a texture or a url.
  42723. */
  42724. groundTexture: string | BaseTexture;
  42725. /**
  42726. * The color mixed in the ground texture by default.
  42727. * BabylonJS clearColor by default.
  42728. */
  42729. groundColor: Color3;
  42730. /**
  42731. * Specifies the ground opacity.
  42732. * 1 by default.
  42733. */
  42734. groundOpacity: number;
  42735. /**
  42736. * Enables the ground to receive shadows.
  42737. * True by default.
  42738. */
  42739. enableGroundShadow: boolean;
  42740. /**
  42741. * Helps preventing the shadow to be fully black on the ground.
  42742. * 0.5 by default.
  42743. */
  42744. groundShadowLevel: number;
  42745. /**
  42746. * Creates a mirror texture attach to the ground.
  42747. * false by default.
  42748. */
  42749. enableGroundMirror: boolean;
  42750. /**
  42751. * Specifies the ground mirror size ratio.
  42752. * 0.3 by default as the default kernel is 64.
  42753. */
  42754. groundMirrorSizeRatio: number;
  42755. /**
  42756. * Specifies the ground mirror blur kernel size.
  42757. * 64 by default.
  42758. */
  42759. groundMirrorBlurKernel: number;
  42760. /**
  42761. * Specifies the ground mirror visibility amount.
  42762. * 1 by default
  42763. */
  42764. groundMirrorAmount: number;
  42765. /**
  42766. * Specifies the ground mirror reflectance weight.
  42767. * This uses the standard weight of the background material to setup the fresnel effect
  42768. * of the mirror.
  42769. * 1 by default.
  42770. */
  42771. groundMirrorFresnelWeight: number;
  42772. /**
  42773. * Specifies the ground mirror Falloff distance.
  42774. * This can helps reducing the size of the reflection.
  42775. * 0 by Default.
  42776. */
  42777. groundMirrorFallOffDistance: number;
  42778. /**
  42779. * Specifies the ground mirror texture type.
  42780. * Unsigned Int by Default.
  42781. */
  42782. groundMirrorTextureType: number;
  42783. /**
  42784. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42785. * the shown objects.
  42786. */
  42787. groundYBias: number;
  42788. /**
  42789. * Specifies wether or not to create a skybox.
  42790. * True by default.
  42791. */
  42792. createSkybox: boolean;
  42793. /**
  42794. * Specifies the skybox size.
  42795. * 20 by default.
  42796. */
  42797. skyboxSize: number;
  42798. /**
  42799. * The texture used on the skybox for the main color.
  42800. * Comes from the BabylonJS CDN by default.
  42801. *
  42802. * Remarks: Can be either a texture or a url.
  42803. */
  42804. skyboxTexture: string | BaseTexture;
  42805. /**
  42806. * The color mixed in the skybox texture by default.
  42807. * BabylonJS clearColor by default.
  42808. */
  42809. skyboxColor: Color3;
  42810. /**
  42811. * The background rotation around the Y axis of the scene.
  42812. * This helps aligning the key lights of your scene with the background.
  42813. * 0 by default.
  42814. */
  42815. backgroundYRotation: number;
  42816. /**
  42817. * Compute automatically the size of the elements to best fit with the scene.
  42818. */
  42819. sizeAuto: boolean;
  42820. /**
  42821. * Default position of the rootMesh if autoSize is not true.
  42822. */
  42823. rootPosition: Vector3;
  42824. /**
  42825. * Sets up the image processing in the scene.
  42826. * true by default.
  42827. */
  42828. setupImageProcessing: boolean;
  42829. /**
  42830. * The texture used as your environment texture in the scene.
  42831. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  42832. *
  42833. * Remarks: Can be either a texture or a url.
  42834. */
  42835. environmentTexture: string | BaseTexture;
  42836. /**
  42837. * The value of the exposure to apply to the scene.
  42838. * 0.6 by default if setupImageProcessing is true.
  42839. */
  42840. cameraExposure: number;
  42841. /**
  42842. * The value of the contrast to apply to the scene.
  42843. * 1.6 by default if setupImageProcessing is true.
  42844. */
  42845. cameraContrast: number;
  42846. /**
  42847. * Specifies wether or not tonemapping should be enabled in the scene.
  42848. * true by default if setupImageProcessing is true.
  42849. */
  42850. toneMappingEnabled: boolean;
  42851. }
  42852. /**
  42853. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42854. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42855. * It also helps with the default setup of your imageProcessing configuration.
  42856. */
  42857. export class EnvironmentHelper {
  42858. /**
  42859. * Default ground texture URL.
  42860. */
  42861. private static _groundTextureCDNUrl;
  42862. /**
  42863. * Default skybox texture URL.
  42864. */
  42865. private static _skyboxTextureCDNUrl;
  42866. /**
  42867. * Default environment texture URL.
  42868. */
  42869. private static _environmentTextureCDNUrl;
  42870. /**
  42871. * Creates the default options for the helper.
  42872. */
  42873. private static _getDefaultOptions;
  42874. private _rootMesh;
  42875. /**
  42876. * Gets the root mesh created by the helper.
  42877. */
  42878. readonly rootMesh: Mesh;
  42879. private _skybox;
  42880. /**
  42881. * Gets the skybox created by the helper.
  42882. */
  42883. readonly skybox: Nullable<Mesh>;
  42884. private _skyboxTexture;
  42885. /**
  42886. * Gets the skybox texture created by the helper.
  42887. */
  42888. readonly skyboxTexture: Nullable<BaseTexture>;
  42889. private _skyboxMaterial;
  42890. /**
  42891. * Gets the skybox material created by the helper.
  42892. */
  42893. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  42894. private _ground;
  42895. /**
  42896. * Gets the ground mesh created by the helper.
  42897. */
  42898. readonly ground: Nullable<Mesh>;
  42899. private _groundTexture;
  42900. /**
  42901. * Gets the ground texture created by the helper.
  42902. */
  42903. readonly groundTexture: Nullable<BaseTexture>;
  42904. private _groundMirror;
  42905. /**
  42906. * Gets the ground mirror created by the helper.
  42907. */
  42908. readonly groundMirror: Nullable<MirrorTexture>;
  42909. /**
  42910. * Gets the ground mirror render list to helps pushing the meshes
  42911. * you wish in the ground reflection.
  42912. */
  42913. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  42914. private _groundMaterial;
  42915. /**
  42916. * Gets the ground material created by the helper.
  42917. */
  42918. readonly groundMaterial: Nullable<BackgroundMaterial>;
  42919. /**
  42920. * Stores the creation options.
  42921. */
  42922. private readonly _scene;
  42923. private _options;
  42924. /**
  42925. * This observable will be notified with any error during the creation of the environment,
  42926. * mainly texture creation errors.
  42927. */
  42928. onErrorObservable: Observable<{
  42929. message?: string;
  42930. exception?: any;
  42931. }>;
  42932. /**
  42933. * constructor
  42934. * @param options Defines the options we want to customize the helper
  42935. * @param scene The scene to add the material to
  42936. */
  42937. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  42938. /**
  42939. * Updates the background according to the new options
  42940. * @param options
  42941. */
  42942. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  42943. /**
  42944. * Sets the primary color of all the available elements.
  42945. * @param color the main color to affect to the ground and the background
  42946. */
  42947. setMainColor(color: Color3): void;
  42948. /**
  42949. * Setup the image processing according to the specified options.
  42950. */
  42951. private _setupImageProcessing;
  42952. /**
  42953. * Setup the environment texture according to the specified options.
  42954. */
  42955. private _setupEnvironmentTexture;
  42956. /**
  42957. * Setup the background according to the specified options.
  42958. */
  42959. private _setupBackground;
  42960. /**
  42961. * Get the scene sizes according to the setup.
  42962. */
  42963. private _getSceneSize;
  42964. /**
  42965. * Setup the ground according to the specified options.
  42966. */
  42967. private _setupGround;
  42968. /**
  42969. * Setup the ground material according to the specified options.
  42970. */
  42971. private _setupGroundMaterial;
  42972. /**
  42973. * Setup the ground diffuse texture according to the specified options.
  42974. */
  42975. private _setupGroundDiffuseTexture;
  42976. /**
  42977. * Setup the ground mirror texture according to the specified options.
  42978. */
  42979. private _setupGroundMirrorTexture;
  42980. /**
  42981. * Setup the ground to receive the mirror texture.
  42982. */
  42983. private _setupMirrorInGroundMaterial;
  42984. /**
  42985. * Setup the skybox according to the specified options.
  42986. */
  42987. private _setupSkybox;
  42988. /**
  42989. * Setup the skybox material according to the specified options.
  42990. */
  42991. private _setupSkyboxMaterial;
  42992. /**
  42993. * Setup the skybox reflection texture according to the specified options.
  42994. */
  42995. private _setupSkyboxReflectionTexture;
  42996. private _errorHandler;
  42997. /**
  42998. * Dispose all the elements created by the Helper.
  42999. */
  43000. dispose(): void;
  43001. }
  43002. }
  43003. declare module BABYLON {
  43004. /**
  43005. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43006. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43007. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43008. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43009. */
  43010. export class PhotoDome extends TransformNode {
  43011. private _useDirectMapping;
  43012. /**
  43013. * The texture being displayed on the sphere
  43014. */
  43015. protected _photoTexture: Texture;
  43016. /**
  43017. * Gets or sets the texture being displayed on the sphere
  43018. */
  43019. photoTexture: Texture;
  43020. /**
  43021. * Observable raised when an error occured while loading the 360 image
  43022. */
  43023. onLoadErrorObservable: Observable<string>;
  43024. /**
  43025. * The skybox material
  43026. */
  43027. protected _material: BackgroundMaterial;
  43028. /**
  43029. * The surface used for the skybox
  43030. */
  43031. protected _mesh: Mesh;
  43032. /**
  43033. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43034. * Also see the options.resolution property.
  43035. */
  43036. fovMultiplier: number;
  43037. /**
  43038. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43039. * @param name Element's name, child elements will append suffixes for their own names.
  43040. * @param urlsOfPhoto defines the url of the photo to display
  43041. * @param options defines an object containing optional or exposed sub element properties
  43042. * @param onError defines a callback called when an error occured while loading the texture
  43043. */
  43044. constructor(name: string, urlOfPhoto: string, options: {
  43045. resolution?: number;
  43046. size?: number;
  43047. useDirectMapping?: boolean;
  43048. faceForward?: boolean;
  43049. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43050. /**
  43051. * Releases resources associated with this node.
  43052. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43053. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43054. */
  43055. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43056. }
  43057. }
  43058. declare module BABYLON {
  43059. /** @hidden */
  43060. export var rgbdDecodePixelShader: {
  43061. name: string;
  43062. shader: string;
  43063. };
  43064. }
  43065. declare module BABYLON {
  43066. /**
  43067. * Class used to host texture specific utilities
  43068. */
  43069. export class BRDFTextureTools {
  43070. /**
  43071. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43072. * @param texture the texture to expand.
  43073. */
  43074. private static _ExpandDefaultBRDFTexture;
  43075. /**
  43076. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43077. * @param scene defines the hosting scene
  43078. * @returns the environment BRDF texture
  43079. */
  43080. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43081. private static _environmentBRDFBase64Texture;
  43082. }
  43083. }
  43084. declare module BABYLON {
  43085. /**
  43086. * @hidden
  43087. */
  43088. export interface IMaterialClearCoatDefines {
  43089. CLEARCOAT: boolean;
  43090. CLEARCOAT_DEFAULTIOR: boolean;
  43091. CLEARCOAT_TEXTURE: boolean;
  43092. CLEARCOAT_TEXTUREDIRECTUV: number;
  43093. CLEARCOAT_BUMP: boolean;
  43094. CLEARCOAT_BUMPDIRECTUV: number;
  43095. CLEARCOAT_TINT: boolean;
  43096. CLEARCOAT_TINT_TEXTURE: boolean;
  43097. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43098. /** @hidden */ areTexturesDirty: boolean;
  43099. }
  43100. /**
  43101. * Define the code related to the clear coat parameters of the pbr material.
  43102. */
  43103. export class PBRClearCoatConfiguration {
  43104. /**
  43105. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43106. * The default fits with a polyurethane material.
  43107. */
  43108. private static readonly _DefaultIndiceOfRefraction;
  43109. private _isEnabled;
  43110. /**
  43111. * Defines if the clear coat is enabled in the material.
  43112. */
  43113. isEnabled: boolean;
  43114. /**
  43115. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43116. */
  43117. intensity: number;
  43118. /**
  43119. * Defines the clear coat layer roughness.
  43120. */
  43121. roughness: number;
  43122. private _indiceOfRefraction;
  43123. /**
  43124. * Defines the indice of refraction of the clear coat.
  43125. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43126. * The default fits with a polyurethane material.
  43127. * Changing the default value is more performance intensive.
  43128. */
  43129. indiceOfRefraction: number;
  43130. private _texture;
  43131. /**
  43132. * Stores the clear coat values in a texture.
  43133. */
  43134. texture: Nullable<BaseTexture>;
  43135. private _bumpTexture;
  43136. /**
  43137. * Define the clear coat specific bump texture.
  43138. */
  43139. bumpTexture: Nullable<BaseTexture>;
  43140. private _isTintEnabled;
  43141. /**
  43142. * Defines if the clear coat tint is enabled in the material.
  43143. */
  43144. isTintEnabled: boolean;
  43145. /**
  43146. * Defines the clear coat tint of the material.
  43147. * This is only use if tint is enabled
  43148. */
  43149. tintColor: Color3;
  43150. /**
  43151. * Defines the distance at which the tint color should be found in the
  43152. * clear coat media.
  43153. * This is only use if tint is enabled
  43154. */
  43155. tintColorAtDistance: number;
  43156. /**
  43157. * Defines the clear coat layer thickness.
  43158. * This is only use if tint is enabled
  43159. */
  43160. tintThickness: number;
  43161. private _tintTexture;
  43162. /**
  43163. * Stores the clear tint values in a texture.
  43164. * rgb is tint
  43165. * a is a thickness factor
  43166. */
  43167. tintTexture: Nullable<BaseTexture>;
  43168. /** @hidden */
  43169. private _internalMarkAllSubMeshesAsTexturesDirty;
  43170. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43171. /**
  43172. * Instantiate a new istance of clear coat configuration.
  43173. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43174. */
  43175. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43176. /**
  43177. * Gets wehter the submesh is ready to be used or not.
  43178. * @param defines the list of "defines" to update.
  43179. * @param scene defines the scene the material belongs to.
  43180. * @param engine defines the engine the material belongs to.
  43181. * @param disableBumpMap defines wether the material disables bump or not.
  43182. * @returns - boolean indicating that the submesh is ready or not.
  43183. */
  43184. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43185. /**
  43186. * Checks to see if a texture is used in the material.
  43187. * @param defines the list of "defines" to update.
  43188. * @param scene defines the scene to the material belongs to.
  43189. */
  43190. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43191. /**
  43192. * Binds the material data.
  43193. * @param uniformBuffer defines the Uniform buffer to fill in.
  43194. * @param scene defines the scene the material belongs to.
  43195. * @param engine defines the engine the material belongs to.
  43196. * @param disableBumpMap defines wether the material disables bump or not.
  43197. * @param isFrozen defines wether the material is frozen or not.
  43198. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43199. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43200. */
  43201. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43202. /**
  43203. * Checks to see if a texture is used in the material.
  43204. * @param texture - Base texture to use.
  43205. * @returns - Boolean specifying if a texture is used in the material.
  43206. */
  43207. hasTexture(texture: BaseTexture): boolean;
  43208. /**
  43209. * Returns an array of the actively used textures.
  43210. * @param activeTextures Array of BaseTextures
  43211. */
  43212. getActiveTextures(activeTextures: BaseTexture[]): void;
  43213. /**
  43214. * Returns the animatable textures.
  43215. * @param animatables Array of animatable textures.
  43216. */
  43217. getAnimatables(animatables: IAnimatable[]): void;
  43218. /**
  43219. * Disposes the resources of the material.
  43220. * @param forceDisposeTextures - Forces the disposal of all textures.
  43221. */
  43222. dispose(forceDisposeTextures?: boolean): void;
  43223. /**
  43224. * Get the current class name of the texture useful for serialization or dynamic coding.
  43225. * @returns "PBRClearCoatConfiguration"
  43226. */
  43227. getClassName(): string;
  43228. /**
  43229. * Add fallbacks to the effect fallbacks list.
  43230. * @param defines defines the Base texture to use.
  43231. * @param fallbacks defines the current fallback list.
  43232. * @param currentRank defines the current fallback rank.
  43233. * @returns the new fallback rank.
  43234. */
  43235. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43236. /**
  43237. * Add the required uniforms to the current list.
  43238. * @param uniforms defines the current uniform list.
  43239. */
  43240. static AddUniforms(uniforms: string[]): void;
  43241. /**
  43242. * Add the required samplers to the current list.
  43243. * @param samplers defines the current sampler list.
  43244. */
  43245. static AddSamplers(samplers: string[]): void;
  43246. /**
  43247. * Add the required uniforms to the current buffer.
  43248. * @param uniformBuffer defines the current uniform buffer.
  43249. */
  43250. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43251. /**
  43252. * Makes a duplicate of the current configuration into another one.
  43253. * @param clearCoatConfiguration define the config where to copy the info
  43254. */
  43255. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43256. /**
  43257. * Serializes this clear coat configuration.
  43258. * @returns - An object with the serialized config.
  43259. */
  43260. serialize(): any;
  43261. /**
  43262. * Parses a Clear Coat Configuration from a serialized object.
  43263. * @param source - Serialized object.
  43264. */
  43265. parse(source: any): void;
  43266. }
  43267. }
  43268. declare module BABYLON {
  43269. /**
  43270. * @hidden
  43271. */
  43272. export interface IMaterialAnisotropicDefines {
  43273. ANISOTROPIC: boolean;
  43274. ANISOTROPIC_TEXTURE: boolean;
  43275. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43276. MAINUV1: boolean; areTexturesDirty: boolean; needUVs: boolean;
  43277. }
  43278. /**
  43279. * Define the code related to the anisotropic parameters of the pbr material.
  43280. */
  43281. export class PBRAnisotropicConfiguration {
  43282. private _isEnabled;
  43283. /**
  43284. * Defines if the anisotropy is enabled in the material.
  43285. */
  43286. isEnabled: boolean;
  43287. /**
  43288. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43289. */
  43290. intensity: number;
  43291. /**
  43292. * Defines if the effect is along the tangents, bitangents or in between.
  43293. * By default, the effect is "strectching" the highlights along the tangents.
  43294. */
  43295. direction: Vector2;
  43296. private _texture;
  43297. /**
  43298. * Stores the anisotropy values in a texture.
  43299. * rg is direction (like normal from -1 to 1)
  43300. * b is a intensity
  43301. */
  43302. texture: Nullable<BaseTexture>;
  43303. /** @hidden */
  43304. private _internalMarkAllSubMeshesAsTexturesDirty;
  43305. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43306. /**
  43307. * Instantiate a new istance of anisotropy configuration.
  43308. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43309. */
  43310. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43311. /**
  43312. * Specifies that the submesh is ready to be used.
  43313. * @param defines the list of "defines" to update.
  43314. * @param scene defines the scene the material belongs to.
  43315. * @returns - boolean indicating that the submesh is ready or not.
  43316. */
  43317. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43318. /**
  43319. * Checks to see if a texture is used in the material.
  43320. * @param defines the list of "defines" to update.
  43321. * @param mesh the mesh we are preparing the defines for.
  43322. * @param scene defines the scene the material belongs to.
  43323. */
  43324. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43325. /**
  43326. * Binds the material data.
  43327. * @param uniformBuffer defines the Uniform buffer to fill in.
  43328. * @param scene defines the scene the material belongs to.
  43329. * @param isFrozen defines wether the material is frozen or not.
  43330. */
  43331. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43332. /**
  43333. * Checks to see if a texture is used in the material.
  43334. * @param texture - Base texture to use.
  43335. * @returns - Boolean specifying if a texture is used in the material.
  43336. */
  43337. hasTexture(texture: BaseTexture): boolean;
  43338. /**
  43339. * Returns an array of the actively used textures.
  43340. * @param activeTextures Array of BaseTextures
  43341. */
  43342. getActiveTextures(activeTextures: BaseTexture[]): void;
  43343. /**
  43344. * Returns the animatable textures.
  43345. * @param animatables Array of animatable textures.
  43346. */
  43347. getAnimatables(animatables: IAnimatable[]): void;
  43348. /**
  43349. * Disposes the resources of the material.
  43350. * @param forceDisposeTextures - Forces the disposal of all textures.
  43351. */
  43352. dispose(forceDisposeTextures?: boolean): void;
  43353. /**
  43354. * Get the current class name of the texture useful for serialization or dynamic coding.
  43355. * @returns "PBRAnisotropicConfiguration"
  43356. */
  43357. getClassName(): string;
  43358. /**
  43359. * Add fallbacks to the effect fallbacks list.
  43360. * @param defines defines the Base texture to use.
  43361. * @param fallbacks defines the current fallback list.
  43362. * @param currentRank defines the current fallback rank.
  43363. * @returns the new fallback rank.
  43364. */
  43365. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43366. /**
  43367. * Add the required uniforms to the current list.
  43368. * @param uniforms defines the current uniform list.
  43369. */
  43370. static AddUniforms(uniforms: string[]): void;
  43371. /**
  43372. * Add the required uniforms to the current buffer.
  43373. * @param uniformBuffer defines the current uniform buffer.
  43374. */
  43375. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43376. /**
  43377. * Add the required samplers to the current list.
  43378. * @param samplers defines the current sampler list.
  43379. */
  43380. static AddSamplers(samplers: string[]): void;
  43381. /**
  43382. * Makes a duplicate of the current configuration into another one.
  43383. * @param anisotropicConfiguration define the config where to copy the info
  43384. */
  43385. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43386. /**
  43387. * Serializes this anisotropy configuration.
  43388. * @returns - An object with the serialized config.
  43389. */
  43390. serialize(): any;
  43391. /**
  43392. * Parses a anisotropy Configuration from a serialized object.
  43393. * @param source - Serialized object.
  43394. */
  43395. parse(source: any): void;
  43396. }
  43397. }
  43398. declare module BABYLON {
  43399. /**
  43400. * @hidden
  43401. */
  43402. export interface IMaterialBRDFDefines {
  43403. BRDF_V_HEIGHT_CORRELATED: boolean;
  43404. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43405. /** @hidden */ areMiscDirty: boolean;
  43406. }
  43407. /**
  43408. * Define the code related to the BRDF parameters of the pbr material.
  43409. */
  43410. export class PBRBRDFConfiguration {
  43411. /**
  43412. * Default value used for the energy conservation.
  43413. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43414. */
  43415. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43416. /**
  43417. * Default value used for the Smith Visibility Height Correlated mode.
  43418. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43419. */
  43420. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43421. private _useEnergyConservation;
  43422. /**
  43423. * Defines if the material uses energy conservation.
  43424. */
  43425. useEnergyConservation: boolean;
  43426. private _useSmithVisibilityHeightCorrelated;
  43427. /**
  43428. * LEGACY Mode set to false
  43429. * Defines if the material uses height smith correlated visibility term.
  43430. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43431. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43432. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43433. * Not relying on height correlated will also disable energy conservation.
  43434. */
  43435. useSmithVisibilityHeightCorrelated: boolean;
  43436. /** @hidden */
  43437. private _internalMarkAllSubMeshesAsMiscDirty;
  43438. /** @hidden */ markAllSubMeshesAsMiscDirty(): void;
  43439. /**
  43440. * Instantiate a new istance of clear coat configuration.
  43441. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43442. */
  43443. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43444. /**
  43445. * Checks to see if a texture is used in the material.
  43446. * @param defines the list of "defines" to update.
  43447. */
  43448. prepareDefines(defines: IMaterialBRDFDefines): void;
  43449. /**
  43450. * Get the current class name of the texture useful for serialization or dynamic coding.
  43451. * @returns "PBRClearCoatConfiguration"
  43452. */
  43453. getClassName(): string;
  43454. /**
  43455. * Makes a duplicate of the current configuration into another one.
  43456. * @param brdfConfiguration define the config where to copy the info
  43457. */
  43458. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43459. /**
  43460. * Serializes this BRDF configuration.
  43461. * @returns - An object with the serialized config.
  43462. */
  43463. serialize(): any;
  43464. /**
  43465. * Parses a BRDF Configuration from a serialized object.
  43466. * @param source - Serialized object.
  43467. */
  43468. parse(source: any): void;
  43469. }
  43470. }
  43471. declare module BABYLON {
  43472. /**
  43473. * @hidden
  43474. */
  43475. export interface IMaterialSheenDefines {
  43476. SHEEN: boolean;
  43477. SHEEN_TEXTURE: boolean;
  43478. SHEEN_TEXTUREDIRECTUV: number;
  43479. SHEEN_LINKWITHALBEDO: boolean;
  43480. /** @hidden */ areTexturesDirty: boolean;
  43481. }
  43482. /**
  43483. * Define the code related to the Sheen parameters of the pbr material.
  43484. */
  43485. export class PBRSheenConfiguration {
  43486. private _isEnabled;
  43487. /**
  43488. * Defines if the material uses sheen.
  43489. */
  43490. isEnabled: boolean;
  43491. private _linkSheenWithAlbedo;
  43492. /**
  43493. * Defines if the sheen is linked to the sheen color.
  43494. */
  43495. linkSheenWithAlbedo: boolean;
  43496. /**
  43497. * Defines the sheen intensity.
  43498. */
  43499. intensity: number;
  43500. /**
  43501. * Defines the sheen color.
  43502. */
  43503. color: Color3;
  43504. private _texture;
  43505. /**
  43506. * Stores the sheen tint values in a texture.
  43507. * rgb is tint
  43508. * a is a intensity
  43509. */
  43510. texture: Nullable<BaseTexture>;
  43511. /** @hidden */
  43512. private _internalMarkAllSubMeshesAsTexturesDirty;
  43513. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43514. /**
  43515. * Instantiate a new istance of clear coat configuration.
  43516. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43517. */
  43518. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43519. /**
  43520. * Specifies that the submesh is ready to be used.
  43521. * @param defines the list of "defines" to update.
  43522. * @param scene defines the scene the material belongs to.
  43523. * @returns - boolean indicating that the submesh is ready or not.
  43524. */
  43525. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43526. /**
  43527. * Checks to see if a texture is used in the material.
  43528. * @param defines the list of "defines" to update.
  43529. * @param scene defines the scene the material belongs to.
  43530. */
  43531. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43532. /**
  43533. * Binds the material data.
  43534. * @param uniformBuffer defines the Uniform buffer to fill in.
  43535. * @param scene defines the scene the material belongs to.
  43536. * @param isFrozen defines wether the material is frozen or not.
  43537. */
  43538. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43539. /**
  43540. * Checks to see if a texture is used in the material.
  43541. * @param texture - Base texture to use.
  43542. * @returns - Boolean specifying if a texture is used in the material.
  43543. */
  43544. hasTexture(texture: BaseTexture): boolean;
  43545. /**
  43546. * Returns an array of the actively used textures.
  43547. * @param activeTextures Array of BaseTextures
  43548. */
  43549. getActiveTextures(activeTextures: BaseTexture[]): void;
  43550. /**
  43551. * Returns the animatable textures.
  43552. * @param animatables Array of animatable textures.
  43553. */
  43554. getAnimatables(animatables: IAnimatable[]): void;
  43555. /**
  43556. * Disposes the resources of the material.
  43557. * @param forceDisposeTextures - Forces the disposal of all textures.
  43558. */
  43559. dispose(forceDisposeTextures?: boolean): void;
  43560. /**
  43561. * Get the current class name of the texture useful for serialization or dynamic coding.
  43562. * @returns "PBRSheenConfiguration"
  43563. */
  43564. getClassName(): string;
  43565. /**
  43566. * Add fallbacks to the effect fallbacks list.
  43567. * @param defines defines the Base texture to use.
  43568. * @param fallbacks defines the current fallback list.
  43569. * @param currentRank defines the current fallback rank.
  43570. * @returns the new fallback rank.
  43571. */
  43572. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43573. /**
  43574. * Add the required uniforms to the current list.
  43575. * @param uniforms defines the current uniform list.
  43576. */
  43577. static AddUniforms(uniforms: string[]): void;
  43578. /**
  43579. * Add the required uniforms to the current buffer.
  43580. * @param uniformBuffer defines the current uniform buffer.
  43581. */
  43582. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43583. /**
  43584. * Add the required samplers to the current list.
  43585. * @param samplers defines the current sampler list.
  43586. */
  43587. static AddSamplers(samplers: string[]): void;
  43588. /**
  43589. * Makes a duplicate of the current configuration into another one.
  43590. * @param sheenConfiguration define the config where to copy the info
  43591. */
  43592. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43593. /**
  43594. * Serializes this BRDF configuration.
  43595. * @returns - An object with the serialized config.
  43596. */
  43597. serialize(): any;
  43598. /**
  43599. * Parses a Sheen Configuration from a serialized object.
  43600. * @param source - Serialized object.
  43601. */
  43602. parse(source: any): void;
  43603. }
  43604. }
  43605. declare module BABYLON {
  43606. /**
  43607. * @hidden
  43608. */
  43609. export interface IMaterialSubSurfaceDefines {
  43610. SUBSURFACE: boolean;
  43611. SS_REFRACTION: boolean;
  43612. SS_TRANSLUCENCY: boolean;
  43613. SS_SCATERRING: boolean;
  43614. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43615. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43616. SS_REFRACTIONMAP_3D: boolean;
  43617. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43618. SS_LODINREFRACTIONALPHA: boolean;
  43619. SS_GAMMAREFRACTION: boolean;
  43620. SS_RGBDREFRACTION: boolean;
  43621. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43622. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43623. /** @hidden */ areTexturesDirty: boolean;
  43624. }
  43625. /**
  43626. * Define the code related to the sub surface parameters of the pbr material.
  43627. */
  43628. export class PBRSubSurfaceConfiguration {
  43629. private _isRefractionEnabled;
  43630. /**
  43631. * Defines if the refraction is enabled in the material.
  43632. */
  43633. isRefractionEnabled: boolean;
  43634. private _isTranslucencyEnabled;
  43635. /**
  43636. * Defines if the translucency is enabled in the material.
  43637. */
  43638. isTranslucencyEnabled: boolean;
  43639. private _isScatteringEnabled;
  43640. /**
  43641. * Defines the refraction intensity of the material.
  43642. * The refraction when enabled replaces the Diffuse part of the material.
  43643. * The intensity helps transitionning between diffuse and refraction.
  43644. */
  43645. refractionIntensity: number;
  43646. /**
  43647. * Defines the translucency intensity of the material.
  43648. * When translucency has been enabled, this defines how much of the "translucency"
  43649. * is addded to the diffuse part of the material.
  43650. */
  43651. translucencyIntensity: number;
  43652. /**
  43653. * Defines the scattering intensity of the material.
  43654. * When scattering has been enabled, this defines how much of the "scattered light"
  43655. * is addded to the diffuse part of the material.
  43656. */
  43657. scatteringIntensity: number;
  43658. private _thicknessTexture;
  43659. /**
  43660. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  43661. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  43662. * 0 would mean minimumThickness
  43663. * 1 would mean maximumThickness
  43664. * The other channels might be use as a mask to vary the different effects intensity.
  43665. */
  43666. thicknessTexture: Nullable<BaseTexture>;
  43667. private _refractionTexture;
  43668. /**
  43669. * Defines the texture to use for refraction.
  43670. */
  43671. refractionTexture: Nullable<BaseTexture>;
  43672. private _indexOfRefraction;
  43673. /**
  43674. * Defines the indice of refraction used in the material.
  43675. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  43676. */
  43677. indexOfRefraction: number;
  43678. private _invertRefractionY;
  43679. /**
  43680. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43681. */
  43682. invertRefractionY: boolean;
  43683. private _linkRefractionWithTransparency;
  43684. /**
  43685. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43686. * Materials half opaque for instance using refraction could benefit from this control.
  43687. */
  43688. linkRefractionWithTransparency: boolean;
  43689. /**
  43690. * Defines the minimum thickness stored in the thickness map.
  43691. * If no thickness map is defined, this value will be used to simulate thickness.
  43692. */
  43693. minimumThickness: number;
  43694. /**
  43695. * Defines the maximum thickness stored in the thickness map.
  43696. */
  43697. maximumThickness: number;
  43698. /**
  43699. * Defines the volume tint of the material.
  43700. * This is used for both translucency and scattering.
  43701. */
  43702. tintColor: Color3;
  43703. /**
  43704. * Defines the distance at which the tint color should be found in the media.
  43705. * This is used for refraction only.
  43706. */
  43707. tintColorAtDistance: number;
  43708. /**
  43709. * Defines how far each channel transmit through the media.
  43710. * It is defined as a color to simplify it selection.
  43711. */
  43712. diffusionDistance: Color3;
  43713. private _useMaskFromThicknessTexture;
  43714. /**
  43715. * Stores the intensity of the different subsurface effects in the thickness texture.
  43716. * * the green channel is the translucency intensity.
  43717. * * the blue channel is the scattering intensity.
  43718. * * the alpha channel is the refraction intensity.
  43719. */
  43720. useMaskFromThicknessTexture: boolean;
  43721. /** @hidden */
  43722. private _internalMarkAllSubMeshesAsTexturesDirty;
  43723. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43724. /**
  43725. * Instantiate a new istance of sub surface configuration.
  43726. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43727. */
  43728. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43729. /**
  43730. * Gets wehter the submesh is ready to be used or not.
  43731. * @param defines the list of "defines" to update.
  43732. * @param scene defines the scene the material belongs to.
  43733. * @returns - boolean indicating that the submesh is ready or not.
  43734. */
  43735. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  43736. /**
  43737. * Checks to see if a texture is used in the material.
  43738. * @param defines the list of "defines" to update.
  43739. * @param scene defines the scene to the material belongs to.
  43740. */
  43741. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  43742. /**
  43743. * Binds the material data.
  43744. * @param uniformBuffer defines the Uniform buffer to fill in.
  43745. * @param scene defines the scene the material belongs to.
  43746. * @param engine defines the engine the material belongs to.
  43747. * @param isFrozen defines wether the material is frozen or not.
  43748. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  43749. */
  43750. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  43751. /**
  43752. * Unbinds the material from the mesh.
  43753. * @param activeEffect defines the effect that should be unbound from.
  43754. * @returns true if unbound, otherwise false
  43755. */
  43756. unbind(activeEffect: Effect): boolean;
  43757. /**
  43758. * Returns the texture used for refraction or null if none is used.
  43759. * @param scene defines the scene the material belongs to.
  43760. * @returns - Refraction texture if present. If no refraction texture and refraction
  43761. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43762. */
  43763. private _getRefractionTexture;
  43764. /**
  43765. * Returns true if alpha blending should be disabled.
  43766. */
  43767. readonly disableAlphaBlending: boolean;
  43768. /**
  43769. * Fills the list of render target textures.
  43770. * @param renderTargets the list of render targets to update
  43771. */
  43772. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  43773. /**
  43774. * Checks to see if a texture is used in the material.
  43775. * @param texture - Base texture to use.
  43776. * @returns - Boolean specifying if a texture is used in the material.
  43777. */
  43778. hasTexture(texture: BaseTexture): boolean;
  43779. /**
  43780. * Gets a boolean indicating that current material needs to register RTT
  43781. * @returns true if this uses a render target otherwise false.
  43782. */
  43783. hasRenderTargetTextures(): boolean;
  43784. /**
  43785. * Returns an array of the actively used textures.
  43786. * @param activeTextures Array of BaseTextures
  43787. */
  43788. getActiveTextures(activeTextures: BaseTexture[]): void;
  43789. /**
  43790. * Returns the animatable textures.
  43791. * @param animatables Array of animatable textures.
  43792. */
  43793. getAnimatables(animatables: IAnimatable[]): void;
  43794. /**
  43795. * Disposes the resources of the material.
  43796. * @param forceDisposeTextures - Forces the disposal of all textures.
  43797. */
  43798. dispose(forceDisposeTextures?: boolean): void;
  43799. /**
  43800. * Get the current class name of the texture useful for serialization or dynamic coding.
  43801. * @returns "PBRSubSurfaceConfiguration"
  43802. */
  43803. getClassName(): string;
  43804. /**
  43805. * Add fallbacks to the effect fallbacks list.
  43806. * @param defines defines the Base texture to use.
  43807. * @param fallbacks defines the current fallback list.
  43808. * @param currentRank defines the current fallback rank.
  43809. * @returns the new fallback rank.
  43810. */
  43811. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43812. /**
  43813. * Add the required uniforms to the current list.
  43814. * @param uniforms defines the current uniform list.
  43815. */
  43816. static AddUniforms(uniforms: string[]): void;
  43817. /**
  43818. * Add the required samplers to the current list.
  43819. * @param samplers defines the current sampler list.
  43820. */
  43821. static AddSamplers(samplers: string[]): void;
  43822. /**
  43823. * Add the required uniforms to the current buffer.
  43824. * @param uniformBuffer defines the current uniform buffer.
  43825. */
  43826. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43827. /**
  43828. * Makes a duplicate of the current configuration into another one.
  43829. * @param configuration define the config where to copy the info
  43830. */
  43831. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  43832. /**
  43833. * Serializes this Sub Surface configuration.
  43834. * @returns - An object with the serialized config.
  43835. */
  43836. serialize(): any;
  43837. /**
  43838. * Parses a Sub Surface Configuration from a serialized object.
  43839. * @param source - Serialized object.
  43840. */
  43841. parse(source: any): void;
  43842. }
  43843. }
  43844. declare module BABYLON {
  43845. /** @hidden */
  43846. export var pbrFragmentDeclaration: {
  43847. name: string;
  43848. shader: string;
  43849. };
  43850. }
  43851. declare module BABYLON {
  43852. /** @hidden */
  43853. export var pbrUboDeclaration: {
  43854. name: string;
  43855. shader: string;
  43856. };
  43857. }
  43858. declare module BABYLON {
  43859. /** @hidden */
  43860. export var pbrFragmentExtraDeclaration: {
  43861. name: string;
  43862. shader: string;
  43863. };
  43864. }
  43865. declare module BABYLON {
  43866. /** @hidden */
  43867. export var pbrFragmentSamplersDeclaration: {
  43868. name: string;
  43869. shader: string;
  43870. };
  43871. }
  43872. declare module BABYLON {
  43873. /** @hidden */
  43874. export var pbrHelperFunctions: {
  43875. name: string;
  43876. shader: string;
  43877. };
  43878. }
  43879. declare module BABYLON {
  43880. /** @hidden */
  43881. export var harmonicsFunctions: {
  43882. name: string;
  43883. shader: string;
  43884. };
  43885. }
  43886. declare module BABYLON {
  43887. /** @hidden */
  43888. export var pbrDirectLightingSetupFunctions: {
  43889. name: string;
  43890. shader: string;
  43891. };
  43892. }
  43893. declare module BABYLON {
  43894. /** @hidden */
  43895. export var pbrDirectLightingFalloffFunctions: {
  43896. name: string;
  43897. shader: string;
  43898. };
  43899. }
  43900. declare module BABYLON {
  43901. /** @hidden */
  43902. export var pbrBRDFFunctions: {
  43903. name: string;
  43904. shader: string;
  43905. };
  43906. }
  43907. declare module BABYLON {
  43908. /** @hidden */
  43909. export var pbrDirectLightingFunctions: {
  43910. name: string;
  43911. shader: string;
  43912. };
  43913. }
  43914. declare module BABYLON {
  43915. /** @hidden */
  43916. export var pbrIBLFunctions: {
  43917. name: string;
  43918. shader: string;
  43919. };
  43920. }
  43921. declare module BABYLON {
  43922. /** @hidden */
  43923. export var pbrDebug: {
  43924. name: string;
  43925. shader: string;
  43926. };
  43927. }
  43928. declare module BABYLON {
  43929. /** @hidden */
  43930. export var pbrPixelShader: {
  43931. name: string;
  43932. shader: string;
  43933. };
  43934. }
  43935. declare module BABYLON {
  43936. /** @hidden */
  43937. export var pbrVertexDeclaration: {
  43938. name: string;
  43939. shader: string;
  43940. };
  43941. }
  43942. declare module BABYLON {
  43943. /** @hidden */
  43944. export var pbrVertexShader: {
  43945. name: string;
  43946. shader: string;
  43947. };
  43948. }
  43949. declare module BABYLON {
  43950. /**
  43951. * Manages the defines for the PBR Material.
  43952. * @hidden
  43953. */
  43954. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  43955. PBR: boolean;
  43956. MAINUV1: boolean;
  43957. MAINUV2: boolean;
  43958. UV1: boolean;
  43959. UV2: boolean;
  43960. ALBEDO: boolean;
  43961. ALBEDODIRECTUV: number;
  43962. VERTEXCOLOR: boolean;
  43963. AMBIENT: boolean;
  43964. AMBIENTDIRECTUV: number;
  43965. AMBIENTINGRAYSCALE: boolean;
  43966. OPACITY: boolean;
  43967. VERTEXALPHA: boolean;
  43968. OPACITYDIRECTUV: number;
  43969. OPACITYRGB: boolean;
  43970. ALPHATEST: boolean;
  43971. DEPTHPREPASS: boolean;
  43972. ALPHABLEND: boolean;
  43973. ALPHAFROMALBEDO: boolean;
  43974. ALPHATESTVALUE: string;
  43975. SPECULAROVERALPHA: boolean;
  43976. RADIANCEOVERALPHA: boolean;
  43977. ALPHAFRESNEL: boolean;
  43978. LINEARALPHAFRESNEL: boolean;
  43979. PREMULTIPLYALPHA: boolean;
  43980. EMISSIVE: boolean;
  43981. EMISSIVEDIRECTUV: number;
  43982. REFLECTIVITY: boolean;
  43983. REFLECTIVITYDIRECTUV: number;
  43984. SPECULARTERM: boolean;
  43985. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  43986. MICROSURFACEAUTOMATIC: boolean;
  43987. LODBASEDMICROSFURACE: boolean;
  43988. MICROSURFACEMAP: boolean;
  43989. MICROSURFACEMAPDIRECTUV: number;
  43990. METALLICWORKFLOW: boolean;
  43991. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  43992. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  43993. METALLNESSSTOREINMETALMAPBLUE: boolean;
  43994. AOSTOREINMETALMAPRED: boolean;
  43995. ENVIRONMENTBRDF: boolean;
  43996. ENVIRONMENTBRDF_RGBD: boolean;
  43997. NORMAL: boolean;
  43998. TANGENT: boolean;
  43999. BUMP: boolean;
  44000. BUMPDIRECTUV: number;
  44001. OBJECTSPACE_NORMALMAP: boolean;
  44002. PARALLAX: boolean;
  44003. PARALLAXOCCLUSION: boolean;
  44004. NORMALXYSCALE: boolean;
  44005. LIGHTMAP: boolean;
  44006. LIGHTMAPDIRECTUV: number;
  44007. USELIGHTMAPASSHADOWMAP: boolean;
  44008. GAMMALIGHTMAP: boolean;
  44009. REFLECTION: boolean;
  44010. REFLECTIONMAP_3D: boolean;
  44011. REFLECTIONMAP_SPHERICAL: boolean;
  44012. REFLECTIONMAP_PLANAR: boolean;
  44013. REFLECTIONMAP_CUBIC: boolean;
  44014. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44015. REFLECTIONMAP_PROJECTION: boolean;
  44016. REFLECTIONMAP_SKYBOX: boolean;
  44017. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44018. REFLECTIONMAP_EXPLICIT: boolean;
  44019. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44020. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44021. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44022. INVERTCUBICMAP: boolean;
  44023. USESPHERICALFROMREFLECTIONMAP: boolean;
  44024. USESPHERICALINVERTEX: boolean;
  44025. REFLECTIONMAP_OPPOSITEZ: boolean;
  44026. LODINREFLECTIONALPHA: boolean;
  44027. GAMMAREFLECTION: boolean;
  44028. RGBDREFLECTION: boolean;
  44029. RADIANCEOCCLUSION: boolean;
  44030. HORIZONOCCLUSION: boolean;
  44031. INSTANCES: boolean;
  44032. NUM_BONE_INFLUENCERS: number;
  44033. BonesPerMesh: number;
  44034. BONETEXTURE: boolean;
  44035. NONUNIFORMSCALING: boolean;
  44036. MORPHTARGETS: boolean;
  44037. MORPHTARGETS_NORMAL: boolean;
  44038. MORPHTARGETS_TANGENT: boolean;
  44039. NUM_MORPH_INFLUENCERS: number;
  44040. IMAGEPROCESSING: boolean;
  44041. VIGNETTE: boolean;
  44042. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44043. VIGNETTEBLENDMODEOPAQUE: boolean;
  44044. TONEMAPPING: boolean;
  44045. TONEMAPPING_ACES: boolean;
  44046. CONTRAST: boolean;
  44047. COLORCURVES: boolean;
  44048. COLORGRADING: boolean;
  44049. COLORGRADING3D: boolean;
  44050. SAMPLER3DGREENDEPTH: boolean;
  44051. SAMPLER3DBGRMAP: boolean;
  44052. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44053. EXPOSURE: boolean;
  44054. MULTIVIEW: boolean;
  44055. USEPHYSICALLIGHTFALLOFF: boolean;
  44056. USEGLTFLIGHTFALLOFF: boolean;
  44057. TWOSIDEDLIGHTING: boolean;
  44058. SHADOWFLOAT: boolean;
  44059. CLIPPLANE: boolean;
  44060. CLIPPLANE2: boolean;
  44061. CLIPPLANE3: boolean;
  44062. CLIPPLANE4: boolean;
  44063. POINTSIZE: boolean;
  44064. FOG: boolean;
  44065. LOGARITHMICDEPTH: boolean;
  44066. FORCENORMALFORWARD: boolean;
  44067. SPECULARAA: boolean;
  44068. CLEARCOAT: boolean;
  44069. CLEARCOAT_DEFAULTIOR: boolean;
  44070. CLEARCOAT_TEXTURE: boolean;
  44071. CLEARCOAT_TEXTUREDIRECTUV: number;
  44072. CLEARCOAT_BUMP: boolean;
  44073. CLEARCOAT_BUMPDIRECTUV: number;
  44074. CLEARCOAT_TINT: boolean;
  44075. CLEARCOAT_TINT_TEXTURE: boolean;
  44076. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44077. ANISOTROPIC: boolean;
  44078. ANISOTROPIC_TEXTURE: boolean;
  44079. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44080. BRDF_V_HEIGHT_CORRELATED: boolean;
  44081. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44082. SHEEN: boolean;
  44083. SHEEN_TEXTURE: boolean;
  44084. SHEEN_TEXTUREDIRECTUV: number;
  44085. SHEEN_LINKWITHALBEDO: boolean;
  44086. SUBSURFACE: boolean;
  44087. SS_REFRACTION: boolean;
  44088. SS_TRANSLUCENCY: boolean;
  44089. SS_SCATERRING: boolean;
  44090. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44091. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44092. SS_REFRACTIONMAP_3D: boolean;
  44093. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44094. SS_LODINREFRACTIONALPHA: boolean;
  44095. SS_GAMMAREFRACTION: boolean;
  44096. SS_RGBDREFRACTION: boolean;
  44097. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44098. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44099. UNLIT: boolean;
  44100. DEBUGMODE: number;
  44101. /**
  44102. * Initializes the PBR Material defines.
  44103. */
  44104. constructor();
  44105. /**
  44106. * Resets the PBR Material defines.
  44107. */
  44108. reset(): void;
  44109. }
  44110. /**
  44111. * The Physically based material base class of BJS.
  44112. *
  44113. * This offers the main features of a standard PBR material.
  44114. * For more information, please refer to the documentation :
  44115. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44116. */
  44117. export abstract class PBRBaseMaterial extends PushMaterial {
  44118. /**
  44119. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44120. */
  44121. static readonly PBRMATERIAL_OPAQUE: number;
  44122. /**
  44123. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44124. */
  44125. static readonly PBRMATERIAL_ALPHATEST: number;
  44126. /**
  44127. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44128. */
  44129. static readonly PBRMATERIAL_ALPHABLEND: number;
  44130. /**
  44131. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44132. * They are also discarded below the alpha cutoff threshold to improve performances.
  44133. */
  44134. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44135. /**
  44136. * Defines the default value of how much AO map is occluding the analytical lights
  44137. * (point spot...).
  44138. */
  44139. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44140. /**
  44141. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44142. */
  44143. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44144. /**
  44145. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44146. * to enhance interoperability with other engines.
  44147. */
  44148. static readonly LIGHTFALLOFF_GLTF: number;
  44149. /**
  44150. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44151. * to enhance interoperability with other materials.
  44152. */
  44153. static readonly LIGHTFALLOFF_STANDARD: number;
  44154. /**
  44155. * Intensity of the direct lights e.g. the four lights available in your scene.
  44156. * This impacts both the direct diffuse and specular highlights.
  44157. */
  44158. protected _directIntensity: number;
  44159. /**
  44160. * Intensity of the emissive part of the material.
  44161. * This helps controlling the emissive effect without modifying the emissive color.
  44162. */
  44163. protected _emissiveIntensity: number;
  44164. /**
  44165. * Intensity of the environment e.g. how much the environment will light the object
  44166. * either through harmonics for rough material or through the refelction for shiny ones.
  44167. */
  44168. protected _environmentIntensity: number;
  44169. /**
  44170. * This is a special control allowing the reduction of the specular highlights coming from the
  44171. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44172. */
  44173. protected _specularIntensity: number;
  44174. /**
  44175. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44176. */
  44177. private _lightingInfos;
  44178. /**
  44179. * Debug Control allowing disabling the bump map on this material.
  44180. */
  44181. protected _disableBumpMap: boolean;
  44182. /**
  44183. * AKA Diffuse Texture in standard nomenclature.
  44184. */
  44185. protected _albedoTexture: Nullable<BaseTexture>;
  44186. /**
  44187. * AKA Occlusion Texture in other nomenclature.
  44188. */
  44189. protected _ambientTexture: Nullable<BaseTexture>;
  44190. /**
  44191. * AKA Occlusion Texture Intensity in other nomenclature.
  44192. */
  44193. protected _ambientTextureStrength: number;
  44194. /**
  44195. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44196. * 1 means it completely occludes it
  44197. * 0 mean it has no impact
  44198. */
  44199. protected _ambientTextureImpactOnAnalyticalLights: number;
  44200. /**
  44201. * Stores the alpha values in a texture.
  44202. */
  44203. protected _opacityTexture: Nullable<BaseTexture>;
  44204. /**
  44205. * Stores the reflection values in a texture.
  44206. */
  44207. protected _reflectionTexture: Nullable<BaseTexture>;
  44208. /**
  44209. * Stores the emissive values in a texture.
  44210. */
  44211. protected _emissiveTexture: Nullable<BaseTexture>;
  44212. /**
  44213. * AKA Specular texture in other nomenclature.
  44214. */
  44215. protected _reflectivityTexture: Nullable<BaseTexture>;
  44216. /**
  44217. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44218. */
  44219. protected _metallicTexture: Nullable<BaseTexture>;
  44220. /**
  44221. * Specifies the metallic scalar of the metallic/roughness workflow.
  44222. * Can also be used to scale the metalness values of the metallic texture.
  44223. */
  44224. protected _metallic: Nullable<number>;
  44225. /**
  44226. * Specifies the roughness scalar of the metallic/roughness workflow.
  44227. * Can also be used to scale the roughness values of the metallic texture.
  44228. */
  44229. protected _roughness: Nullable<number>;
  44230. /**
  44231. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44232. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44233. */
  44234. protected _microSurfaceTexture: Nullable<BaseTexture>;
  44235. /**
  44236. * Stores surface normal data used to displace a mesh in a texture.
  44237. */
  44238. protected _bumpTexture: Nullable<BaseTexture>;
  44239. /**
  44240. * Stores the pre-calculated light information of a mesh in a texture.
  44241. */
  44242. protected _lightmapTexture: Nullable<BaseTexture>;
  44243. /**
  44244. * The color of a material in ambient lighting.
  44245. */
  44246. protected _ambientColor: Color3;
  44247. /**
  44248. * AKA Diffuse Color in other nomenclature.
  44249. */
  44250. protected _albedoColor: Color3;
  44251. /**
  44252. * AKA Specular Color in other nomenclature.
  44253. */
  44254. protected _reflectivityColor: Color3;
  44255. /**
  44256. * The color applied when light is reflected from a material.
  44257. */
  44258. protected _reflectionColor: Color3;
  44259. /**
  44260. * The color applied when light is emitted from a material.
  44261. */
  44262. protected _emissiveColor: Color3;
  44263. /**
  44264. * AKA Glossiness in other nomenclature.
  44265. */
  44266. protected _microSurface: number;
  44267. /**
  44268. * Specifies that the material will use the light map as a show map.
  44269. */
  44270. protected _useLightmapAsShadowmap: boolean;
  44271. /**
  44272. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44273. * makes the reflect vector face the model (under horizon).
  44274. */
  44275. protected _useHorizonOcclusion: boolean;
  44276. /**
  44277. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44278. * too much the area relying on ambient texture to define their ambient occlusion.
  44279. */
  44280. protected _useRadianceOcclusion: boolean;
  44281. /**
  44282. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44283. */
  44284. protected _useAlphaFromAlbedoTexture: boolean;
  44285. /**
  44286. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44287. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44288. */
  44289. protected _useSpecularOverAlpha: boolean;
  44290. /**
  44291. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44292. */
  44293. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44294. /**
  44295. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44296. */
  44297. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44298. /**
  44299. * Specifies if the metallic texture contains the roughness information in its green channel.
  44300. */
  44301. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44302. /**
  44303. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44304. */
  44305. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44306. /**
  44307. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44308. */
  44309. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44310. /**
  44311. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44312. */
  44313. protected _useAmbientInGrayScale: boolean;
  44314. /**
  44315. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44316. * The material will try to infer what glossiness each pixel should be.
  44317. */
  44318. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44319. /**
  44320. * Defines the falloff type used in this material.
  44321. * It by default is Physical.
  44322. */
  44323. protected _lightFalloff: number;
  44324. /**
  44325. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44326. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44327. */
  44328. protected _useRadianceOverAlpha: boolean;
  44329. /**
  44330. * Allows using an object space normal map (instead of tangent space).
  44331. */
  44332. protected _useObjectSpaceNormalMap: boolean;
  44333. /**
  44334. * Allows using the bump map in parallax mode.
  44335. */
  44336. protected _useParallax: boolean;
  44337. /**
  44338. * Allows using the bump map in parallax occlusion mode.
  44339. */
  44340. protected _useParallaxOcclusion: boolean;
  44341. /**
  44342. * Controls the scale bias of the parallax mode.
  44343. */
  44344. protected _parallaxScaleBias: number;
  44345. /**
  44346. * If sets to true, disables all the lights affecting the material.
  44347. */
  44348. protected _disableLighting: boolean;
  44349. /**
  44350. * Number of Simultaneous lights allowed on the material.
  44351. */
  44352. protected _maxSimultaneousLights: number;
  44353. /**
  44354. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44355. */
  44356. protected _invertNormalMapX: boolean;
  44357. /**
  44358. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44359. */
  44360. protected _invertNormalMapY: boolean;
  44361. /**
  44362. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44363. */
  44364. protected _twoSidedLighting: boolean;
  44365. /**
  44366. * Defines the alpha limits in alpha test mode.
  44367. */
  44368. protected _alphaCutOff: number;
  44369. /**
  44370. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44371. */
  44372. protected _forceAlphaTest: boolean;
  44373. /**
  44374. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44375. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44376. */
  44377. protected _useAlphaFresnel: boolean;
  44378. /**
  44379. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44380. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44381. */
  44382. protected _useLinearAlphaFresnel: boolean;
  44383. /**
  44384. * The transparency mode of the material.
  44385. */
  44386. protected _transparencyMode: Nullable<number>;
  44387. /**
  44388. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44389. * from cos thetav and roughness:
  44390. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44391. */
  44392. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44393. /**
  44394. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44395. */
  44396. protected _forceIrradianceInFragment: boolean;
  44397. /**
  44398. * Force normal to face away from face.
  44399. */
  44400. protected _forceNormalForward: boolean;
  44401. /**
  44402. * Enables specular anti aliasing in the PBR shader.
  44403. * It will both interacts on the Geometry for analytical and IBL lighting.
  44404. * It also prefilter the roughness map based on the bump values.
  44405. */
  44406. protected _enableSpecularAntiAliasing: boolean;
  44407. /**
  44408. * Default configuration related to image processing available in the PBR Material.
  44409. */
  44410. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44411. /**
  44412. * Keep track of the image processing observer to allow dispose and replace.
  44413. */
  44414. private _imageProcessingObserver;
  44415. /**
  44416. * Attaches a new image processing configuration to the PBR Material.
  44417. * @param configuration
  44418. */
  44419. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44420. /**
  44421. * Stores the available render targets.
  44422. */
  44423. private _renderTargets;
  44424. /**
  44425. * Sets the global ambient color for the material used in lighting calculations.
  44426. */
  44427. private _globalAmbientColor;
  44428. /**
  44429. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44430. */
  44431. private _useLogarithmicDepth;
  44432. /**
  44433. * If set to true, no lighting calculations will be applied.
  44434. */
  44435. private _unlit;
  44436. private _debugMode;
  44437. /**
  44438. * @hidden
  44439. * This is reserved for the inspector.
  44440. * Defines the material debug mode.
  44441. * It helps seeing only some components of the material while troubleshooting.
  44442. */
  44443. debugMode: number;
  44444. /**
  44445. * @hidden
  44446. * This is reserved for the inspector.
  44447. * Specify from where on screen the debug mode should start.
  44448. * The value goes from -1 (full screen) to 1 (not visible)
  44449. * It helps with side by side comparison against the final render
  44450. * This defaults to -1
  44451. */
  44452. private debugLimit;
  44453. /**
  44454. * @hidden
  44455. * This is reserved for the inspector.
  44456. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44457. * You can use the factor to better multiply the final value.
  44458. */
  44459. private debugFactor;
  44460. /**
  44461. * Defines the clear coat layer parameters for the material.
  44462. */
  44463. readonly clearCoat: PBRClearCoatConfiguration;
  44464. /**
  44465. * Defines the anisotropic parameters for the material.
  44466. */
  44467. readonly anisotropy: PBRAnisotropicConfiguration;
  44468. /**
  44469. * Defines the BRDF parameters for the material.
  44470. */
  44471. readonly brdf: PBRBRDFConfiguration;
  44472. /**
  44473. * Defines the Sheen parameters for the material.
  44474. */
  44475. readonly sheen: PBRSheenConfiguration;
  44476. /**
  44477. * Defines the SubSurface parameters for the material.
  44478. */
  44479. readonly subSurface: PBRSubSurfaceConfiguration;
  44480. /**
  44481. * Custom callback helping to override the default shader used in the material.
  44482. */
  44483. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44484. /**
  44485. * Instantiates a new PBRMaterial instance.
  44486. *
  44487. * @param name The material name
  44488. * @param scene The scene the material will be use in.
  44489. */
  44490. constructor(name: string, scene: Scene);
  44491. /**
  44492. * Gets a boolean indicating that current material needs to register RTT
  44493. */
  44494. readonly hasRenderTargetTextures: boolean;
  44495. /**
  44496. * Gets the name of the material class.
  44497. */
  44498. getClassName(): string;
  44499. /**
  44500. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44501. */
  44502. /**
  44503. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44504. */
  44505. useLogarithmicDepth: boolean;
  44506. /**
  44507. * Gets the current transparency mode.
  44508. */
  44509. /**
  44510. * Sets the transparency mode of the material.
  44511. *
  44512. * | Value | Type | Description |
  44513. * | ----- | ----------------------------------- | ----------- |
  44514. * | 0 | OPAQUE | |
  44515. * | 1 | ALPHATEST | |
  44516. * | 2 | ALPHABLEND | |
  44517. * | 3 | ALPHATESTANDBLEND | |
  44518. *
  44519. */
  44520. transparencyMode: Nullable<number>;
  44521. /**
  44522. * Returns true if alpha blending should be disabled.
  44523. */
  44524. private readonly _disableAlphaBlending;
  44525. /**
  44526. * Specifies whether or not this material should be rendered in alpha blend mode.
  44527. */
  44528. needAlphaBlending(): boolean;
  44529. /**
  44530. * Specifies if the mesh will require alpha blending.
  44531. * @param mesh - BJS mesh.
  44532. */
  44533. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44534. /**
  44535. * Specifies whether or not this material should be rendered in alpha test mode.
  44536. */
  44537. needAlphaTesting(): boolean;
  44538. /**
  44539. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44540. */
  44541. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44542. /**
  44543. * Gets the texture used for the alpha test.
  44544. */
  44545. getAlphaTestTexture(): Nullable<BaseTexture>;
  44546. /**
  44547. * Specifies that the submesh is ready to be used.
  44548. * @param mesh - BJS mesh.
  44549. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44550. * @param useInstances - Specifies that instances should be used.
  44551. * @returns - boolean indicating that the submesh is ready or not.
  44552. */
  44553. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44554. /**
  44555. * Specifies if the material uses metallic roughness workflow.
  44556. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44557. */
  44558. isMetallicWorkflow(): boolean;
  44559. private _prepareEffect;
  44560. private _prepareDefines;
  44561. /**
  44562. * Force shader compilation
  44563. */
  44564. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44565. clipPlane: boolean;
  44566. }>): void;
  44567. /**
  44568. * Initializes the uniform buffer layout for the shader.
  44569. */
  44570. buildUniformLayout(): void;
  44571. /**
  44572. * Unbinds the material from the mesh
  44573. */
  44574. unbind(): void;
  44575. /**
  44576. * Binds the submesh data.
  44577. * @param world - The world matrix.
  44578. * @param mesh - The BJS mesh.
  44579. * @param subMesh - A submesh of the BJS mesh.
  44580. */
  44581. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44582. /**
  44583. * Returns the animatable textures.
  44584. * @returns - Array of animatable textures.
  44585. */
  44586. getAnimatables(): IAnimatable[];
  44587. /**
  44588. * Returns the texture used for reflections.
  44589. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44590. */
  44591. private _getReflectionTexture;
  44592. /**
  44593. * Returns an array of the actively used textures.
  44594. * @returns - Array of BaseTextures
  44595. */
  44596. getActiveTextures(): BaseTexture[];
  44597. /**
  44598. * Checks to see if a texture is used in the material.
  44599. * @param texture - Base texture to use.
  44600. * @returns - Boolean specifying if a texture is used in the material.
  44601. */
  44602. hasTexture(texture: BaseTexture): boolean;
  44603. /**
  44604. * Disposes the resources of the material.
  44605. * @param forceDisposeEffect - Forces the disposal of effects.
  44606. * @param forceDisposeTextures - Forces the disposal of all textures.
  44607. */
  44608. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44609. }
  44610. }
  44611. declare module BABYLON {
  44612. /**
  44613. * The Physically based material of BJS.
  44614. *
  44615. * This offers the main features of a standard PBR material.
  44616. * For more information, please refer to the documentation :
  44617. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44618. */
  44619. export class PBRMaterial extends PBRBaseMaterial {
  44620. /**
  44621. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44622. */
  44623. static readonly PBRMATERIAL_OPAQUE: number;
  44624. /**
  44625. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44626. */
  44627. static readonly PBRMATERIAL_ALPHATEST: number;
  44628. /**
  44629. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44630. */
  44631. static readonly PBRMATERIAL_ALPHABLEND: number;
  44632. /**
  44633. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44634. * They are also discarded below the alpha cutoff threshold to improve performances.
  44635. */
  44636. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44637. /**
  44638. * Defines the default value of how much AO map is occluding the analytical lights
  44639. * (point spot...).
  44640. */
  44641. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44642. /**
  44643. * Intensity of the direct lights e.g. the four lights available in your scene.
  44644. * This impacts both the direct diffuse and specular highlights.
  44645. */
  44646. directIntensity: number;
  44647. /**
  44648. * Intensity of the emissive part of the material.
  44649. * This helps controlling the emissive effect without modifying the emissive color.
  44650. */
  44651. emissiveIntensity: number;
  44652. /**
  44653. * Intensity of the environment e.g. how much the environment will light the object
  44654. * either through harmonics for rough material or through the refelction for shiny ones.
  44655. */
  44656. environmentIntensity: number;
  44657. /**
  44658. * This is a special control allowing the reduction of the specular highlights coming from the
  44659. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44660. */
  44661. specularIntensity: number;
  44662. /**
  44663. * Debug Control allowing disabling the bump map on this material.
  44664. */
  44665. disableBumpMap: boolean;
  44666. /**
  44667. * AKA Diffuse Texture in standard nomenclature.
  44668. */
  44669. albedoTexture: BaseTexture;
  44670. /**
  44671. * AKA Occlusion Texture in other nomenclature.
  44672. */
  44673. ambientTexture: BaseTexture;
  44674. /**
  44675. * AKA Occlusion Texture Intensity in other nomenclature.
  44676. */
  44677. ambientTextureStrength: number;
  44678. /**
  44679. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44680. * 1 means it completely occludes it
  44681. * 0 mean it has no impact
  44682. */
  44683. ambientTextureImpactOnAnalyticalLights: number;
  44684. /**
  44685. * Stores the alpha values in a texture.
  44686. */
  44687. opacityTexture: BaseTexture;
  44688. /**
  44689. * Stores the reflection values in a texture.
  44690. */
  44691. reflectionTexture: Nullable<BaseTexture>;
  44692. /**
  44693. * Stores the emissive values in a texture.
  44694. */
  44695. emissiveTexture: BaseTexture;
  44696. /**
  44697. * AKA Specular texture in other nomenclature.
  44698. */
  44699. reflectivityTexture: BaseTexture;
  44700. /**
  44701. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44702. */
  44703. metallicTexture: BaseTexture;
  44704. /**
  44705. * Specifies the metallic scalar of the metallic/roughness workflow.
  44706. * Can also be used to scale the metalness values of the metallic texture.
  44707. */
  44708. metallic: Nullable<number>;
  44709. /**
  44710. * Specifies the roughness scalar of the metallic/roughness workflow.
  44711. * Can also be used to scale the roughness values of the metallic texture.
  44712. */
  44713. roughness: Nullable<number>;
  44714. /**
  44715. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44716. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44717. */
  44718. microSurfaceTexture: BaseTexture;
  44719. /**
  44720. * Stores surface normal data used to displace a mesh in a texture.
  44721. */
  44722. bumpTexture: BaseTexture;
  44723. /**
  44724. * Stores the pre-calculated light information of a mesh in a texture.
  44725. */
  44726. lightmapTexture: BaseTexture;
  44727. /**
  44728. * Stores the refracted light information in a texture.
  44729. */
  44730. refractionTexture: Nullable<BaseTexture>;
  44731. /**
  44732. * The color of a material in ambient lighting.
  44733. */
  44734. ambientColor: Color3;
  44735. /**
  44736. * AKA Diffuse Color in other nomenclature.
  44737. */
  44738. albedoColor: Color3;
  44739. /**
  44740. * AKA Specular Color in other nomenclature.
  44741. */
  44742. reflectivityColor: Color3;
  44743. /**
  44744. * The color reflected from the material.
  44745. */
  44746. reflectionColor: Color3;
  44747. /**
  44748. * The color emitted from the material.
  44749. */
  44750. emissiveColor: Color3;
  44751. /**
  44752. * AKA Glossiness in other nomenclature.
  44753. */
  44754. microSurface: number;
  44755. /**
  44756. * source material index of refraction (IOR)' / 'destination material IOR.
  44757. */
  44758. indexOfRefraction: number;
  44759. /**
  44760. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44761. */
  44762. invertRefractionY: boolean;
  44763. /**
  44764. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44765. * Materials half opaque for instance using refraction could benefit from this control.
  44766. */
  44767. linkRefractionWithTransparency: boolean;
  44768. /**
  44769. * If true, the light map contains occlusion information instead of lighting info.
  44770. */
  44771. useLightmapAsShadowmap: boolean;
  44772. /**
  44773. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44774. */
  44775. useAlphaFromAlbedoTexture: boolean;
  44776. /**
  44777. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44778. */
  44779. forceAlphaTest: boolean;
  44780. /**
  44781. * Defines the alpha limits in alpha test mode.
  44782. */
  44783. alphaCutOff: number;
  44784. /**
  44785. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44786. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44787. */
  44788. useSpecularOverAlpha: boolean;
  44789. /**
  44790. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44791. */
  44792. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44793. /**
  44794. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44795. */
  44796. useRoughnessFromMetallicTextureAlpha: boolean;
  44797. /**
  44798. * Specifies if the metallic texture contains the roughness information in its green channel.
  44799. */
  44800. useRoughnessFromMetallicTextureGreen: boolean;
  44801. /**
  44802. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44803. */
  44804. useMetallnessFromMetallicTextureBlue: boolean;
  44805. /**
  44806. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44807. */
  44808. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44809. /**
  44810. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44811. */
  44812. useAmbientInGrayScale: boolean;
  44813. /**
  44814. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44815. * The material will try to infer what glossiness each pixel should be.
  44816. */
  44817. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44818. /**
  44819. * BJS is using an harcoded light falloff based on a manually sets up range.
  44820. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44821. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44822. */
  44823. /**
  44824. * BJS is using an harcoded light falloff based on a manually sets up range.
  44825. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44826. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44827. */
  44828. usePhysicalLightFalloff: boolean;
  44829. /**
  44830. * In order to support the falloff compatibility with gltf, a special mode has been added
  44831. * to reproduce the gltf light falloff.
  44832. */
  44833. /**
  44834. * In order to support the falloff compatibility with gltf, a special mode has been added
  44835. * to reproduce the gltf light falloff.
  44836. */
  44837. useGLTFLightFalloff: boolean;
  44838. /**
  44839. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44840. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44841. */
  44842. useRadianceOverAlpha: boolean;
  44843. /**
  44844. * Allows using an object space normal map (instead of tangent space).
  44845. */
  44846. useObjectSpaceNormalMap: boolean;
  44847. /**
  44848. * Allows using the bump map in parallax mode.
  44849. */
  44850. useParallax: boolean;
  44851. /**
  44852. * Allows using the bump map in parallax occlusion mode.
  44853. */
  44854. useParallaxOcclusion: boolean;
  44855. /**
  44856. * Controls the scale bias of the parallax mode.
  44857. */
  44858. parallaxScaleBias: number;
  44859. /**
  44860. * If sets to true, disables all the lights affecting the material.
  44861. */
  44862. disableLighting: boolean;
  44863. /**
  44864. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44865. */
  44866. forceIrradianceInFragment: boolean;
  44867. /**
  44868. * Number of Simultaneous lights allowed on the material.
  44869. */
  44870. maxSimultaneousLights: number;
  44871. /**
  44872. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44873. */
  44874. invertNormalMapX: boolean;
  44875. /**
  44876. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44877. */
  44878. invertNormalMapY: boolean;
  44879. /**
  44880. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44881. */
  44882. twoSidedLighting: boolean;
  44883. /**
  44884. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44885. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44886. */
  44887. useAlphaFresnel: boolean;
  44888. /**
  44889. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44890. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44891. */
  44892. useLinearAlphaFresnel: boolean;
  44893. /**
  44894. * Let user defines the brdf lookup texture used for IBL.
  44895. * A default 8bit version is embedded but you could point at :
  44896. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  44897. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44898. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44899. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44900. */
  44901. environmentBRDFTexture: Nullable<BaseTexture>;
  44902. /**
  44903. * Force normal to face away from face.
  44904. */
  44905. forceNormalForward: boolean;
  44906. /**
  44907. * Enables specular anti aliasing in the PBR shader.
  44908. * It will both interacts on the Geometry for analytical and IBL lighting.
  44909. * It also prefilter the roughness map based on the bump values.
  44910. */
  44911. enableSpecularAntiAliasing: boolean;
  44912. /**
  44913. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44914. * makes the reflect vector face the model (under horizon).
  44915. */
  44916. useHorizonOcclusion: boolean;
  44917. /**
  44918. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44919. * too much the area relying on ambient texture to define their ambient occlusion.
  44920. */
  44921. useRadianceOcclusion: boolean;
  44922. /**
  44923. * If set to true, no lighting calculations will be applied.
  44924. */
  44925. unlit: boolean;
  44926. /**
  44927. * Gets the image processing configuration used either in this material.
  44928. */
  44929. /**
  44930. * Sets the Default image processing configuration used either in the this material.
  44931. *
  44932. * If sets to null, the scene one is in use.
  44933. */
  44934. imageProcessingConfiguration: ImageProcessingConfiguration;
  44935. /**
  44936. * Gets wether the color curves effect is enabled.
  44937. */
  44938. /**
  44939. * Sets wether the color curves effect is enabled.
  44940. */
  44941. cameraColorCurvesEnabled: boolean;
  44942. /**
  44943. * Gets wether the color grading effect is enabled.
  44944. */
  44945. /**
  44946. * Gets wether the color grading effect is enabled.
  44947. */
  44948. cameraColorGradingEnabled: boolean;
  44949. /**
  44950. * Gets wether tonemapping is enabled or not.
  44951. */
  44952. /**
  44953. * Sets wether tonemapping is enabled or not
  44954. */
  44955. cameraToneMappingEnabled: boolean;
  44956. /**
  44957. * The camera exposure used on this material.
  44958. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44959. * This corresponds to a photographic exposure.
  44960. */
  44961. /**
  44962. * The camera exposure used on this material.
  44963. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44964. * This corresponds to a photographic exposure.
  44965. */
  44966. cameraExposure: number;
  44967. /**
  44968. * Gets The camera contrast used on this material.
  44969. */
  44970. /**
  44971. * Sets The camera contrast used on this material.
  44972. */
  44973. cameraContrast: number;
  44974. /**
  44975. * Gets the Color Grading 2D Lookup Texture.
  44976. */
  44977. /**
  44978. * Sets the Color Grading 2D Lookup Texture.
  44979. */
  44980. cameraColorGradingTexture: Nullable<BaseTexture>;
  44981. /**
  44982. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44983. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44984. * 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;
  44985. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44986. */
  44987. /**
  44988. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44989. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44990. * 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;
  44991. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44992. */
  44993. cameraColorCurves: Nullable<ColorCurves>;
  44994. /**
  44995. * Instantiates a new PBRMaterial instance.
  44996. *
  44997. * @param name The material name
  44998. * @param scene The scene the material will be use in.
  44999. */
  45000. constructor(name: string, scene: Scene);
  45001. /**
  45002. * Returns the name of this material class.
  45003. */
  45004. getClassName(): string;
  45005. /**
  45006. * Makes a duplicate of the current material.
  45007. * @param name - name to use for the new material.
  45008. */
  45009. clone(name: string): PBRMaterial;
  45010. /**
  45011. * Serializes this PBR Material.
  45012. * @returns - An object with the serialized material.
  45013. */
  45014. serialize(): any;
  45015. /**
  45016. * Parses a PBR Material from a serialized object.
  45017. * @param source - Serialized object.
  45018. * @param scene - BJS scene instance.
  45019. * @param rootUrl - url for the scene object
  45020. * @returns - PBRMaterial
  45021. */
  45022. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45023. }
  45024. }
  45025. declare module BABYLON {
  45026. /**
  45027. * Direct draw surface info
  45028. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45029. */
  45030. export interface DDSInfo {
  45031. /**
  45032. * Width of the texture
  45033. */
  45034. width: number;
  45035. /**
  45036. * Width of the texture
  45037. */
  45038. height: number;
  45039. /**
  45040. * Number of Mipmaps for the texture
  45041. * @see https://en.wikipedia.org/wiki/Mipmap
  45042. */
  45043. mipmapCount: number;
  45044. /**
  45045. * If the textures format is a known fourCC format
  45046. * @see https://www.fourcc.org/
  45047. */
  45048. isFourCC: boolean;
  45049. /**
  45050. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45051. */
  45052. isRGB: boolean;
  45053. /**
  45054. * If the texture is a lumincance format
  45055. */
  45056. isLuminance: boolean;
  45057. /**
  45058. * If this is a cube texture
  45059. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45060. */
  45061. isCube: boolean;
  45062. /**
  45063. * If the texture is a compressed format eg. FOURCC_DXT1
  45064. */
  45065. isCompressed: boolean;
  45066. /**
  45067. * The dxgiFormat of the texture
  45068. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45069. */
  45070. dxgiFormat: number;
  45071. /**
  45072. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45073. */
  45074. textureType: number;
  45075. /**
  45076. * Sphericle polynomial created for the dds texture
  45077. */
  45078. sphericalPolynomial?: SphericalPolynomial;
  45079. }
  45080. /**
  45081. * Class used to provide DDS decompression tools
  45082. */
  45083. export class DDSTools {
  45084. /**
  45085. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45086. */
  45087. static StoreLODInAlphaChannel: boolean;
  45088. /**
  45089. * Gets DDS information from an array buffer
  45090. * @param arrayBuffer defines the array buffer to read data from
  45091. * @returns the DDS information
  45092. */
  45093. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45094. private static _FloatView;
  45095. private static _Int32View;
  45096. private static _ToHalfFloat;
  45097. private static _FromHalfFloat;
  45098. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45099. private static _GetHalfFloatRGBAArrayBuffer;
  45100. private static _GetFloatRGBAArrayBuffer;
  45101. private static _GetFloatAsUIntRGBAArrayBuffer;
  45102. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45103. private static _GetRGBAArrayBuffer;
  45104. private static _ExtractLongWordOrder;
  45105. private static _GetRGBArrayBuffer;
  45106. private static _GetLuminanceArrayBuffer;
  45107. /**
  45108. * Uploads DDS Levels to a Babylon Texture
  45109. * @hidden
  45110. */
  45111. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45112. }
  45113. interface Engine {
  45114. /**
  45115. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45116. * @param rootUrl defines the url where the file to load is located
  45117. * @param scene defines the current scene
  45118. * @param lodScale defines scale to apply to the mip map selection
  45119. * @param lodOffset defines offset to apply to the mip map selection
  45120. * @param onLoad defines an optional callback raised when the texture is loaded
  45121. * @param onError defines an optional callback raised if there is an issue to load the texture
  45122. * @param format defines the format of the data
  45123. * @param forcedExtension defines the extension to use to pick the right loader
  45124. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45125. * @returns the cube texture as an InternalTexture
  45126. */
  45127. 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;
  45128. }
  45129. }
  45130. declare module BABYLON {
  45131. /**
  45132. * Implementation of the DDS Texture Loader.
  45133. * @hidden
  45134. */
  45135. export class _DDSTextureLoader implements IInternalTextureLoader {
  45136. /**
  45137. * Defines wether the loader supports cascade loading the different faces.
  45138. */
  45139. readonly supportCascades: boolean;
  45140. /**
  45141. * This returns if the loader support the current file information.
  45142. * @param extension defines the file extension of the file being loaded
  45143. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45144. * @param fallback defines the fallback internal texture if any
  45145. * @param isBase64 defines whether the texture is encoded as a base64
  45146. * @param isBuffer defines whether the texture data are stored as a buffer
  45147. * @returns true if the loader can load the specified file
  45148. */
  45149. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45150. /**
  45151. * Transform the url before loading if required.
  45152. * @param rootUrl the url of the texture
  45153. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45154. * @returns the transformed texture
  45155. */
  45156. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45157. /**
  45158. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45159. * @param rootUrl the url of the texture
  45160. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45161. * @returns the fallback texture
  45162. */
  45163. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45164. /**
  45165. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45166. * @param data contains the texture data
  45167. * @param texture defines the BabylonJS internal texture
  45168. * @param createPolynomials will be true if polynomials have been requested
  45169. * @param onLoad defines the callback to trigger once the texture is ready
  45170. * @param onError defines the callback to trigger in case of error
  45171. */
  45172. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45173. /**
  45174. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45175. * @param data contains the texture data
  45176. * @param texture defines the BabylonJS internal texture
  45177. * @param callback defines the method to call once ready to upload
  45178. */
  45179. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45180. }
  45181. }
  45182. declare module BABYLON {
  45183. /** @hidden */
  45184. export var rgbdEncodePixelShader: {
  45185. name: string;
  45186. shader: string;
  45187. };
  45188. }
  45189. declare module BABYLON {
  45190. /**
  45191. * Raw texture data and descriptor sufficient for WebGL texture upload
  45192. */
  45193. export interface EnvironmentTextureInfo {
  45194. /**
  45195. * Version of the environment map
  45196. */
  45197. version: number;
  45198. /**
  45199. * Width of image
  45200. */
  45201. width: number;
  45202. /**
  45203. * Irradiance information stored in the file.
  45204. */
  45205. irradiance: any;
  45206. /**
  45207. * Specular information stored in the file.
  45208. */
  45209. specular: any;
  45210. }
  45211. /**
  45212. * Sets of helpers addressing the serialization and deserialization of environment texture
  45213. * stored in a BabylonJS env file.
  45214. * Those files are usually stored as .env files.
  45215. */
  45216. export class EnvironmentTextureTools {
  45217. /**
  45218. * Magic number identifying the env file.
  45219. */
  45220. private static _MagicBytes;
  45221. /**
  45222. * Gets the environment info from an env file.
  45223. * @param data The array buffer containing the .env bytes.
  45224. * @returns the environment file info (the json header) if successfully parsed.
  45225. */
  45226. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45227. /**
  45228. * Creates an environment texture from a loaded cube texture.
  45229. * @param texture defines the cube texture to convert in env file
  45230. * @return a promise containing the environment data if succesfull.
  45231. */
  45232. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45233. /**
  45234. * Creates a JSON representation of the spherical data.
  45235. * @param texture defines the texture containing the polynomials
  45236. * @return the JSON representation of the spherical info
  45237. */
  45238. private static _CreateEnvTextureIrradiance;
  45239. /**
  45240. * Uploads the texture info contained in the env file to the GPU.
  45241. * @param texture defines the internal texture to upload to
  45242. * @param arrayBuffer defines the buffer cotaining the data to load
  45243. * @param info defines the texture info retrieved through the GetEnvInfo method
  45244. * @returns a promise
  45245. */
  45246. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45247. /**
  45248. * Uploads the levels of image data to the GPU.
  45249. * @param texture defines the internal texture to upload to
  45250. * @param imageData defines the array buffer views of image data [mipmap][face]
  45251. * @returns a promise
  45252. */
  45253. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45254. /**
  45255. * Uploads spherical polynomials information to the texture.
  45256. * @param texture defines the texture we are trying to upload the information to
  45257. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45258. */
  45259. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45260. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45261. }
  45262. }
  45263. declare module BABYLON {
  45264. /**
  45265. * Implementation of the ENV Texture Loader.
  45266. * @hidden
  45267. */
  45268. export class _ENVTextureLoader implements IInternalTextureLoader {
  45269. /**
  45270. * Defines wether the loader supports cascade loading the different faces.
  45271. */
  45272. readonly supportCascades: boolean;
  45273. /**
  45274. * This returns if the loader support the current file information.
  45275. * @param extension defines the file extension of the file being loaded
  45276. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45277. * @param fallback defines the fallback internal texture if any
  45278. * @param isBase64 defines whether the texture is encoded as a base64
  45279. * @param isBuffer defines whether the texture data are stored as a buffer
  45280. * @returns true if the loader can load the specified file
  45281. */
  45282. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45283. /**
  45284. * Transform the url before loading if required.
  45285. * @param rootUrl the url of the texture
  45286. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45287. * @returns the transformed texture
  45288. */
  45289. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45290. /**
  45291. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45292. * @param rootUrl the url of the texture
  45293. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45294. * @returns the fallback texture
  45295. */
  45296. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45297. /**
  45298. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45299. * @param data contains the texture data
  45300. * @param texture defines the BabylonJS internal texture
  45301. * @param createPolynomials will be true if polynomials have been requested
  45302. * @param onLoad defines the callback to trigger once the texture is ready
  45303. * @param onError defines the callback to trigger in case of error
  45304. */
  45305. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45306. /**
  45307. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45308. * @param data contains the texture data
  45309. * @param texture defines the BabylonJS internal texture
  45310. * @param callback defines the method to call once ready to upload
  45311. */
  45312. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45313. }
  45314. }
  45315. declare module BABYLON {
  45316. /**
  45317. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45318. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45319. */
  45320. export class KhronosTextureContainer {
  45321. /** contents of the KTX container file */
  45322. arrayBuffer: any;
  45323. private static HEADER_LEN;
  45324. private static COMPRESSED_2D;
  45325. private static COMPRESSED_3D;
  45326. private static TEX_2D;
  45327. private static TEX_3D;
  45328. /**
  45329. * Gets the openGL type
  45330. */
  45331. glType: number;
  45332. /**
  45333. * Gets the openGL type size
  45334. */
  45335. glTypeSize: number;
  45336. /**
  45337. * Gets the openGL format
  45338. */
  45339. glFormat: number;
  45340. /**
  45341. * Gets the openGL internal format
  45342. */
  45343. glInternalFormat: number;
  45344. /**
  45345. * Gets the base internal format
  45346. */
  45347. glBaseInternalFormat: number;
  45348. /**
  45349. * Gets image width in pixel
  45350. */
  45351. pixelWidth: number;
  45352. /**
  45353. * Gets image height in pixel
  45354. */
  45355. pixelHeight: number;
  45356. /**
  45357. * Gets image depth in pixels
  45358. */
  45359. pixelDepth: number;
  45360. /**
  45361. * Gets the number of array elements
  45362. */
  45363. numberOfArrayElements: number;
  45364. /**
  45365. * Gets the number of faces
  45366. */
  45367. numberOfFaces: number;
  45368. /**
  45369. * Gets the number of mipmap levels
  45370. */
  45371. numberOfMipmapLevels: number;
  45372. /**
  45373. * Gets the bytes of key value data
  45374. */
  45375. bytesOfKeyValueData: number;
  45376. /**
  45377. * Gets the load type
  45378. */
  45379. loadType: number;
  45380. /**
  45381. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45382. */
  45383. isInvalid: boolean;
  45384. /**
  45385. * Creates a new KhronosTextureContainer
  45386. * @param arrayBuffer contents of the KTX container file
  45387. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45388. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45389. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45390. */
  45391. constructor(
  45392. /** contents of the KTX container file */
  45393. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45394. /**
  45395. * Uploads KTX content to a Babylon Texture.
  45396. * It is assumed that the texture has already been created & is currently bound
  45397. * @hidden
  45398. */
  45399. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45400. private _upload2DCompressedLevels;
  45401. }
  45402. }
  45403. declare module BABYLON {
  45404. /**
  45405. * Implementation of the KTX Texture Loader.
  45406. * @hidden
  45407. */
  45408. export class _KTXTextureLoader implements IInternalTextureLoader {
  45409. /**
  45410. * Defines wether the loader supports cascade loading the different faces.
  45411. */
  45412. readonly supportCascades: boolean;
  45413. /**
  45414. * This returns if the loader support the current file information.
  45415. * @param extension defines the file extension of the file being loaded
  45416. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45417. * @param fallback defines the fallback internal texture if any
  45418. * @param isBase64 defines whether the texture is encoded as a base64
  45419. * @param isBuffer defines whether the texture data are stored as a buffer
  45420. * @returns true if the loader can load the specified file
  45421. */
  45422. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45423. /**
  45424. * Transform the url before loading if required.
  45425. * @param rootUrl the url of the texture
  45426. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45427. * @returns the transformed texture
  45428. */
  45429. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45430. /**
  45431. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45432. * @param rootUrl the url of the texture
  45433. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45434. * @returns the fallback texture
  45435. */
  45436. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45437. /**
  45438. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45439. * @param data contains the texture data
  45440. * @param texture defines the BabylonJS internal texture
  45441. * @param createPolynomials will be true if polynomials have been requested
  45442. * @param onLoad defines the callback to trigger once the texture is ready
  45443. * @param onError defines the callback to trigger in case of error
  45444. */
  45445. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45446. /**
  45447. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45448. * @param data contains the texture data
  45449. * @param texture defines the BabylonJS internal texture
  45450. * @param callback defines the method to call once ready to upload
  45451. */
  45452. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45453. }
  45454. }
  45455. declare module BABYLON {
  45456. /** @hidden */
  45457. export var _forceSceneHelpersToBundle: boolean;
  45458. interface Scene {
  45459. /**
  45460. * Creates a default light for the scene.
  45461. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45462. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45463. */
  45464. createDefaultLight(replace?: boolean): void;
  45465. /**
  45466. * Creates a default camera for the scene.
  45467. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45468. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45469. * @param replace has default false, when true replaces the active camera in the scene
  45470. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45471. */
  45472. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45473. /**
  45474. * Creates a default camera and a default light.
  45475. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45476. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45477. * @param replace has the default false, when true replaces the active camera/light in the scene
  45478. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45479. */
  45480. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45481. /**
  45482. * Creates a new sky box
  45483. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45484. * @param environmentTexture defines the texture to use as environment texture
  45485. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45486. * @param scale defines the overall scale of the skybox
  45487. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45488. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45489. * @returns a new mesh holding the sky box
  45490. */
  45491. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45492. /**
  45493. * Creates a new environment
  45494. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45495. * @param options defines the options you can use to configure the environment
  45496. * @returns the new EnvironmentHelper
  45497. */
  45498. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45499. /**
  45500. * Creates a new VREXperienceHelper
  45501. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45502. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45503. * @returns a new VREXperienceHelper
  45504. */
  45505. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45506. /**
  45507. * Creates a new XREXperienceHelper
  45508. * @see http://doc.babylonjs.com/how_to/webxr
  45509. * @returns a promise for a new XREXperienceHelper
  45510. */
  45511. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45512. }
  45513. }
  45514. declare module BABYLON {
  45515. /**
  45516. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45517. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45518. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45519. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45520. */
  45521. export class VideoDome extends TransformNode {
  45522. /**
  45523. * Define the video source as a Monoscopic panoramic 360 video.
  45524. */
  45525. static readonly MODE_MONOSCOPIC: number;
  45526. /**
  45527. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45528. */
  45529. static readonly MODE_TOPBOTTOM: number;
  45530. /**
  45531. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45532. */
  45533. static readonly MODE_SIDEBYSIDE: number;
  45534. private _useDirectMapping;
  45535. /**
  45536. * The video texture being displayed on the sphere
  45537. */
  45538. protected _videoTexture: VideoTexture;
  45539. /**
  45540. * Gets the video texture being displayed on the sphere
  45541. */
  45542. readonly videoTexture: VideoTexture;
  45543. /**
  45544. * The skybox material
  45545. */
  45546. protected _material: BackgroundMaterial;
  45547. /**
  45548. * The surface used for the skybox
  45549. */
  45550. protected _mesh: Mesh;
  45551. /**
  45552. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45553. * Also see the options.resolution property.
  45554. */
  45555. fovMultiplier: number;
  45556. private _videoMode;
  45557. /**
  45558. * Gets or set the current video mode for the video. It can be:
  45559. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45560. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45561. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45562. */
  45563. videoMode: number;
  45564. /**
  45565. * Oberserver used in Stereoscopic VR Mode.
  45566. */
  45567. private _onBeforeCameraRenderObserver;
  45568. /**
  45569. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45570. * @param name Element's name, child elements will append suffixes for their own names.
  45571. * @param urlsOrVideo defines the url(s) or the video element to use
  45572. * @param options An object containing optional or exposed sub element properties
  45573. */
  45574. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45575. resolution?: number;
  45576. clickToPlay?: boolean;
  45577. autoPlay?: boolean;
  45578. loop?: boolean;
  45579. size?: number;
  45580. poster?: string;
  45581. faceForward?: boolean;
  45582. useDirectMapping?: boolean;
  45583. }, scene: Scene);
  45584. private _changeVideoMode;
  45585. /**
  45586. * Releases resources associated with this node.
  45587. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45588. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45589. */
  45590. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45591. }
  45592. }
  45593. declare module BABYLON {
  45594. /**
  45595. * This class can be used to get instrumentation data from a Babylon engine
  45596. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45597. */
  45598. export class EngineInstrumentation implements IDisposable {
  45599. /**
  45600. * Define the instrumented engine.
  45601. */
  45602. engine: Engine;
  45603. private _captureGPUFrameTime;
  45604. private _gpuFrameTimeToken;
  45605. private _gpuFrameTime;
  45606. private _captureShaderCompilationTime;
  45607. private _shaderCompilationTime;
  45608. private _onBeginFrameObserver;
  45609. private _onEndFrameObserver;
  45610. private _onBeforeShaderCompilationObserver;
  45611. private _onAfterShaderCompilationObserver;
  45612. /**
  45613. * Gets the perf counter used for GPU frame time
  45614. */
  45615. readonly gpuFrameTimeCounter: PerfCounter;
  45616. /**
  45617. * Gets the GPU frame time capture status
  45618. */
  45619. /**
  45620. * Enable or disable the GPU frame time capture
  45621. */
  45622. captureGPUFrameTime: boolean;
  45623. /**
  45624. * Gets the perf counter used for shader compilation time
  45625. */
  45626. readonly shaderCompilationTimeCounter: PerfCounter;
  45627. /**
  45628. * Gets the shader compilation time capture status
  45629. */
  45630. /**
  45631. * Enable or disable the shader compilation time capture
  45632. */
  45633. captureShaderCompilationTime: boolean;
  45634. /**
  45635. * Instantiates a new engine instrumentation.
  45636. * This class can be used to get instrumentation data from a Babylon engine
  45637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45638. * @param engine Defines the engine to instrument
  45639. */
  45640. constructor(
  45641. /**
  45642. * Define the instrumented engine.
  45643. */
  45644. engine: Engine);
  45645. /**
  45646. * Dispose and release associated resources.
  45647. */
  45648. dispose(): void;
  45649. }
  45650. }
  45651. declare module BABYLON {
  45652. /**
  45653. * This class can be used to get instrumentation data from a Babylon engine
  45654. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45655. */
  45656. export class SceneInstrumentation implements IDisposable {
  45657. /**
  45658. * Defines the scene to instrument
  45659. */
  45660. scene: Scene;
  45661. private _captureActiveMeshesEvaluationTime;
  45662. private _activeMeshesEvaluationTime;
  45663. private _captureRenderTargetsRenderTime;
  45664. private _renderTargetsRenderTime;
  45665. private _captureFrameTime;
  45666. private _frameTime;
  45667. private _captureRenderTime;
  45668. private _renderTime;
  45669. private _captureInterFrameTime;
  45670. private _interFrameTime;
  45671. private _captureParticlesRenderTime;
  45672. private _particlesRenderTime;
  45673. private _captureSpritesRenderTime;
  45674. private _spritesRenderTime;
  45675. private _capturePhysicsTime;
  45676. private _physicsTime;
  45677. private _captureAnimationsTime;
  45678. private _animationsTime;
  45679. private _captureCameraRenderTime;
  45680. private _cameraRenderTime;
  45681. private _onBeforeActiveMeshesEvaluationObserver;
  45682. private _onAfterActiveMeshesEvaluationObserver;
  45683. private _onBeforeRenderTargetsRenderObserver;
  45684. private _onAfterRenderTargetsRenderObserver;
  45685. private _onAfterRenderObserver;
  45686. private _onBeforeDrawPhaseObserver;
  45687. private _onAfterDrawPhaseObserver;
  45688. private _onBeforeAnimationsObserver;
  45689. private _onBeforeParticlesRenderingObserver;
  45690. private _onAfterParticlesRenderingObserver;
  45691. private _onBeforeSpritesRenderingObserver;
  45692. private _onAfterSpritesRenderingObserver;
  45693. private _onBeforePhysicsObserver;
  45694. private _onAfterPhysicsObserver;
  45695. private _onAfterAnimationsObserver;
  45696. private _onBeforeCameraRenderObserver;
  45697. private _onAfterCameraRenderObserver;
  45698. /**
  45699. * Gets the perf counter used for active meshes evaluation time
  45700. */
  45701. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45702. /**
  45703. * Gets the active meshes evaluation time capture status
  45704. */
  45705. /**
  45706. * Enable or disable the active meshes evaluation time capture
  45707. */
  45708. captureActiveMeshesEvaluationTime: boolean;
  45709. /**
  45710. * Gets the perf counter used for render targets render time
  45711. */
  45712. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45713. /**
  45714. * Gets the render targets render time capture status
  45715. */
  45716. /**
  45717. * Enable or disable the render targets render time capture
  45718. */
  45719. captureRenderTargetsRenderTime: boolean;
  45720. /**
  45721. * Gets the perf counter used for particles render time
  45722. */
  45723. readonly particlesRenderTimeCounter: PerfCounter;
  45724. /**
  45725. * Gets the particles render time capture status
  45726. */
  45727. /**
  45728. * Enable or disable the particles render time capture
  45729. */
  45730. captureParticlesRenderTime: boolean;
  45731. /**
  45732. * Gets the perf counter used for sprites render time
  45733. */
  45734. readonly spritesRenderTimeCounter: PerfCounter;
  45735. /**
  45736. * Gets the sprites render time capture status
  45737. */
  45738. /**
  45739. * Enable or disable the sprites render time capture
  45740. */
  45741. captureSpritesRenderTime: boolean;
  45742. /**
  45743. * Gets the perf counter used for physics time
  45744. */
  45745. readonly physicsTimeCounter: PerfCounter;
  45746. /**
  45747. * Gets the physics time capture status
  45748. */
  45749. /**
  45750. * Enable or disable the physics time capture
  45751. */
  45752. capturePhysicsTime: boolean;
  45753. /**
  45754. * Gets the perf counter used for animations time
  45755. */
  45756. readonly animationsTimeCounter: PerfCounter;
  45757. /**
  45758. * Gets the animations time capture status
  45759. */
  45760. /**
  45761. * Enable or disable the animations time capture
  45762. */
  45763. captureAnimationsTime: boolean;
  45764. /**
  45765. * Gets the perf counter used for frame time capture
  45766. */
  45767. readonly frameTimeCounter: PerfCounter;
  45768. /**
  45769. * Gets the frame time capture status
  45770. */
  45771. /**
  45772. * Enable or disable the frame time capture
  45773. */
  45774. captureFrameTime: boolean;
  45775. /**
  45776. * Gets the perf counter used for inter-frames time capture
  45777. */
  45778. readonly interFrameTimeCounter: PerfCounter;
  45779. /**
  45780. * Gets the inter-frames time capture status
  45781. */
  45782. /**
  45783. * Enable or disable the inter-frames time capture
  45784. */
  45785. captureInterFrameTime: boolean;
  45786. /**
  45787. * Gets the perf counter used for render time capture
  45788. */
  45789. readonly renderTimeCounter: PerfCounter;
  45790. /**
  45791. * Gets the render time capture status
  45792. */
  45793. /**
  45794. * Enable or disable the render time capture
  45795. */
  45796. captureRenderTime: boolean;
  45797. /**
  45798. * Gets the perf counter used for camera render time capture
  45799. */
  45800. readonly cameraRenderTimeCounter: PerfCounter;
  45801. /**
  45802. * Gets the camera render time capture status
  45803. */
  45804. /**
  45805. * Enable or disable the camera render time capture
  45806. */
  45807. captureCameraRenderTime: boolean;
  45808. /**
  45809. * Gets the perf counter used for draw calls
  45810. */
  45811. readonly drawCallsCounter: PerfCounter;
  45812. /**
  45813. * Instantiates a new scene instrumentation.
  45814. * This class can be used to get instrumentation data from a Babylon engine
  45815. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45816. * @param scene Defines the scene to instrument
  45817. */
  45818. constructor(
  45819. /**
  45820. * Defines the scene to instrument
  45821. */
  45822. scene: Scene);
  45823. /**
  45824. * Dispose and release associated resources.
  45825. */
  45826. dispose(): void;
  45827. }
  45828. }
  45829. declare module BABYLON {
  45830. /** @hidden */
  45831. export var glowMapGenerationPixelShader: {
  45832. name: string;
  45833. shader: string;
  45834. };
  45835. }
  45836. declare module BABYLON {
  45837. /** @hidden */
  45838. export var glowMapGenerationVertexShader: {
  45839. name: string;
  45840. shader: string;
  45841. };
  45842. }
  45843. declare module BABYLON {
  45844. /**
  45845. * Effect layer options. This helps customizing the behaviour
  45846. * of the effect layer.
  45847. */
  45848. export interface IEffectLayerOptions {
  45849. /**
  45850. * Multiplication factor apply to the canvas size to compute the render target size
  45851. * used to generated the objects (the smaller the faster).
  45852. */
  45853. mainTextureRatio: number;
  45854. /**
  45855. * Enforces a fixed size texture to ensure effect stability across devices.
  45856. */
  45857. mainTextureFixedSize?: number;
  45858. /**
  45859. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45860. */
  45861. alphaBlendingMode: number;
  45862. /**
  45863. * The camera attached to the layer.
  45864. */
  45865. camera: Nullable<Camera>;
  45866. /**
  45867. * The rendering group to draw the layer in.
  45868. */
  45869. renderingGroupId: number;
  45870. }
  45871. /**
  45872. * The effect layer Helps adding post process effect blended with the main pass.
  45873. *
  45874. * This can be for instance use to generate glow or higlight effects on the scene.
  45875. *
  45876. * The effect layer class can not be used directly and is intented to inherited from to be
  45877. * customized per effects.
  45878. */
  45879. export abstract class EffectLayer {
  45880. private _vertexBuffers;
  45881. private _indexBuffer;
  45882. private _cachedDefines;
  45883. private _effectLayerMapGenerationEffect;
  45884. private _effectLayerOptions;
  45885. private _mergeEffect;
  45886. protected _scene: Scene;
  45887. protected _engine: Engine;
  45888. protected _maxSize: number;
  45889. protected _mainTextureDesiredSize: ISize;
  45890. protected _mainTexture: RenderTargetTexture;
  45891. protected _shouldRender: boolean;
  45892. protected _postProcesses: PostProcess[];
  45893. protected _textures: BaseTexture[];
  45894. protected _emissiveTextureAndColor: {
  45895. texture: Nullable<BaseTexture>;
  45896. color: Color4;
  45897. };
  45898. /**
  45899. * The name of the layer
  45900. */
  45901. name: string;
  45902. /**
  45903. * The clear color of the texture used to generate the glow map.
  45904. */
  45905. neutralColor: Color4;
  45906. /**
  45907. * Specifies wether the highlight layer is enabled or not.
  45908. */
  45909. isEnabled: boolean;
  45910. /**
  45911. * Gets the camera attached to the layer.
  45912. */
  45913. readonly camera: Nullable<Camera>;
  45914. /**
  45915. * Gets the rendering group id the layer should render in.
  45916. */
  45917. readonly renderingGroupId: number;
  45918. /**
  45919. * An event triggered when the effect layer has been disposed.
  45920. */
  45921. onDisposeObservable: Observable<EffectLayer>;
  45922. /**
  45923. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45924. */
  45925. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45926. /**
  45927. * An event triggered when the generated texture is being merged in the scene.
  45928. */
  45929. onBeforeComposeObservable: Observable<EffectLayer>;
  45930. /**
  45931. * An event triggered when the generated texture has been merged in the scene.
  45932. */
  45933. onAfterComposeObservable: Observable<EffectLayer>;
  45934. /**
  45935. * An event triggered when the efffect layer changes its size.
  45936. */
  45937. onSizeChangedObservable: Observable<EffectLayer>;
  45938. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  45939. /**
  45940. * Instantiates a new effect Layer and references it in the scene.
  45941. * @param name The name of the layer
  45942. * @param scene The scene to use the layer in
  45943. */
  45944. constructor(
  45945. /** The Friendly of the effect in the scene */
  45946. name: string, scene: Scene);
  45947. /**
  45948. * Get the effect name of the layer.
  45949. * @return The effect name
  45950. */
  45951. abstract getEffectName(): string;
  45952. /**
  45953. * Checks for the readiness of the element composing the layer.
  45954. * @param subMesh the mesh to check for
  45955. * @param useInstances specify wether or not to use instances to render the mesh
  45956. * @return true if ready otherwise, false
  45957. */
  45958. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45959. /**
  45960. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45961. * @returns true if the effect requires stencil during the main canvas render pass.
  45962. */
  45963. abstract needStencil(): boolean;
  45964. /**
  45965. * Create the merge effect. This is the shader use to blit the information back
  45966. * to the main canvas at the end of the scene rendering.
  45967. * @returns The effect containing the shader used to merge the effect on the main canvas
  45968. */
  45969. protected abstract _createMergeEffect(): Effect;
  45970. /**
  45971. * Creates the render target textures and post processes used in the effect layer.
  45972. */
  45973. protected abstract _createTextureAndPostProcesses(): void;
  45974. /**
  45975. * Implementation specific of rendering the generating effect on the main canvas.
  45976. * @param effect The effect used to render through
  45977. */
  45978. protected abstract _internalRender(effect: Effect): void;
  45979. /**
  45980. * Sets the required values for both the emissive texture and and the main color.
  45981. */
  45982. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45983. /**
  45984. * Free any resources and references associated to a mesh.
  45985. * Internal use
  45986. * @param mesh The mesh to free.
  45987. */
  45988. abstract _disposeMesh(mesh: Mesh): void;
  45989. /**
  45990. * Serializes this layer (Glow or Highlight for example)
  45991. * @returns a serialized layer object
  45992. */
  45993. abstract serialize?(): any;
  45994. /**
  45995. * Initializes the effect layer with the required options.
  45996. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45997. */
  45998. protected _init(options: Partial<IEffectLayerOptions>): void;
  45999. /**
  46000. * Generates the index buffer of the full screen quad blending to the main canvas.
  46001. */
  46002. private _generateIndexBuffer;
  46003. /**
  46004. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46005. */
  46006. private _genrateVertexBuffer;
  46007. /**
  46008. * Sets the main texture desired size which is the closest power of two
  46009. * of the engine canvas size.
  46010. */
  46011. private _setMainTextureSize;
  46012. /**
  46013. * Creates the main texture for the effect layer.
  46014. */
  46015. protected _createMainTexture(): void;
  46016. /**
  46017. * Adds specific effects defines.
  46018. * @param defines The defines to add specifics to.
  46019. */
  46020. protected _addCustomEffectDefines(defines: string[]): void;
  46021. /**
  46022. * Checks for the readiness of the element composing the layer.
  46023. * @param subMesh the mesh to check for
  46024. * @param useInstances specify wether or not to use instances to render the mesh
  46025. * @param emissiveTexture the associated emissive texture used to generate the glow
  46026. * @return true if ready otherwise, false
  46027. */
  46028. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46029. /**
  46030. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46031. */
  46032. render(): void;
  46033. /**
  46034. * Determine if a given mesh will be used in the current effect.
  46035. * @param mesh mesh to test
  46036. * @returns true if the mesh will be used
  46037. */
  46038. hasMesh(mesh: AbstractMesh): boolean;
  46039. /**
  46040. * Returns true if the layer contains information to display, otherwise false.
  46041. * @returns true if the glow layer should be rendered
  46042. */
  46043. shouldRender(): boolean;
  46044. /**
  46045. * Returns true if the mesh should render, otherwise false.
  46046. * @param mesh The mesh to render
  46047. * @returns true if it should render otherwise false
  46048. */
  46049. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46050. /**
  46051. * Returns true if the mesh can be rendered, otherwise false.
  46052. * @param mesh The mesh to render
  46053. * @param material The material used on the mesh
  46054. * @returns true if it can be rendered otherwise false
  46055. */
  46056. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46057. /**
  46058. * Returns true if the mesh should render, otherwise false.
  46059. * @param mesh The mesh to render
  46060. * @returns true if it should render otherwise false
  46061. */
  46062. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46063. /**
  46064. * Renders the submesh passed in parameter to the generation map.
  46065. */
  46066. protected _renderSubMesh(subMesh: SubMesh): void;
  46067. /**
  46068. * Rebuild the required buffers.
  46069. * @hidden Internal use only.
  46070. */ rebuild(): void;
  46071. /**
  46072. * Dispose only the render target textures and post process.
  46073. */
  46074. private _disposeTextureAndPostProcesses;
  46075. /**
  46076. * Dispose the highlight layer and free resources.
  46077. */
  46078. dispose(): void;
  46079. /**
  46080. * Gets the class name of the effect layer
  46081. * @returns the string with the class name of the effect layer
  46082. */
  46083. getClassName(): string;
  46084. /**
  46085. * Creates an effect layer from parsed effect layer data
  46086. * @param parsedEffectLayer defines effect layer data
  46087. * @param scene defines the current scene
  46088. * @param rootUrl defines the root URL containing the effect layer information
  46089. * @returns a parsed effect Layer
  46090. */
  46091. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46092. }
  46093. }
  46094. declare module BABYLON {
  46095. interface AbstractScene {
  46096. /**
  46097. * The list of effect layers (highlights/glow) added to the scene
  46098. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46099. * @see http://doc.babylonjs.com/how_to/glow_layer
  46100. */
  46101. effectLayers: Array<EffectLayer>;
  46102. /**
  46103. * Removes the given effect layer from this scene.
  46104. * @param toRemove defines the effect layer to remove
  46105. * @returns the index of the removed effect layer
  46106. */
  46107. removeEffectLayer(toRemove: EffectLayer): number;
  46108. /**
  46109. * Adds the given effect layer to this scene
  46110. * @param newEffectLayer defines the effect layer to add
  46111. */
  46112. addEffectLayer(newEffectLayer: EffectLayer): void;
  46113. }
  46114. /**
  46115. * Defines the layer scene component responsible to manage any effect layers
  46116. * in a given scene.
  46117. */
  46118. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46119. /**
  46120. * The component name helpfull to identify the component in the list of scene components.
  46121. */
  46122. readonly name: string;
  46123. /**
  46124. * The scene the component belongs to.
  46125. */
  46126. scene: Scene;
  46127. private _engine;
  46128. private _renderEffects;
  46129. private _needStencil;
  46130. private _previousStencilState;
  46131. /**
  46132. * Creates a new instance of the component for the given scene
  46133. * @param scene Defines the scene to register the component in
  46134. */
  46135. constructor(scene: Scene);
  46136. /**
  46137. * Registers the component in a given scene
  46138. */
  46139. register(): void;
  46140. /**
  46141. * Rebuilds the elements related to this component in case of
  46142. * context lost for instance.
  46143. */
  46144. rebuild(): void;
  46145. /**
  46146. * Serializes the component data to the specified json object
  46147. * @param serializationObject The object to serialize to
  46148. */
  46149. serialize(serializationObject: any): void;
  46150. /**
  46151. * Adds all the element from the container to the scene
  46152. * @param container the container holding the elements
  46153. */
  46154. addFromContainer(container: AbstractScene): void;
  46155. /**
  46156. * Removes all the elements in the container from the scene
  46157. * @param container contains the elements to remove
  46158. * @param dispose if the removed element should be disposed (default: false)
  46159. */
  46160. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46161. /**
  46162. * Disposes the component and the associated ressources.
  46163. */
  46164. dispose(): void;
  46165. private _isReadyForMesh;
  46166. private _renderMainTexture;
  46167. private _setStencil;
  46168. private _setStencilBack;
  46169. private _draw;
  46170. private _drawCamera;
  46171. private _drawRenderingGroup;
  46172. }
  46173. }
  46174. declare module BABYLON {
  46175. /** @hidden */
  46176. export var glowMapMergePixelShader: {
  46177. name: string;
  46178. shader: string;
  46179. };
  46180. }
  46181. declare module BABYLON {
  46182. /** @hidden */
  46183. export var glowMapMergeVertexShader: {
  46184. name: string;
  46185. shader: string;
  46186. };
  46187. }
  46188. declare module BABYLON {
  46189. interface AbstractScene {
  46190. /**
  46191. * Return a the first highlight layer of the scene with a given name.
  46192. * @param name The name of the highlight layer to look for.
  46193. * @return The highlight layer if found otherwise null.
  46194. */
  46195. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46196. }
  46197. /**
  46198. * Glow layer options. This helps customizing the behaviour
  46199. * of the glow layer.
  46200. */
  46201. export interface IGlowLayerOptions {
  46202. /**
  46203. * Multiplication factor apply to the canvas size to compute the render target size
  46204. * used to generated the glowing objects (the smaller the faster).
  46205. */
  46206. mainTextureRatio: number;
  46207. /**
  46208. * Enforces a fixed size texture to ensure resize independant blur.
  46209. */
  46210. mainTextureFixedSize?: number;
  46211. /**
  46212. * How big is the kernel of the blur texture.
  46213. */
  46214. blurKernelSize: number;
  46215. /**
  46216. * The camera attached to the layer.
  46217. */
  46218. camera: Nullable<Camera>;
  46219. /**
  46220. * Enable MSAA by chosing the number of samples.
  46221. */
  46222. mainTextureSamples?: number;
  46223. /**
  46224. * The rendering group to draw the layer in.
  46225. */
  46226. renderingGroupId: number;
  46227. }
  46228. /**
  46229. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46230. *
  46231. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46232. * glowy meshes to your scene.
  46233. *
  46234. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46235. */
  46236. export class GlowLayer extends EffectLayer {
  46237. /**
  46238. * Effect Name of the layer.
  46239. */
  46240. static readonly EffectName: string;
  46241. /**
  46242. * The default blur kernel size used for the glow.
  46243. */
  46244. static DefaultBlurKernelSize: number;
  46245. /**
  46246. * The default texture size ratio used for the glow.
  46247. */
  46248. static DefaultTextureRatio: number;
  46249. /**
  46250. * Sets the kernel size of the blur.
  46251. */
  46252. /**
  46253. * Gets the kernel size of the blur.
  46254. */
  46255. blurKernelSize: number;
  46256. /**
  46257. * Sets the glow intensity.
  46258. */
  46259. /**
  46260. * Gets the glow intensity.
  46261. */
  46262. intensity: number;
  46263. private _options;
  46264. private _intensity;
  46265. private _horizontalBlurPostprocess1;
  46266. private _verticalBlurPostprocess1;
  46267. private _horizontalBlurPostprocess2;
  46268. private _verticalBlurPostprocess2;
  46269. private _blurTexture1;
  46270. private _blurTexture2;
  46271. private _postProcesses1;
  46272. private _postProcesses2;
  46273. private _includedOnlyMeshes;
  46274. private _excludedMeshes;
  46275. /**
  46276. * Callback used to let the user override the color selection on a per mesh basis
  46277. */
  46278. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46279. /**
  46280. * Callback used to let the user override the texture selection on a per mesh basis
  46281. */
  46282. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46283. /**
  46284. * Instantiates a new glow Layer and references it to the scene.
  46285. * @param name The name of the layer
  46286. * @param scene The scene to use the layer in
  46287. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46288. */
  46289. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46290. /**
  46291. * Get the effect name of the layer.
  46292. * @return The effect name
  46293. */
  46294. getEffectName(): string;
  46295. /**
  46296. * Create the merge effect. This is the shader use to blit the information back
  46297. * to the main canvas at the end of the scene rendering.
  46298. */
  46299. protected _createMergeEffect(): Effect;
  46300. /**
  46301. * Creates the render target textures and post processes used in the glow layer.
  46302. */
  46303. protected _createTextureAndPostProcesses(): void;
  46304. /**
  46305. * Checks for the readiness of the element composing the layer.
  46306. * @param subMesh the mesh to check for
  46307. * @param useInstances specify wether or not to use instances to render the mesh
  46308. * @param emissiveTexture the associated emissive texture used to generate the glow
  46309. * @return true if ready otherwise, false
  46310. */
  46311. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46312. /**
  46313. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46314. */
  46315. needStencil(): boolean;
  46316. /**
  46317. * Returns true if the mesh can be rendered, otherwise false.
  46318. * @param mesh The mesh to render
  46319. * @param material The material used on the mesh
  46320. * @returns true if it can be rendered otherwise false
  46321. */
  46322. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46323. /**
  46324. * Implementation specific of rendering the generating effect on the main canvas.
  46325. * @param effect The effect used to render through
  46326. */
  46327. protected _internalRender(effect: Effect): void;
  46328. /**
  46329. * Sets the required values for both the emissive texture and and the main color.
  46330. */
  46331. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46332. /**
  46333. * Returns true if the mesh should render, otherwise false.
  46334. * @param mesh The mesh to render
  46335. * @returns true if it should render otherwise false
  46336. */
  46337. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46338. /**
  46339. * Adds specific effects defines.
  46340. * @param defines The defines to add specifics to.
  46341. */
  46342. protected _addCustomEffectDefines(defines: string[]): void;
  46343. /**
  46344. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46345. * @param mesh The mesh to exclude from the glow layer
  46346. */
  46347. addExcludedMesh(mesh: Mesh): void;
  46348. /**
  46349. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46350. * @param mesh The mesh to remove
  46351. */
  46352. removeExcludedMesh(mesh: Mesh): void;
  46353. /**
  46354. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46355. * @param mesh The mesh to include in the glow layer
  46356. */
  46357. addIncludedOnlyMesh(mesh: Mesh): void;
  46358. /**
  46359. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46360. * @param mesh The mesh to remove
  46361. */
  46362. removeIncludedOnlyMesh(mesh: Mesh): void;
  46363. /**
  46364. * Determine if a given mesh will be used in the glow layer
  46365. * @param mesh The mesh to test
  46366. * @returns true if the mesh will be highlighted by the current glow layer
  46367. */
  46368. hasMesh(mesh: AbstractMesh): boolean;
  46369. /**
  46370. * Free any resources and references associated to a mesh.
  46371. * Internal use
  46372. * @param mesh The mesh to free.
  46373. * @hidden
  46374. */ disposeMesh(mesh: Mesh): void;
  46375. /**
  46376. * Gets the class name of the effect layer
  46377. * @returns the string with the class name of the effect layer
  46378. */
  46379. getClassName(): string;
  46380. /**
  46381. * Serializes this glow layer
  46382. * @returns a serialized glow layer object
  46383. */
  46384. serialize(): any;
  46385. /**
  46386. * Creates a Glow Layer from parsed glow layer data
  46387. * @param parsedGlowLayer defines glow layer data
  46388. * @param scene defines the current scene
  46389. * @param rootUrl defines the root URL containing the glow layer information
  46390. * @returns a parsed Glow Layer
  46391. */
  46392. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46393. }
  46394. }
  46395. declare module BABYLON {
  46396. /** @hidden */
  46397. export var glowBlurPostProcessPixelShader: {
  46398. name: string;
  46399. shader: string;
  46400. };
  46401. }
  46402. declare module BABYLON {
  46403. interface AbstractScene {
  46404. /**
  46405. * Return a the first highlight layer of the scene with a given name.
  46406. * @param name The name of the highlight layer to look for.
  46407. * @return The highlight layer if found otherwise null.
  46408. */
  46409. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46410. }
  46411. /**
  46412. * Highlight layer options. This helps customizing the behaviour
  46413. * of the highlight layer.
  46414. */
  46415. export interface IHighlightLayerOptions {
  46416. /**
  46417. * Multiplication factor apply to the canvas size to compute the render target size
  46418. * used to generated the glowing objects (the smaller the faster).
  46419. */
  46420. mainTextureRatio: number;
  46421. /**
  46422. * Enforces a fixed size texture to ensure resize independant blur.
  46423. */
  46424. mainTextureFixedSize?: number;
  46425. /**
  46426. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46427. * of the picture to blur (the smaller the faster).
  46428. */
  46429. blurTextureSizeRatio: number;
  46430. /**
  46431. * How big in texel of the blur texture is the vertical blur.
  46432. */
  46433. blurVerticalSize: number;
  46434. /**
  46435. * How big in texel of the blur texture is the horizontal blur.
  46436. */
  46437. blurHorizontalSize: number;
  46438. /**
  46439. * Alpha blending mode used to apply the blur. Default is combine.
  46440. */
  46441. alphaBlendingMode: number;
  46442. /**
  46443. * The camera attached to the layer.
  46444. */
  46445. camera: Nullable<Camera>;
  46446. /**
  46447. * Should we display highlight as a solid stroke?
  46448. */
  46449. isStroke?: boolean;
  46450. /**
  46451. * The rendering group to draw the layer in.
  46452. */
  46453. renderingGroupId: number;
  46454. }
  46455. /**
  46456. * The highlight layer Helps adding a glow effect around a mesh.
  46457. *
  46458. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46459. * glowy meshes to your scene.
  46460. *
  46461. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46462. */
  46463. export class HighlightLayer extends EffectLayer {
  46464. name: string;
  46465. /**
  46466. * Effect Name of the highlight layer.
  46467. */
  46468. static readonly EffectName: string;
  46469. /**
  46470. * The neutral color used during the preparation of the glow effect.
  46471. * This is black by default as the blend operation is a blend operation.
  46472. */
  46473. static NeutralColor: Color4;
  46474. /**
  46475. * Stencil value used for glowing meshes.
  46476. */
  46477. static GlowingMeshStencilReference: number;
  46478. /**
  46479. * Stencil value used for the other meshes in the scene.
  46480. */
  46481. static NormalMeshStencilReference: number;
  46482. /**
  46483. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46484. */
  46485. innerGlow: boolean;
  46486. /**
  46487. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46488. */
  46489. outerGlow: boolean;
  46490. /**
  46491. * Specifies the horizontal size of the blur.
  46492. */
  46493. /**
  46494. * Gets the horizontal size of the blur.
  46495. */
  46496. blurHorizontalSize: number;
  46497. /**
  46498. * Specifies the vertical size of the blur.
  46499. */
  46500. /**
  46501. * Gets the vertical size of the blur.
  46502. */
  46503. blurVerticalSize: number;
  46504. /**
  46505. * An event triggered when the highlight layer is being blurred.
  46506. */
  46507. onBeforeBlurObservable: Observable<HighlightLayer>;
  46508. /**
  46509. * An event triggered when the highlight layer has been blurred.
  46510. */
  46511. onAfterBlurObservable: Observable<HighlightLayer>;
  46512. private _instanceGlowingMeshStencilReference;
  46513. private _options;
  46514. private _downSamplePostprocess;
  46515. private _horizontalBlurPostprocess;
  46516. private _verticalBlurPostprocess;
  46517. private _blurTexture;
  46518. private _meshes;
  46519. private _excludedMeshes;
  46520. /**
  46521. * Instantiates a new highlight Layer and references it to the scene..
  46522. * @param name The name of the layer
  46523. * @param scene The scene to use the layer in
  46524. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46525. */
  46526. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46527. /**
  46528. * Get the effect name of the layer.
  46529. * @return The effect name
  46530. */
  46531. getEffectName(): string;
  46532. /**
  46533. * Create the merge effect. This is the shader use to blit the information back
  46534. * to the main canvas at the end of the scene rendering.
  46535. */
  46536. protected _createMergeEffect(): Effect;
  46537. /**
  46538. * Creates the render target textures and post processes used in the highlight layer.
  46539. */
  46540. protected _createTextureAndPostProcesses(): void;
  46541. /**
  46542. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46543. */
  46544. needStencil(): boolean;
  46545. /**
  46546. * Checks for the readiness of the element composing the layer.
  46547. * @param subMesh the mesh to check for
  46548. * @param useInstances specify wether or not to use instances to render the mesh
  46549. * @param emissiveTexture the associated emissive texture used to generate the glow
  46550. * @return true if ready otherwise, false
  46551. */
  46552. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46553. /**
  46554. * Implementation specific of rendering the generating effect on the main canvas.
  46555. * @param effect The effect used to render through
  46556. */
  46557. protected _internalRender(effect: Effect): void;
  46558. /**
  46559. * Returns true if the layer contains information to display, otherwise false.
  46560. */
  46561. shouldRender(): boolean;
  46562. /**
  46563. * Returns true if the mesh should render, otherwise false.
  46564. * @param mesh The mesh to render
  46565. * @returns true if it should render otherwise false
  46566. */
  46567. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46568. /**
  46569. * Sets the required values for both the emissive texture and and the main color.
  46570. */
  46571. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46572. /**
  46573. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46574. * @param mesh The mesh to exclude from the highlight layer
  46575. */
  46576. addExcludedMesh(mesh: Mesh): void;
  46577. /**
  46578. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46579. * @param mesh The mesh to highlight
  46580. */
  46581. removeExcludedMesh(mesh: Mesh): void;
  46582. /**
  46583. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46584. * @param mesh mesh to test
  46585. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46586. */
  46587. hasMesh(mesh: AbstractMesh): boolean;
  46588. /**
  46589. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46590. * @param mesh The mesh to highlight
  46591. * @param color The color of the highlight
  46592. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46593. */
  46594. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46595. /**
  46596. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46597. * @param mesh The mesh to highlight
  46598. */
  46599. removeMesh(mesh: Mesh): void;
  46600. /**
  46601. * Force the stencil to the normal expected value for none glowing parts
  46602. */
  46603. private _defaultStencilReference;
  46604. /**
  46605. * Free any resources and references associated to a mesh.
  46606. * Internal use
  46607. * @param mesh The mesh to free.
  46608. * @hidden
  46609. */ disposeMesh(mesh: Mesh): void;
  46610. /**
  46611. * Dispose the highlight layer and free resources.
  46612. */
  46613. dispose(): void;
  46614. /**
  46615. * Gets the class name of the effect layer
  46616. * @returns the string with the class name of the effect layer
  46617. */
  46618. getClassName(): string;
  46619. /**
  46620. * Serializes this Highlight layer
  46621. * @returns a serialized Highlight layer object
  46622. */
  46623. serialize(): any;
  46624. /**
  46625. * Creates a Highlight layer from parsed Highlight layer data
  46626. * @param parsedHightlightLayer defines the Highlight layer data
  46627. * @param scene defines the current scene
  46628. * @param rootUrl defines the root URL containing the Highlight layer information
  46629. * @returns a parsed Highlight layer
  46630. */
  46631. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46632. }
  46633. }
  46634. declare module BABYLON {
  46635. /** @hidden */
  46636. export var lensFlarePixelShader: {
  46637. name: string;
  46638. shader: string;
  46639. };
  46640. }
  46641. declare module BABYLON {
  46642. /** @hidden */
  46643. export var lensFlareVertexShader: {
  46644. name: string;
  46645. shader: string;
  46646. };
  46647. }
  46648. declare module BABYLON {
  46649. /**
  46650. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46651. * It is usually composed of several `lensFlare`.
  46652. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46653. */
  46654. export class LensFlareSystem {
  46655. /**
  46656. * Define the name of the lens flare system
  46657. */
  46658. name: string;
  46659. /**
  46660. * List of lens flares used in this system.
  46661. */
  46662. lensFlares: LensFlare[];
  46663. /**
  46664. * Define a limit from the border the lens flare can be visible.
  46665. */
  46666. borderLimit: number;
  46667. /**
  46668. * Define a viewport border we do not want to see the lens flare in.
  46669. */
  46670. viewportBorder: number;
  46671. /**
  46672. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46673. */
  46674. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46675. /**
  46676. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46677. */
  46678. layerMask: number;
  46679. /**
  46680. * Define the id of the lens flare system in the scene.
  46681. * (equal to name by default)
  46682. */
  46683. id: string;
  46684. private _scene;
  46685. private _emitter;
  46686. private _vertexBuffers;
  46687. private _indexBuffer;
  46688. private _effect;
  46689. private _positionX;
  46690. private _positionY;
  46691. private _isEnabled;
  46692. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46693. /**
  46694. * Instantiates a lens flare system.
  46695. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46696. * It is usually composed of several `lensFlare`.
  46697. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46698. * @param name Define the name of the lens flare system in the scene
  46699. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46700. * @param scene Define the scene the lens flare system belongs to
  46701. */
  46702. constructor(
  46703. /**
  46704. * Define the name of the lens flare system
  46705. */
  46706. name: string, emitter: any, scene: Scene);
  46707. /**
  46708. * Define if the lens flare system is enabled.
  46709. */
  46710. isEnabled: boolean;
  46711. /**
  46712. * Get the scene the effects belongs to.
  46713. * @returns the scene holding the lens flare system
  46714. */
  46715. getScene(): Scene;
  46716. /**
  46717. * Get the emitter of the lens flare system.
  46718. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46719. * @returns the emitter of the lens flare system
  46720. */
  46721. getEmitter(): any;
  46722. /**
  46723. * Set the emitter of the lens flare system.
  46724. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46725. * @param newEmitter Define the new emitter of the system
  46726. */
  46727. setEmitter(newEmitter: any): void;
  46728. /**
  46729. * Get the lens flare system emitter position.
  46730. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46731. * @returns the position
  46732. */
  46733. getEmitterPosition(): Vector3;
  46734. /**
  46735. * @hidden
  46736. */
  46737. computeEffectivePosition(globalViewport: Viewport): boolean;
  46738. /** @hidden */ isVisible(): boolean;
  46739. /**
  46740. * @hidden
  46741. */
  46742. render(): boolean;
  46743. /**
  46744. * Dispose and release the lens flare with its associated resources.
  46745. */
  46746. dispose(): void;
  46747. /**
  46748. * Parse a lens flare system from a JSON repressentation
  46749. * @param parsedLensFlareSystem Define the JSON to parse
  46750. * @param scene Define the scene the parsed system should be instantiated in
  46751. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46752. * @returns the parsed system
  46753. */
  46754. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46755. /**
  46756. * Serialize the current Lens Flare System into a JSON representation.
  46757. * @returns the serialized JSON
  46758. */
  46759. serialize(): any;
  46760. }
  46761. }
  46762. declare module BABYLON {
  46763. /**
  46764. * This represents one of the lens effect in a `lensFlareSystem`.
  46765. * It controls one of the indiviual texture used in the effect.
  46766. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46767. */
  46768. export class LensFlare {
  46769. /**
  46770. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46771. */
  46772. size: number;
  46773. /**
  46774. * 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.
  46775. */
  46776. position: number;
  46777. /**
  46778. * Define the lens color.
  46779. */
  46780. color: Color3;
  46781. /**
  46782. * Define the lens texture.
  46783. */
  46784. texture: Nullable<Texture>;
  46785. /**
  46786. * Define the alpha mode to render this particular lens.
  46787. */
  46788. alphaMode: number;
  46789. private _system;
  46790. /**
  46791. * Creates a new Lens Flare.
  46792. * This represents one of the lens effect in a `lensFlareSystem`.
  46793. * It controls one of the indiviual texture used in the effect.
  46794. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46795. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46796. * @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.
  46797. * @param color Define the lens color
  46798. * @param imgUrl Define the lens texture url
  46799. * @param system Define the `lensFlareSystem` this flare is part of
  46800. * @returns The newly created Lens Flare
  46801. */
  46802. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46803. /**
  46804. * Instantiates a new Lens Flare.
  46805. * This represents one of the lens effect in a `lensFlareSystem`.
  46806. * It controls one of the indiviual texture used in the effect.
  46807. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46808. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46809. * @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.
  46810. * @param color Define the lens color
  46811. * @param imgUrl Define the lens texture url
  46812. * @param system Define the `lensFlareSystem` this flare is part of
  46813. */
  46814. constructor(
  46815. /**
  46816. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46817. */
  46818. size: number,
  46819. /**
  46820. * 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.
  46821. */
  46822. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46823. /**
  46824. * Dispose and release the lens flare with its associated resources.
  46825. */
  46826. dispose(): void;
  46827. }
  46828. }
  46829. declare module BABYLON {
  46830. interface AbstractScene {
  46831. /**
  46832. * The list of lens flare system added to the scene
  46833. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46834. */
  46835. lensFlareSystems: Array<LensFlareSystem>;
  46836. /**
  46837. * Removes the given lens flare system from this scene.
  46838. * @param toRemove The lens flare system to remove
  46839. * @returns The index of the removed lens flare system
  46840. */
  46841. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46842. /**
  46843. * Adds the given lens flare system to this scene
  46844. * @param newLensFlareSystem The lens flare system to add
  46845. */
  46846. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46847. /**
  46848. * Gets a lens flare system using its name
  46849. * @param name defines the name to look for
  46850. * @returns the lens flare system or null if not found
  46851. */
  46852. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46853. /**
  46854. * Gets a lens flare system using its id
  46855. * @param id defines the id to look for
  46856. * @returns the lens flare system or null if not found
  46857. */
  46858. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46859. }
  46860. /**
  46861. * Defines the lens flare scene component responsible to manage any lens flares
  46862. * in a given scene.
  46863. */
  46864. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46865. /**
  46866. * The component name helpfull to identify the component in the list of scene components.
  46867. */
  46868. readonly name: string;
  46869. /**
  46870. * The scene the component belongs to.
  46871. */
  46872. scene: Scene;
  46873. /**
  46874. * Creates a new instance of the component for the given scene
  46875. * @param scene Defines the scene to register the component in
  46876. */
  46877. constructor(scene: Scene);
  46878. /**
  46879. * Registers the component in a given scene
  46880. */
  46881. register(): void;
  46882. /**
  46883. * Rebuilds the elements related to this component in case of
  46884. * context lost for instance.
  46885. */
  46886. rebuild(): void;
  46887. /**
  46888. * Adds all the element from the container to the scene
  46889. * @param container the container holding the elements
  46890. */
  46891. addFromContainer(container: AbstractScene): void;
  46892. /**
  46893. * Removes all the elements in the container from the scene
  46894. * @param container contains the elements to remove
  46895. * @param dispose if the removed element should be disposed (default: false)
  46896. */
  46897. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46898. /**
  46899. * Serializes the component data to the specified json object
  46900. * @param serializationObject The object to serialize to
  46901. */
  46902. serialize(serializationObject: any): void;
  46903. /**
  46904. * Disposes the component and the associated ressources.
  46905. */
  46906. dispose(): void;
  46907. private _draw;
  46908. }
  46909. }
  46910. declare module BABYLON {
  46911. /**
  46912. * Defines the shadow generator component responsible to manage any shadow generators
  46913. * in a given scene.
  46914. */
  46915. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46916. /**
  46917. * The component name helpfull to identify the component in the list of scene components.
  46918. */
  46919. readonly name: string;
  46920. /**
  46921. * The scene the component belongs to.
  46922. */
  46923. scene: Scene;
  46924. /**
  46925. * Creates a new instance of the component for the given scene
  46926. * @param scene Defines the scene to register the component in
  46927. */
  46928. constructor(scene: Scene);
  46929. /**
  46930. * Registers the component in a given scene
  46931. */
  46932. register(): void;
  46933. /**
  46934. * Rebuilds the elements related to this component in case of
  46935. * context lost for instance.
  46936. */
  46937. rebuild(): void;
  46938. /**
  46939. * Serializes the component data to the specified json object
  46940. * @param serializationObject The object to serialize to
  46941. */
  46942. serialize(serializationObject: any): void;
  46943. /**
  46944. * Adds all the element from the container to the scene
  46945. * @param container the container holding the elements
  46946. */
  46947. addFromContainer(container: AbstractScene): void;
  46948. /**
  46949. * Removes all the elements in the container from the scene
  46950. * @param container contains the elements to remove
  46951. * @param dispose if the removed element should be disposed (default: false)
  46952. */
  46953. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46954. /**
  46955. * Rebuilds the elements related to this component in case of
  46956. * context lost for instance.
  46957. */
  46958. dispose(): void;
  46959. private _gatherRenderTargets;
  46960. }
  46961. }
  46962. declare module BABYLON {
  46963. /**
  46964. * A point light is a light defined by an unique point in world space.
  46965. * The light is emitted in every direction from this point.
  46966. * A good example of a point light is a standard light bulb.
  46967. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46968. */
  46969. export class PointLight extends ShadowLight {
  46970. private _shadowAngle;
  46971. /**
  46972. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46973. * This specifies what angle the shadow will use to be created.
  46974. *
  46975. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46976. */
  46977. /**
  46978. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46979. * This specifies what angle the shadow will use to be created.
  46980. *
  46981. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46982. */
  46983. shadowAngle: number;
  46984. /**
  46985. * Gets the direction if it has been set.
  46986. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46987. */
  46988. /**
  46989. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46990. */
  46991. direction: Vector3;
  46992. /**
  46993. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46994. * A PointLight emits the light in every direction.
  46995. * It can cast shadows.
  46996. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46997. * ```javascript
  46998. * var pointLight = new PointLight("pl", camera.position, scene);
  46999. * ```
  47000. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47001. * @param name The light friendly name
  47002. * @param position The position of the point light in the scene
  47003. * @param scene The scene the lights belongs to
  47004. */
  47005. constructor(name: string, position: Vector3, scene: Scene);
  47006. /**
  47007. * Returns the string "PointLight"
  47008. * @returns the class name
  47009. */
  47010. getClassName(): string;
  47011. /**
  47012. * Returns the integer 0.
  47013. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47014. */
  47015. getTypeID(): number;
  47016. /**
  47017. * Specifies wether or not the shadowmap should be a cube texture.
  47018. * @returns true if the shadowmap needs to be a cube texture.
  47019. */
  47020. needCube(): boolean;
  47021. /**
  47022. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47023. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47024. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47025. */
  47026. getShadowDirection(faceIndex?: number): Vector3;
  47027. /**
  47028. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47029. * - fov = PI / 2
  47030. * - aspect ratio : 1.0
  47031. * - z-near and far equal to the active camera minZ and maxZ.
  47032. * Returns the PointLight.
  47033. */
  47034. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47035. protected _buildUniformLayout(): void;
  47036. /**
  47037. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47038. * @param effect The effect to update
  47039. * @param lightIndex The index of the light in the effect to update
  47040. * @returns The point light
  47041. */
  47042. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47043. /**
  47044. * Prepares the list of defines specific to the light type.
  47045. * @param defines the list of defines
  47046. * @param lightIndex defines the index of the light for the effect
  47047. */
  47048. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47049. }
  47050. }
  47051. declare module BABYLON {
  47052. /**
  47053. * Header information of HDR texture files.
  47054. */
  47055. export interface HDRInfo {
  47056. /**
  47057. * The height of the texture in pixels.
  47058. */
  47059. height: number;
  47060. /**
  47061. * The width of the texture in pixels.
  47062. */
  47063. width: number;
  47064. /**
  47065. * The index of the beginning of the data in the binary file.
  47066. */
  47067. dataPosition: number;
  47068. }
  47069. /**
  47070. * This groups tools to convert HDR texture to native colors array.
  47071. */
  47072. export class HDRTools {
  47073. private static Ldexp;
  47074. private static Rgbe2float;
  47075. private static readStringLine;
  47076. /**
  47077. * Reads header information from an RGBE texture stored in a native array.
  47078. * More information on this format are available here:
  47079. * https://en.wikipedia.org/wiki/RGBE_image_format
  47080. *
  47081. * @param uint8array The binary file stored in native array.
  47082. * @return The header information.
  47083. */
  47084. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47085. /**
  47086. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47087. * This RGBE texture needs to store the information as a panorama.
  47088. *
  47089. * More information on this format are available here:
  47090. * https://en.wikipedia.org/wiki/RGBE_image_format
  47091. *
  47092. * @param buffer The binary file stored in an array buffer.
  47093. * @param size The expected size of the extracted cubemap.
  47094. * @return The Cube Map information.
  47095. */
  47096. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47097. /**
  47098. * Returns the pixels data extracted from an RGBE texture.
  47099. * This pixels will be stored left to right up to down in the R G B order in one array.
  47100. *
  47101. * More information on this format are available here:
  47102. * https://en.wikipedia.org/wiki/RGBE_image_format
  47103. *
  47104. * @param uint8array The binary file stored in an array buffer.
  47105. * @param hdrInfo The header information of the file.
  47106. * @return The pixels data in RGB right to left up to down order.
  47107. */
  47108. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47109. private static RGBE_ReadPixels_RLE;
  47110. }
  47111. }
  47112. declare module BABYLON {
  47113. /**
  47114. * This represents a texture coming from an HDR input.
  47115. *
  47116. * The only supported format is currently panorama picture stored in RGBE format.
  47117. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47118. */
  47119. export class HDRCubeTexture extends BaseTexture {
  47120. private static _facesMapping;
  47121. private _generateHarmonics;
  47122. private _noMipmap;
  47123. private _textureMatrix;
  47124. private _size;
  47125. private _onLoad;
  47126. private _onError;
  47127. /**
  47128. * The texture URL.
  47129. */
  47130. url: string;
  47131. /**
  47132. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47133. */
  47134. coordinatesMode: number;
  47135. protected _isBlocking: boolean;
  47136. /**
  47137. * Sets wether or not the texture is blocking during loading.
  47138. */
  47139. /**
  47140. * Gets wether or not the texture is blocking during loading.
  47141. */
  47142. isBlocking: boolean;
  47143. protected _rotationY: number;
  47144. /**
  47145. * Sets texture matrix rotation angle around Y axis in radians.
  47146. */
  47147. /**
  47148. * Gets texture matrix rotation angle around Y axis radians.
  47149. */
  47150. rotationY: number;
  47151. /**
  47152. * Gets or sets the center of the bounding box associated with the cube texture
  47153. * It must define where the camera used to render the texture was set
  47154. */
  47155. boundingBoxPosition: Vector3;
  47156. private _boundingBoxSize;
  47157. /**
  47158. * Gets or sets the size of the bounding box associated with the cube texture
  47159. * When defined, the cubemap will switch to local mode
  47160. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47161. * @example https://www.babylonjs-playground.com/#RNASML
  47162. */
  47163. boundingBoxSize: Vector3;
  47164. /**
  47165. * Instantiates an HDRTexture from the following parameters.
  47166. *
  47167. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47168. * @param scene The scene the texture will be used in
  47169. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47170. * @param noMipmap Forces to not generate the mipmap if true
  47171. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47172. * @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)
  47173. * @param reserved Reserved flag for internal use.
  47174. */
  47175. 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>);
  47176. /**
  47177. * Get the current class name of the texture useful for serialization or dynamic coding.
  47178. * @returns "HDRCubeTexture"
  47179. */
  47180. getClassName(): string;
  47181. /**
  47182. * Occurs when the file is raw .hdr file.
  47183. */
  47184. private loadTexture;
  47185. clone(): HDRCubeTexture;
  47186. delayLoad(): void;
  47187. /**
  47188. * Get the texture reflection matrix used to rotate/transform the reflection.
  47189. * @returns the reflection matrix
  47190. */
  47191. getReflectionTextureMatrix(): Matrix;
  47192. /**
  47193. * Set the texture reflection matrix used to rotate/transform the reflection.
  47194. * @param value Define the reflection matrix to set
  47195. */
  47196. setReflectionTextureMatrix(value: Matrix): void;
  47197. /**
  47198. * Parses a JSON representation of an HDR Texture in order to create the texture
  47199. * @param parsedTexture Define the JSON representation
  47200. * @param scene Define the scene the texture should be created in
  47201. * @param rootUrl Define the root url in case we need to load relative dependencies
  47202. * @returns the newly created texture after parsing
  47203. */
  47204. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47205. serialize(): any;
  47206. }
  47207. }
  47208. declare module BABYLON {
  47209. /**
  47210. * Class used to control physics engine
  47211. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47212. */
  47213. export class PhysicsEngine implements IPhysicsEngine {
  47214. private _physicsPlugin;
  47215. /**
  47216. * Global value used to control the smallest number supported by the simulation
  47217. */
  47218. static Epsilon: number;
  47219. private _impostors;
  47220. private _joints;
  47221. /**
  47222. * Gets the gravity vector used by the simulation
  47223. */
  47224. gravity: Vector3;
  47225. /**
  47226. * Factory used to create the default physics plugin.
  47227. * @returns The default physics plugin
  47228. */
  47229. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47230. /**
  47231. * Creates a new Physics Engine
  47232. * @param gravity defines the gravity vector used by the simulation
  47233. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47234. */
  47235. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47236. /**
  47237. * Sets the gravity vector used by the simulation
  47238. * @param gravity defines the gravity vector to use
  47239. */
  47240. setGravity(gravity: Vector3): void;
  47241. /**
  47242. * Set the time step of the physics engine.
  47243. * Default is 1/60.
  47244. * To slow it down, enter 1/600 for example.
  47245. * To speed it up, 1/30
  47246. * @param newTimeStep defines the new timestep to apply to this world.
  47247. */
  47248. setTimeStep(newTimeStep?: number): void;
  47249. /**
  47250. * Get the time step of the physics engine.
  47251. * @returns the current time step
  47252. */
  47253. getTimeStep(): number;
  47254. /**
  47255. * Release all resources
  47256. */
  47257. dispose(): void;
  47258. /**
  47259. * Gets the name of the current physics plugin
  47260. * @returns the name of the plugin
  47261. */
  47262. getPhysicsPluginName(): string;
  47263. /**
  47264. * Adding a new impostor for the impostor tracking.
  47265. * This will be done by the impostor itself.
  47266. * @param impostor the impostor to add
  47267. */
  47268. addImpostor(impostor: PhysicsImpostor): void;
  47269. /**
  47270. * Remove an impostor from the engine.
  47271. * This impostor and its mesh will not longer be updated by the physics engine.
  47272. * @param impostor the impostor to remove
  47273. */
  47274. removeImpostor(impostor: PhysicsImpostor): void;
  47275. /**
  47276. * Add a joint to the physics engine
  47277. * @param mainImpostor defines the main impostor to which the joint is added.
  47278. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47279. * @param joint defines the joint that will connect both impostors.
  47280. */
  47281. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47282. /**
  47283. * Removes a joint from the simulation
  47284. * @param mainImpostor defines the impostor used with the joint
  47285. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47286. * @param joint defines the joint to remove
  47287. */
  47288. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47289. /**
  47290. * Called by the scene. No need to call it.
  47291. * @param delta defines the timespam between frames
  47292. */ step(delta: number): void;
  47293. /**
  47294. * Gets the current plugin used to run the simulation
  47295. * @returns current plugin
  47296. */
  47297. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47298. /**
  47299. * Gets the list of physic impostors
  47300. * @returns an array of PhysicsImpostor
  47301. */
  47302. getImpostors(): Array<PhysicsImpostor>;
  47303. /**
  47304. * Gets the impostor for a physics enabled object
  47305. * @param object defines the object impersonated by the impostor
  47306. * @returns the PhysicsImpostor or null if not found
  47307. */
  47308. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47309. /**
  47310. * Gets the impostor for a physics body object
  47311. * @param body defines physics body used by the impostor
  47312. * @returns the PhysicsImpostor or null if not found
  47313. */
  47314. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47315. /**
  47316. * Does a raycast in the physics world
  47317. * @param from when should the ray start?
  47318. * @param to when should the ray end?
  47319. * @returns PhysicsRaycastResult
  47320. */
  47321. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47322. }
  47323. }
  47324. declare module BABYLON {
  47325. /** @hidden */
  47326. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47327. private _useDeltaForWorldStep;
  47328. world: any;
  47329. name: string;
  47330. private _physicsMaterials;
  47331. private _fixedTimeStep;
  47332. private _cannonRaycastResult;
  47333. private _raycastResult;
  47334. private _removeAfterStep;
  47335. BJSCANNON: any;
  47336. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47337. setGravity(gravity: Vector3): void;
  47338. setTimeStep(timeStep: number): void;
  47339. getTimeStep(): number;
  47340. executeStep(delta: number): void;
  47341. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47342. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47343. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47344. private _processChildMeshes;
  47345. removePhysicsBody(impostor: PhysicsImpostor): void;
  47346. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47347. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47348. private _addMaterial;
  47349. private _checkWithEpsilon;
  47350. private _createShape;
  47351. private _createHeightmap;
  47352. private _minus90X;
  47353. private _plus90X;
  47354. private _tmpPosition;
  47355. private _tmpDeltaPosition;
  47356. private _tmpUnityRotation;
  47357. private _updatePhysicsBodyTransformation;
  47358. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47359. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47360. isSupported(): boolean;
  47361. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47362. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47363. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47364. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47365. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47366. getBodyMass(impostor: PhysicsImpostor): number;
  47367. getBodyFriction(impostor: PhysicsImpostor): number;
  47368. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47369. getBodyRestitution(impostor: PhysicsImpostor): number;
  47370. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47371. sleepBody(impostor: PhysicsImpostor): void;
  47372. wakeUpBody(impostor: PhysicsImpostor): void;
  47373. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47374. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47375. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47376. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47377. getRadius(impostor: PhysicsImpostor): number;
  47378. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47379. dispose(): void;
  47380. private _extendNamespace;
  47381. /**
  47382. * Does a raycast in the physics world
  47383. * @param from when should the ray start?
  47384. * @param to when should the ray end?
  47385. * @returns PhysicsRaycastResult
  47386. */
  47387. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47388. }
  47389. }
  47390. declare module BABYLON {
  47391. /** @hidden */
  47392. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47393. world: any;
  47394. name: string;
  47395. BJSOIMO: any;
  47396. private _raycastResult;
  47397. constructor(iterations?: number, oimoInjection?: any);
  47398. setGravity(gravity: Vector3): void;
  47399. setTimeStep(timeStep: number): void;
  47400. getTimeStep(): number;
  47401. private _tmpImpostorsArray;
  47402. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47403. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47404. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47405. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47406. private _tmpPositionVector;
  47407. removePhysicsBody(impostor: PhysicsImpostor): void;
  47408. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47409. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47410. isSupported(): boolean;
  47411. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47412. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47413. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47414. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47415. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47416. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47417. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47418. getBodyMass(impostor: PhysicsImpostor): number;
  47419. getBodyFriction(impostor: PhysicsImpostor): number;
  47420. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47421. getBodyRestitution(impostor: PhysicsImpostor): number;
  47422. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47423. sleepBody(impostor: PhysicsImpostor): void;
  47424. wakeUpBody(impostor: PhysicsImpostor): void;
  47425. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47426. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47427. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47428. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47429. getRadius(impostor: PhysicsImpostor): number;
  47430. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47431. dispose(): void;
  47432. /**
  47433. * Does a raycast in the physics world
  47434. * @param from when should the ray start?
  47435. * @param to when should the ray end?
  47436. * @returns PhysicsRaycastResult
  47437. */
  47438. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47439. }
  47440. }
  47441. declare module BABYLON {
  47442. /**
  47443. * Class containing static functions to help procedurally build meshes
  47444. */
  47445. export class RibbonBuilder {
  47446. /**
  47447. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47448. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47449. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47450. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47451. * * 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
  47452. * * 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
  47453. * * 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
  47454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47455. * * 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
  47456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47457. * * 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
  47458. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47459. * * 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
  47460. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47462. * @param name defines the name of the mesh
  47463. * @param options defines the options used to create the mesh
  47464. * @param scene defines the hosting scene
  47465. * @returns the ribbon mesh
  47466. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47467. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47468. */
  47469. static CreateRibbon(name: string, options: {
  47470. pathArray: Vector3[][];
  47471. closeArray?: boolean;
  47472. closePath?: boolean;
  47473. offset?: number;
  47474. updatable?: boolean;
  47475. sideOrientation?: number;
  47476. frontUVs?: Vector4;
  47477. backUVs?: Vector4;
  47478. instance?: Mesh;
  47479. invertUV?: boolean;
  47480. uvs?: Vector2[];
  47481. colors?: Color4[];
  47482. }, scene?: Nullable<Scene>): Mesh;
  47483. }
  47484. }
  47485. declare module BABYLON {
  47486. /**
  47487. * Class containing static functions to help procedurally build meshes
  47488. */
  47489. export class ShapeBuilder {
  47490. /**
  47491. * 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.
  47492. * * 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.
  47493. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47494. * * 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.
  47495. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47496. * * 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
  47497. * * 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
  47498. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47500. * * 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
  47501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47503. * @param name defines the name of the mesh
  47504. * @param options defines the options used to create the mesh
  47505. * @param scene defines the hosting scene
  47506. * @returns the extruded shape mesh
  47507. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47509. */
  47510. static ExtrudeShape(name: string, options: {
  47511. shape: Vector3[];
  47512. path: Vector3[];
  47513. scale?: number;
  47514. rotation?: number;
  47515. cap?: number;
  47516. updatable?: boolean;
  47517. sideOrientation?: number;
  47518. frontUVs?: Vector4;
  47519. backUVs?: Vector4;
  47520. instance?: Mesh;
  47521. invertUV?: boolean;
  47522. }, scene?: Nullable<Scene>): Mesh;
  47523. /**
  47524. * Creates an custom extruded shape mesh.
  47525. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47526. * * 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.
  47527. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47528. * * 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
  47529. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47530. * * 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
  47531. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47532. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47533. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47534. * * 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
  47535. * * 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
  47536. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47538. * * 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
  47539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47541. * @param name defines the name of the mesh
  47542. * @param options defines the options used to create the mesh
  47543. * @param scene defines the hosting scene
  47544. * @returns the custom extruded shape mesh
  47545. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47546. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47547. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47548. */
  47549. static ExtrudeShapeCustom(name: string, options: {
  47550. shape: Vector3[];
  47551. path: Vector3[];
  47552. scaleFunction?: any;
  47553. rotationFunction?: any;
  47554. ribbonCloseArray?: boolean;
  47555. ribbonClosePath?: boolean;
  47556. cap?: number;
  47557. updatable?: boolean;
  47558. sideOrientation?: number;
  47559. frontUVs?: Vector4;
  47560. backUVs?: Vector4;
  47561. instance?: Mesh;
  47562. invertUV?: boolean;
  47563. }, scene?: Nullable<Scene>): Mesh;
  47564. private static _ExtrudeShapeGeneric;
  47565. }
  47566. }
  47567. declare module BABYLON {
  47568. /**
  47569. * AmmoJS Physics plugin
  47570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  47571. * @see https://github.com/kripken/ammo.js/
  47572. */
  47573. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  47574. private _useDeltaForWorldStep;
  47575. /**
  47576. * Reference to the Ammo library
  47577. */
  47578. bjsAMMO: any;
  47579. /**
  47580. * Created ammoJS world which physics bodies are added to
  47581. */
  47582. world: any;
  47583. /**
  47584. * Name of the plugin
  47585. */
  47586. name: string;
  47587. private _timeStep;
  47588. private _fixedTimeStep;
  47589. private _maxSteps;
  47590. private _tmpQuaternion;
  47591. private _tmpAmmoTransform;
  47592. private _tmpAmmoQuaternion;
  47593. private _tmpAmmoConcreteContactResultCallback;
  47594. private _collisionConfiguration;
  47595. private _dispatcher;
  47596. private _overlappingPairCache;
  47597. private _solver;
  47598. private _softBodySolver;
  47599. private _tmpAmmoVectorA;
  47600. private _tmpAmmoVectorB;
  47601. private _tmpAmmoVectorC;
  47602. private _tmpAmmoVectorD;
  47603. private _tmpContactCallbackResult;
  47604. private _tmpAmmoVectorRCA;
  47605. private _tmpAmmoVectorRCB;
  47606. private _raycastResult;
  47607. private static readonly DISABLE_COLLISION_FLAG;
  47608. private static readonly KINEMATIC_FLAG;
  47609. private static readonly DISABLE_DEACTIVATION_FLAG;
  47610. /**
  47611. * Initializes the ammoJS plugin
  47612. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  47613. * @param ammoInjection can be used to inject your own ammo reference
  47614. */
  47615. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  47616. /**
  47617. * Sets the gravity of the physics world (m/(s^2))
  47618. * @param gravity Gravity to set
  47619. */
  47620. setGravity(gravity: Vector3): void;
  47621. /**
  47622. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  47623. * @param timeStep timestep to use in seconds
  47624. */
  47625. setTimeStep(timeStep: number): void;
  47626. /**
  47627. * 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)
  47628. * @param fixedTimeStep fixedTimeStep to use in seconds
  47629. */
  47630. setFixedTimeStep(fixedTimeStep: number): void;
  47631. /**
  47632. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  47633. * @param maxSteps the maximum number of steps by the physics engine per frame
  47634. */
  47635. setMaxSteps(maxSteps: number): void;
  47636. /**
  47637. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  47638. * @returns the current timestep in seconds
  47639. */
  47640. getTimeStep(): number;
  47641. private _isImpostorInContact;
  47642. private _isImpostorPairInContact;
  47643. private _stepSimulation;
  47644. /**
  47645. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  47646. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  47647. * After the step the babylon meshes are set to the position of the physics imposters
  47648. * @param delta amount of time to step forward
  47649. * @param impostors array of imposters to update before/after the step
  47650. */
  47651. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47652. /**
  47653. * Update babylon mesh to match physics world object
  47654. * @param impostor imposter to match
  47655. */
  47656. private _afterSoftStep;
  47657. /**
  47658. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47659. * @param impostor imposter to match
  47660. */
  47661. private _ropeStep;
  47662. /**
  47663. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47664. * @param impostor imposter to match
  47665. */
  47666. private _softbodyOrClothStep;
  47667. private _tmpVector;
  47668. private _tmpMatrix;
  47669. /**
  47670. * Applies an impulse on the imposter
  47671. * @param impostor imposter to apply impulse to
  47672. * @param force amount of force to be applied to the imposter
  47673. * @param contactPoint the location to apply the impulse on the imposter
  47674. */
  47675. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47676. /**
  47677. * Applies a force on the imposter
  47678. * @param impostor imposter to apply force
  47679. * @param force amount of force to be applied to the imposter
  47680. * @param contactPoint the location to apply the force on the imposter
  47681. */
  47682. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47683. /**
  47684. * Creates a physics body using the plugin
  47685. * @param impostor the imposter to create the physics body on
  47686. */
  47687. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47688. /**
  47689. * Removes the physics body from the imposter and disposes of the body's memory
  47690. * @param impostor imposter to remove the physics body from
  47691. */
  47692. removePhysicsBody(impostor: PhysicsImpostor): void;
  47693. /**
  47694. * Generates a joint
  47695. * @param impostorJoint the imposter joint to create the joint with
  47696. */
  47697. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47698. /**
  47699. * Removes a joint
  47700. * @param impostorJoint the imposter joint to remove the joint from
  47701. */
  47702. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47703. private _addMeshVerts;
  47704. /**
  47705. * Initialise the soft body vertices to match its object's (mesh) vertices
  47706. * Softbody vertices (nodes) are in world space and to match this
  47707. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  47708. * @param impostor to create the softbody for
  47709. */
  47710. private _softVertexData;
  47711. /**
  47712. * Create an impostor's soft body
  47713. * @param impostor to create the softbody for
  47714. */
  47715. private _createSoftbody;
  47716. /**
  47717. * Create cloth for an impostor
  47718. * @param impostor to create the softbody for
  47719. */
  47720. private _createCloth;
  47721. /**
  47722. * Create rope for an impostor
  47723. * @param impostor to create the softbody for
  47724. */
  47725. private _createRope;
  47726. private _addHullVerts;
  47727. private _createShape;
  47728. /**
  47729. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  47730. * @param impostor imposter containing the physics body and babylon object
  47731. */
  47732. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47733. /**
  47734. * Sets the babylon object's position/rotation from the physics body's position/rotation
  47735. * @param impostor imposter containing the physics body and babylon object
  47736. * @param newPosition new position
  47737. * @param newRotation new rotation
  47738. */
  47739. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47740. /**
  47741. * If this plugin is supported
  47742. * @returns true if its supported
  47743. */
  47744. isSupported(): boolean;
  47745. /**
  47746. * Sets the linear velocity of the physics body
  47747. * @param impostor imposter to set the velocity on
  47748. * @param velocity velocity to set
  47749. */
  47750. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47751. /**
  47752. * Sets the angular velocity of the physics body
  47753. * @param impostor imposter to set the velocity on
  47754. * @param velocity velocity to set
  47755. */
  47756. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47757. /**
  47758. * gets the linear velocity
  47759. * @param impostor imposter to get linear velocity from
  47760. * @returns linear velocity
  47761. */
  47762. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47763. /**
  47764. * gets the angular velocity
  47765. * @param impostor imposter to get angular velocity from
  47766. * @returns angular velocity
  47767. */
  47768. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47769. /**
  47770. * Sets the mass of physics body
  47771. * @param impostor imposter to set the mass on
  47772. * @param mass mass to set
  47773. */
  47774. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47775. /**
  47776. * Gets the mass of the physics body
  47777. * @param impostor imposter to get the mass from
  47778. * @returns mass
  47779. */
  47780. getBodyMass(impostor: PhysicsImpostor): number;
  47781. /**
  47782. * Gets friction of the impostor
  47783. * @param impostor impostor to get friction from
  47784. * @returns friction value
  47785. */
  47786. getBodyFriction(impostor: PhysicsImpostor): number;
  47787. /**
  47788. * Sets friction of the impostor
  47789. * @param impostor impostor to set friction on
  47790. * @param friction friction value
  47791. */
  47792. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47793. /**
  47794. * Gets restitution of the impostor
  47795. * @param impostor impostor to get restitution from
  47796. * @returns restitution value
  47797. */
  47798. getBodyRestitution(impostor: PhysicsImpostor): number;
  47799. /**
  47800. * Sets resitution of the impostor
  47801. * @param impostor impostor to set resitution on
  47802. * @param restitution resitution value
  47803. */
  47804. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47805. /**
  47806. * Gets pressure inside the impostor
  47807. * @param impostor impostor to get pressure from
  47808. * @returns pressure value
  47809. */
  47810. getBodyPressure(impostor: PhysicsImpostor): number;
  47811. /**
  47812. * Sets pressure inside a soft body impostor
  47813. * Cloth and rope must remain 0 pressure
  47814. * @param impostor impostor to set pressure on
  47815. * @param pressure pressure value
  47816. */
  47817. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  47818. /**
  47819. * Gets stiffness of the impostor
  47820. * @param impostor impostor to get stiffness from
  47821. * @returns pressure value
  47822. */
  47823. getBodyStiffness(impostor: PhysicsImpostor): number;
  47824. /**
  47825. * Sets stiffness of the impostor
  47826. * @param impostor impostor to set stiffness on
  47827. * @param stiffness stiffness value from 0 to 1
  47828. */
  47829. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  47830. /**
  47831. * Gets velocityIterations of the impostor
  47832. * @param impostor impostor to get velocity iterations from
  47833. * @returns velocityIterations value
  47834. */
  47835. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  47836. /**
  47837. * Sets velocityIterations of the impostor
  47838. * @param impostor impostor to set velocity iterations on
  47839. * @param velocityIterations velocityIterations value
  47840. */
  47841. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  47842. /**
  47843. * Gets positionIterations of the impostor
  47844. * @param impostor impostor to get position iterations from
  47845. * @returns positionIterations value
  47846. */
  47847. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  47848. /**
  47849. * Sets positionIterations of the impostor
  47850. * @param impostor impostor to set position on
  47851. * @param positionIterations positionIterations value
  47852. */
  47853. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  47854. /**
  47855. * Append an anchor to a cloth object
  47856. * @param impostor is the cloth impostor to add anchor to
  47857. * @param otherImpostor is the rigid impostor to anchor to
  47858. * @param width ratio across width from 0 to 1
  47859. * @param height ratio up height from 0 to 1
  47860. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  47861. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  47862. */
  47863. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  47864. /**
  47865. * Append an hook to a rope object
  47866. * @param impostor is the rope impostor to add hook to
  47867. * @param otherImpostor is the rigid impostor to hook to
  47868. * @param length ratio along the rope from 0 to 1
  47869. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  47870. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  47871. */
  47872. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  47873. /**
  47874. * Sleeps the physics body and stops it from being active
  47875. * @param impostor impostor to sleep
  47876. */
  47877. sleepBody(impostor: PhysicsImpostor): void;
  47878. /**
  47879. * Activates the physics body
  47880. * @param impostor impostor to activate
  47881. */
  47882. wakeUpBody(impostor: PhysicsImpostor): void;
  47883. /**
  47884. * Updates the distance parameters of the joint
  47885. * @param joint joint to update
  47886. * @param maxDistance maximum distance of the joint
  47887. * @param minDistance minimum distance of the joint
  47888. */
  47889. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47890. /**
  47891. * Sets a motor on the joint
  47892. * @param joint joint to set motor on
  47893. * @param speed speed of the motor
  47894. * @param maxForce maximum force of the motor
  47895. * @param motorIndex index of the motor
  47896. */
  47897. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47898. /**
  47899. * Sets the motors limit
  47900. * @param joint joint to set limit on
  47901. * @param upperLimit upper limit
  47902. * @param lowerLimit lower limit
  47903. */
  47904. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47905. /**
  47906. * Syncs the position and rotation of a mesh with the impostor
  47907. * @param mesh mesh to sync
  47908. * @param impostor impostor to update the mesh with
  47909. */
  47910. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47911. /**
  47912. * Gets the radius of the impostor
  47913. * @param impostor impostor to get radius from
  47914. * @returns the radius
  47915. */
  47916. getRadius(impostor: PhysicsImpostor): number;
  47917. /**
  47918. * Gets the box size of the impostor
  47919. * @param impostor impostor to get box size from
  47920. * @param result the resulting box size
  47921. */
  47922. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47923. /**
  47924. * Disposes of the impostor
  47925. */
  47926. dispose(): void;
  47927. /**
  47928. * Does a raycast in the physics world
  47929. * @param from when should the ray start?
  47930. * @param to when should the ray end?
  47931. * @returns PhysicsRaycastResult
  47932. */
  47933. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47934. }
  47935. }
  47936. declare module BABYLON {
  47937. interface AbstractScene {
  47938. /**
  47939. * The list of reflection probes added to the scene
  47940. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47941. */
  47942. reflectionProbes: Array<ReflectionProbe>;
  47943. /**
  47944. * Removes the given reflection probe from this scene.
  47945. * @param toRemove The reflection probe to remove
  47946. * @returns The index of the removed reflection probe
  47947. */
  47948. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47949. /**
  47950. * Adds the given reflection probe to this scene.
  47951. * @param newReflectionProbe The reflection probe to add
  47952. */
  47953. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47954. }
  47955. /**
  47956. * Class used to generate realtime reflection / refraction cube textures
  47957. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47958. */
  47959. export class ReflectionProbe {
  47960. /** defines the name of the probe */
  47961. name: string;
  47962. private _scene;
  47963. private _renderTargetTexture;
  47964. private _projectionMatrix;
  47965. private _viewMatrix;
  47966. private _target;
  47967. private _add;
  47968. private _attachedMesh;
  47969. private _invertYAxis;
  47970. /** Gets or sets probe position (center of the cube map) */
  47971. position: Vector3;
  47972. /**
  47973. * Creates a new reflection probe
  47974. * @param name defines the name of the probe
  47975. * @param size defines the texture resolution (for each face)
  47976. * @param scene defines the hosting scene
  47977. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47978. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47979. */
  47980. constructor(
  47981. /** defines the name of the probe */
  47982. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47983. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47984. samples: number;
  47985. /** Gets or sets the refresh rate to use (on every frame by default) */
  47986. refreshRate: number;
  47987. /**
  47988. * Gets the hosting scene
  47989. * @returns a Scene
  47990. */
  47991. getScene(): Scene;
  47992. /** Gets the internal CubeTexture used to render to */
  47993. readonly cubeTexture: RenderTargetTexture;
  47994. /** Gets the list of meshes to render */
  47995. readonly renderList: Nullable<AbstractMesh[]>;
  47996. /**
  47997. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47998. * @param mesh defines the mesh to attach to
  47999. */
  48000. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48001. /**
  48002. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48003. * @param renderingGroupId The rendering group id corresponding to its index
  48004. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48005. */
  48006. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48007. /**
  48008. * Clean all associated resources
  48009. */
  48010. dispose(): void;
  48011. /**
  48012. * Converts the reflection probe information to a readable string for debug purpose.
  48013. * @param fullDetails Supports for multiple levels of logging within scene loading
  48014. * @returns the human readable reflection probe info
  48015. */
  48016. toString(fullDetails?: boolean): string;
  48017. /**
  48018. * Get the class name of the relfection probe.
  48019. * @returns "ReflectionProbe"
  48020. */
  48021. getClassName(): string;
  48022. /**
  48023. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48024. * @returns The JSON representation of the texture
  48025. */
  48026. serialize(): any;
  48027. /**
  48028. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48029. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48030. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48031. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48032. * @returns The parsed reflection probe if successful
  48033. */
  48034. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48035. }
  48036. }
  48037. declare module BABYLON {
  48038. /** @hidden */
  48039. export var _BabylonLoaderRegistered: boolean;
  48040. }
  48041. declare module BABYLON {
  48042. /**
  48043. * The Physically based simple base material of BJS.
  48044. *
  48045. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48046. * It is used as the base class for both the specGloss and metalRough conventions.
  48047. */
  48048. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48049. /**
  48050. * Number of Simultaneous lights allowed on the material.
  48051. */
  48052. maxSimultaneousLights: number;
  48053. /**
  48054. * If sets to true, disables all the lights affecting the material.
  48055. */
  48056. disableLighting: boolean;
  48057. /**
  48058. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48059. */
  48060. environmentTexture: BaseTexture;
  48061. /**
  48062. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48063. */
  48064. invertNormalMapX: boolean;
  48065. /**
  48066. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48067. */
  48068. invertNormalMapY: boolean;
  48069. /**
  48070. * Normal map used in the model.
  48071. */
  48072. normalTexture: BaseTexture;
  48073. /**
  48074. * Emissivie color used to self-illuminate the model.
  48075. */
  48076. emissiveColor: Color3;
  48077. /**
  48078. * Emissivie texture used to self-illuminate the model.
  48079. */
  48080. emissiveTexture: BaseTexture;
  48081. /**
  48082. * Occlusion Channel Strenght.
  48083. */
  48084. occlusionStrength: number;
  48085. /**
  48086. * Occlusion Texture of the material (adding extra occlusion effects).
  48087. */
  48088. occlusionTexture: BaseTexture;
  48089. /**
  48090. * Defines the alpha limits in alpha test mode.
  48091. */
  48092. alphaCutOff: number;
  48093. /**
  48094. * Gets the current double sided mode.
  48095. */
  48096. /**
  48097. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48098. */
  48099. doubleSided: boolean;
  48100. /**
  48101. * Stores the pre-calculated light information of a mesh in a texture.
  48102. */
  48103. lightmapTexture: BaseTexture;
  48104. /**
  48105. * If true, the light map contains occlusion information instead of lighting info.
  48106. */
  48107. useLightmapAsShadowmap: boolean;
  48108. /**
  48109. * Instantiates a new PBRMaterial instance.
  48110. *
  48111. * @param name The material name
  48112. * @param scene The scene the material will be use in.
  48113. */
  48114. constructor(name: string, scene: Scene);
  48115. getClassName(): string;
  48116. }
  48117. }
  48118. declare module BABYLON {
  48119. /**
  48120. * The PBR material of BJS following the metal roughness convention.
  48121. *
  48122. * This fits to the PBR convention in the GLTF definition:
  48123. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48124. */
  48125. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48126. /**
  48127. * The base color has two different interpretations depending on the value of metalness.
  48128. * When the material is a metal, the base color is the specific measured reflectance value
  48129. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48130. * of the material.
  48131. */
  48132. baseColor: Color3;
  48133. /**
  48134. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48135. * well as opacity information in the alpha channel.
  48136. */
  48137. baseTexture: BaseTexture;
  48138. /**
  48139. * Specifies the metallic scalar value of the material.
  48140. * Can also be used to scale the metalness values of the metallic texture.
  48141. */
  48142. metallic: number;
  48143. /**
  48144. * Specifies the roughness scalar value of the material.
  48145. * Can also be used to scale the roughness values of the metallic texture.
  48146. */
  48147. roughness: number;
  48148. /**
  48149. * Texture containing both the metallic value in the B channel and the
  48150. * roughness value in the G channel to keep better precision.
  48151. */
  48152. metallicRoughnessTexture: BaseTexture;
  48153. /**
  48154. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48155. *
  48156. * @param name The material name
  48157. * @param scene The scene the material will be use in.
  48158. */
  48159. constructor(name: string, scene: Scene);
  48160. /**
  48161. * Return the currrent class name of the material.
  48162. */
  48163. getClassName(): string;
  48164. /**
  48165. * Makes a duplicate of the current material.
  48166. * @param name - name to use for the new material.
  48167. */
  48168. clone(name: string): PBRMetallicRoughnessMaterial;
  48169. /**
  48170. * Serialize the material to a parsable JSON object.
  48171. */
  48172. serialize(): any;
  48173. /**
  48174. * Parses a JSON object correponding to the serialize function.
  48175. */
  48176. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48177. }
  48178. }
  48179. declare module BABYLON {
  48180. /**
  48181. * The PBR material of BJS following the specular glossiness convention.
  48182. *
  48183. * This fits to the PBR convention in the GLTF definition:
  48184. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48185. */
  48186. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48187. /**
  48188. * Specifies the diffuse color of the material.
  48189. */
  48190. diffuseColor: Color3;
  48191. /**
  48192. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48193. * channel.
  48194. */
  48195. diffuseTexture: BaseTexture;
  48196. /**
  48197. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48198. */
  48199. specularColor: Color3;
  48200. /**
  48201. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48202. */
  48203. glossiness: number;
  48204. /**
  48205. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48206. */
  48207. specularGlossinessTexture: BaseTexture;
  48208. /**
  48209. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48210. *
  48211. * @param name The material name
  48212. * @param scene The scene the material will be use in.
  48213. */
  48214. constructor(name: string, scene: Scene);
  48215. /**
  48216. * Return the currrent class name of the material.
  48217. */
  48218. getClassName(): string;
  48219. /**
  48220. * Makes a duplicate of the current material.
  48221. * @param name - name to use for the new material.
  48222. */
  48223. clone(name: string): PBRSpecularGlossinessMaterial;
  48224. /**
  48225. * Serialize the material to a parsable JSON object.
  48226. */
  48227. serialize(): any;
  48228. /**
  48229. * Parses a JSON object correponding to the serialize function.
  48230. */
  48231. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48232. }
  48233. }
  48234. declare module BABYLON {
  48235. /**
  48236. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48237. * It can help converting any input color in a desired output one. This can then be used to create effects
  48238. * from sepia, black and white to sixties or futuristic rendering...
  48239. *
  48240. * The only supported format is currently 3dl.
  48241. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48242. */
  48243. export class ColorGradingTexture extends BaseTexture {
  48244. /**
  48245. * The current texture matrix. (will always be identity in color grading texture)
  48246. */
  48247. private _textureMatrix;
  48248. /**
  48249. * The texture URL.
  48250. */
  48251. url: string;
  48252. /**
  48253. * Empty line regex stored for GC.
  48254. */
  48255. private static _noneEmptyLineRegex;
  48256. private _engine;
  48257. /**
  48258. * Instantiates a ColorGradingTexture from the following parameters.
  48259. *
  48260. * @param url The location of the color gradind data (currently only supporting 3dl)
  48261. * @param scene The scene the texture will be used in
  48262. */
  48263. constructor(url: string, scene: Scene);
  48264. /**
  48265. * Returns the texture matrix used in most of the material.
  48266. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48267. */
  48268. getTextureMatrix(): Matrix;
  48269. /**
  48270. * Occurs when the file being loaded is a .3dl LUT file.
  48271. */
  48272. private load3dlTexture;
  48273. /**
  48274. * Starts the loading process of the texture.
  48275. */
  48276. private loadTexture;
  48277. /**
  48278. * Clones the color gradind texture.
  48279. */
  48280. clone(): ColorGradingTexture;
  48281. /**
  48282. * Called during delayed load for textures.
  48283. */
  48284. delayLoad(): void;
  48285. /**
  48286. * Parses a color grading texture serialized by Babylon.
  48287. * @param parsedTexture The texture information being parsedTexture
  48288. * @param scene The scene to load the texture in
  48289. * @param rootUrl The root url of the data assets to load
  48290. * @return A color gradind texture
  48291. */
  48292. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48293. /**
  48294. * Serializes the LUT texture to json format.
  48295. */
  48296. serialize(): any;
  48297. }
  48298. }
  48299. declare module BABYLON {
  48300. /**
  48301. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48302. */
  48303. export class EquiRectangularCubeTexture extends BaseTexture {
  48304. /** The six faces of the cube. */
  48305. private static _FacesMapping;
  48306. private _noMipmap;
  48307. private _onLoad;
  48308. private _onError;
  48309. /** The size of the cubemap. */
  48310. private _size;
  48311. /** The buffer of the image. */
  48312. private _buffer;
  48313. /** The width of the input image. */
  48314. private _width;
  48315. /** The height of the input image. */
  48316. private _height;
  48317. /** The URL to the image. */
  48318. url: string;
  48319. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48320. coordinatesMode: number;
  48321. /**
  48322. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48323. * @param url The location of the image
  48324. * @param scene The scene the texture will be used in
  48325. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48326. * @param noMipmap Forces to not generate the mipmap if true
  48327. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48328. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48329. * @param onLoad — defines a callback called when texture is loaded
  48330. * @param onError — defines a callback called if there is an error
  48331. */
  48332. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48333. /**
  48334. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48335. */
  48336. private loadImage;
  48337. /**
  48338. * Convert the image buffer into a cubemap and create a CubeTexture.
  48339. */
  48340. private loadTexture;
  48341. /**
  48342. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48343. * @param buffer The ArrayBuffer that should be converted.
  48344. * @returns The buffer as Float32Array.
  48345. */
  48346. private getFloat32ArrayFromArrayBuffer;
  48347. /**
  48348. * Get the current class name of the texture useful for serialization or dynamic coding.
  48349. * @returns "EquiRectangularCubeTexture"
  48350. */
  48351. getClassName(): string;
  48352. /**
  48353. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48354. * @returns A clone of the current EquiRectangularCubeTexture.
  48355. */
  48356. clone(): EquiRectangularCubeTexture;
  48357. }
  48358. }
  48359. declare module BABYLON {
  48360. /**
  48361. * Based on jsTGALoader - Javascript loader for TGA file
  48362. * By Vincent Thibault
  48363. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48364. */
  48365. export class TGATools {
  48366. private static _TYPE_INDEXED;
  48367. private static _TYPE_RGB;
  48368. private static _TYPE_GREY;
  48369. private static _TYPE_RLE_INDEXED;
  48370. private static _TYPE_RLE_RGB;
  48371. private static _TYPE_RLE_GREY;
  48372. private static _ORIGIN_MASK;
  48373. private static _ORIGIN_SHIFT;
  48374. private static _ORIGIN_BL;
  48375. private static _ORIGIN_BR;
  48376. private static _ORIGIN_UL;
  48377. private static _ORIGIN_UR;
  48378. /**
  48379. * Gets the header of a TGA file
  48380. * @param data defines the TGA data
  48381. * @returns the header
  48382. */
  48383. static GetTGAHeader(data: Uint8Array): any;
  48384. /**
  48385. * Uploads TGA content to a Babylon Texture
  48386. * @hidden
  48387. */
  48388. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48389. /** @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;
  48390. /** @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;
  48391. /** @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;
  48392. /** @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;
  48393. /** @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;
  48394. /** @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;
  48395. }
  48396. }
  48397. declare module BABYLON {
  48398. /**
  48399. * Implementation of the TGA Texture Loader.
  48400. * @hidden
  48401. */
  48402. export class _TGATextureLoader implements IInternalTextureLoader {
  48403. /**
  48404. * Defines wether the loader supports cascade loading the different faces.
  48405. */
  48406. readonly supportCascades: boolean;
  48407. /**
  48408. * This returns if the loader support the current file information.
  48409. * @param extension defines the file extension of the file being loaded
  48410. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48411. * @param fallback defines the fallback internal texture if any
  48412. * @param isBase64 defines whether the texture is encoded as a base64
  48413. * @param isBuffer defines whether the texture data are stored as a buffer
  48414. * @returns true if the loader can load the specified file
  48415. */
  48416. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48417. /**
  48418. * Transform the url before loading if required.
  48419. * @param rootUrl the url of the texture
  48420. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48421. * @returns the transformed texture
  48422. */
  48423. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48424. /**
  48425. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48426. * @param rootUrl the url of the texture
  48427. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48428. * @returns the fallback texture
  48429. */
  48430. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48431. /**
  48432. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48433. * @param data contains the texture data
  48434. * @param texture defines the BabylonJS internal texture
  48435. * @param createPolynomials will be true if polynomials have been requested
  48436. * @param onLoad defines the callback to trigger once the texture is ready
  48437. * @param onError defines the callback to trigger in case of error
  48438. */
  48439. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48440. /**
  48441. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48442. * @param data contains the texture data
  48443. * @param texture defines the BabylonJS internal texture
  48444. * @param callback defines the method to call once ready to upload
  48445. */
  48446. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48447. }
  48448. }
  48449. declare module BABYLON {
  48450. /**
  48451. * 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.
  48452. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48453. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48454. */
  48455. export class CustomProceduralTexture extends ProceduralTexture {
  48456. private _animate;
  48457. private _time;
  48458. private _config;
  48459. private _texturePath;
  48460. /**
  48461. * Instantiates a new Custom Procedural Texture.
  48462. * 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.
  48463. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48464. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48465. * @param name Define the name of the texture
  48466. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48467. * @param size Define the size of the texture to create
  48468. * @param scene Define the scene the texture belongs to
  48469. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48470. * @param generateMipMaps Define if the texture should creates mip maps or not
  48471. */
  48472. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48473. private _loadJson;
  48474. /**
  48475. * Is the texture ready to be used ? (rendered at least once)
  48476. * @returns true if ready, otherwise, false.
  48477. */
  48478. isReady(): boolean;
  48479. /**
  48480. * Render the texture to its associated render target.
  48481. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48482. */
  48483. render(useCameraPostProcess?: boolean): void;
  48484. /**
  48485. * Update the list of dependant textures samplers in the shader.
  48486. */
  48487. updateTextures(): void;
  48488. /**
  48489. * Update the uniform values of the procedural texture in the shader.
  48490. */
  48491. updateShaderUniforms(): void;
  48492. /**
  48493. * Define if the texture animates or not.
  48494. */
  48495. animate: boolean;
  48496. }
  48497. }
  48498. declare module BABYLON {
  48499. /** @hidden */
  48500. export var noisePixelShader: {
  48501. name: string;
  48502. shader: string;
  48503. };
  48504. }
  48505. declare module BABYLON {
  48506. /**
  48507. * Class used to generate noise procedural textures
  48508. */
  48509. export class NoiseProceduralTexture extends ProceduralTexture {
  48510. private _time;
  48511. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48512. brightness: number;
  48513. /** Defines the number of octaves to process */
  48514. octaves: number;
  48515. /** Defines the level of persistence (0.8 by default) */
  48516. persistence: number;
  48517. /** Gets or sets animation speed factor (default is 1) */
  48518. animationSpeedFactor: number;
  48519. /**
  48520. * Creates a new NoiseProceduralTexture
  48521. * @param name defines the name fo the texture
  48522. * @param size defines the size of the texture (default is 256)
  48523. * @param scene defines the hosting scene
  48524. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48525. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48526. */
  48527. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48528. private _updateShaderUniforms;
  48529. protected _getDefines(): string;
  48530. /** Generate the current state of the procedural texture */
  48531. render(useCameraPostProcess?: boolean): void;
  48532. /**
  48533. * Serializes this noise procedural texture
  48534. * @returns a serialized noise procedural texture object
  48535. */
  48536. serialize(): any;
  48537. /**
  48538. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48539. * @param parsedTexture defines parsed texture data
  48540. * @param scene defines the current scene
  48541. * @param rootUrl defines the root URL containing noise procedural texture information
  48542. * @returns a parsed NoiseProceduralTexture
  48543. */
  48544. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48545. }
  48546. }
  48547. declare module BABYLON {
  48548. /**
  48549. * Raw cube texture where the raw buffers are passed in
  48550. */
  48551. export class RawCubeTexture extends CubeTexture {
  48552. /**
  48553. * Creates a cube texture where the raw buffers are passed in.
  48554. * @param scene defines the scene the texture is attached to
  48555. * @param data defines the array of data to use to create each face
  48556. * @param size defines the size of the textures
  48557. * @param format defines the format of the data
  48558. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48559. * @param generateMipMaps defines if the engine should generate the mip levels
  48560. * @param invertY defines if data must be stored with Y axis inverted
  48561. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48562. * @param compression defines the compression used (null by default)
  48563. */
  48564. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48565. /**
  48566. * Updates the raw cube texture.
  48567. * @param data defines the data to store
  48568. * @param format defines the data format
  48569. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48570. * @param invertY defines if data must be stored with Y axis inverted
  48571. * @param compression defines the compression used (null by default)
  48572. * @param level defines which level of the texture to update
  48573. */
  48574. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48575. /**
  48576. * Updates a raw cube texture with RGBD encoded data.
  48577. * @param data defines the array of data [mipmap][face] to use to create each face
  48578. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48579. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48580. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48581. * @returns a promsie that resolves when the operation is complete
  48582. */
  48583. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48584. /**
  48585. * Clones the raw cube texture.
  48586. * @return a new cube texture
  48587. */
  48588. clone(): CubeTexture;
  48589. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48590. }
  48591. }
  48592. declare module BABYLON {
  48593. /**
  48594. * Class used to store 3D textures containing user data
  48595. */
  48596. export class RawTexture3D extends Texture {
  48597. /** Gets or sets the texture format to use */
  48598. format: number;
  48599. private _engine;
  48600. /**
  48601. * Create a new RawTexture3D
  48602. * @param data defines the data of the texture
  48603. * @param width defines the width of the texture
  48604. * @param height defines the height of the texture
  48605. * @param depth defines the depth of the texture
  48606. * @param format defines the texture format to use
  48607. * @param scene defines the hosting scene
  48608. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48609. * @param invertY defines if texture must be stored with Y axis inverted
  48610. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48611. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48612. */
  48613. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48614. /** Gets or sets the texture format to use */
  48615. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48616. /**
  48617. * Update the texture with new data
  48618. * @param data defines the data to store in the texture
  48619. */
  48620. update(data: ArrayBufferView): void;
  48621. }
  48622. }
  48623. declare module BABYLON {
  48624. /**
  48625. * Creates a refraction texture used by refraction channel of the standard material.
  48626. * It is like a mirror but to see through a material.
  48627. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48628. */
  48629. export class RefractionTexture extends RenderTargetTexture {
  48630. /**
  48631. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48632. * 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.
  48633. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48634. */
  48635. refractionPlane: Plane;
  48636. /**
  48637. * Define how deep under the surface we should see.
  48638. */
  48639. depth: number;
  48640. /**
  48641. * Creates a refraction texture used by refraction channel of the standard material.
  48642. * It is like a mirror but to see through a material.
  48643. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48644. * @param name Define the texture name
  48645. * @param size Define the size of the underlying texture
  48646. * @param scene Define the scene the refraction belongs to
  48647. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48648. */
  48649. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48650. /**
  48651. * Clone the refraction texture.
  48652. * @returns the cloned texture
  48653. */
  48654. clone(): RefractionTexture;
  48655. /**
  48656. * Serialize the texture to a JSON representation you could use in Parse later on
  48657. * @returns the serialized JSON representation
  48658. */
  48659. serialize(): any;
  48660. }
  48661. }
  48662. declare module BABYLON {
  48663. /**
  48664. * Defines the options related to the creation of an HtmlElementTexture
  48665. */
  48666. export interface IHtmlElementTextureOptions {
  48667. /**
  48668. * Defines wether mip maps should be created or not.
  48669. */
  48670. generateMipMaps?: boolean;
  48671. /**
  48672. * Defines the sampling mode of the texture.
  48673. */
  48674. samplingMode?: number;
  48675. /**
  48676. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  48677. */
  48678. engine: Nullable<Engine>;
  48679. /**
  48680. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  48681. */
  48682. scene: Nullable<Scene>;
  48683. }
  48684. /**
  48685. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  48686. * To be as efficient as possible depending on your constraints nothing aside the first upload
  48687. * is automatically managed.
  48688. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  48689. * in your application.
  48690. *
  48691. * As the update is not automatic, you need to call them manually.
  48692. */
  48693. export class HtmlElementTexture extends BaseTexture {
  48694. /**
  48695. * The texture URL.
  48696. */
  48697. element: HTMLVideoElement | HTMLCanvasElement;
  48698. private static readonly DefaultOptions;
  48699. private _textureMatrix;
  48700. private _engine;
  48701. private _isVideo;
  48702. private _generateMipMaps;
  48703. private _samplingMode;
  48704. /**
  48705. * Instantiates a HtmlElementTexture from the following parameters.
  48706. *
  48707. * @param name Defines the name of the texture
  48708. * @param element Defines the video or canvas the texture is filled with
  48709. * @param options Defines the other none mandatory texture creation options
  48710. */
  48711. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  48712. private _createInternalTexture;
  48713. /**
  48714. * Returns the texture matrix used in most of the material.
  48715. */
  48716. getTextureMatrix(): Matrix;
  48717. /**
  48718. * Updates the content of the texture.
  48719. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  48720. */
  48721. update(invertY?: Nullable<boolean>): void;
  48722. }
  48723. }
  48724. declare module BABYLON {
  48725. /**
  48726. * Helper class to push actions to a pool of workers.
  48727. */
  48728. export class WorkerPool implements IDisposable {
  48729. private _workerInfos;
  48730. private _pendingActions;
  48731. /**
  48732. * Constructor
  48733. * @param workers Array of workers to use for actions
  48734. */
  48735. constructor(workers: Array<Worker>);
  48736. /**
  48737. * Terminates all workers and clears any pending actions.
  48738. */
  48739. dispose(): void;
  48740. /**
  48741. * Pushes an action to the worker pool. If all the workers are active, the action will be
  48742. * pended until a worker has completed its action.
  48743. * @param action The action to perform. Call onComplete when the action is complete.
  48744. */
  48745. push(action: (worker: Worker, onComplete: () => void) => void): void;
  48746. private _execute;
  48747. }
  48748. }
  48749. declare module BABYLON {
  48750. /**
  48751. * Configuration for Draco compression
  48752. */
  48753. export interface IDracoCompressionConfiguration {
  48754. /**
  48755. * Configuration for the decoder.
  48756. */
  48757. decoder?: {
  48758. /**
  48759. * The url to the WebAssembly module.
  48760. */
  48761. wasmUrl?: string;
  48762. /**
  48763. * The url to the WebAssembly binary.
  48764. */
  48765. wasmBinaryUrl?: string;
  48766. /**
  48767. * The url to the fallback JavaScript module.
  48768. */
  48769. fallbackUrl?: string;
  48770. };
  48771. }
  48772. /**
  48773. * Draco compression (https://google.github.io/draco/)
  48774. *
  48775. * This class wraps the Draco module.
  48776. *
  48777. * **Encoder**
  48778. *
  48779. * The encoder is not currently implemented.
  48780. *
  48781. * **Decoder**
  48782. *
  48783. * 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.
  48784. *
  48785. * To update the configuration, use the following code:
  48786. * ```javascript
  48787. * DracoCompression.Configuration = {
  48788. * decoder: {
  48789. * wasmUrl: "<url to the WebAssembly library>",
  48790. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48791. * fallbackUrl: "<url to the fallback JavaScript library>",
  48792. * }
  48793. * };
  48794. * ```
  48795. *
  48796. * 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.
  48797. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48798. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48799. *
  48800. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48801. * ```javascript
  48802. * var dracoCompression = new DracoCompression();
  48803. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48804. * [VertexBuffer.PositionKind]: 0
  48805. * });
  48806. * ```
  48807. *
  48808. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48809. */
  48810. export class DracoCompression implements IDisposable {
  48811. private _workerPoolPromise;
  48812. /**
  48813. * The configuration. Defaults to the following urls:
  48814. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48815. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48816. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48817. */
  48818. static Configuration: IDracoCompressionConfiguration;
  48819. /**
  48820. * Returns true if the decoder is available.
  48821. */
  48822. static readonly DecoderAvailable: boolean;
  48823. /**
  48824. * Default number of workers to create when creating the draco compression object.
  48825. */
  48826. static DefaultNumWorkers: number;
  48827. private static GetDefaultNumWorkers;
  48828. /**
  48829. * Constructor
  48830. * @param numWorkers The number of workers for async operations
  48831. */
  48832. constructor(numWorkers?: number);
  48833. /**
  48834. * Stop all async operations and release resources.
  48835. */
  48836. dispose(): void;
  48837. /**
  48838. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  48839. * @returns a promise that resolves when ready
  48840. */
  48841. whenReadyAsync(): Promise<void>;
  48842. /**
  48843. * Decode Draco compressed mesh data to vertex data.
  48844. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48845. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48846. * @returns A promise that resolves with the decoded vertex data
  48847. */
  48848. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  48849. [kind: string]: number;
  48850. }): Promise<VertexData>;
  48851. /**
  48852. * The worker function that gets converted to a blob url to pass into a worker.
  48853. */
  48854. private static _Worker;
  48855. private _loadDecoderWasmBinaryAsync;
  48856. }
  48857. }
  48858. declare module BABYLON {
  48859. /**
  48860. * Class for building Constructive Solid Geometry
  48861. */
  48862. export class CSG {
  48863. private polygons;
  48864. /**
  48865. * The world matrix
  48866. */
  48867. matrix: Matrix;
  48868. /**
  48869. * Stores the position
  48870. */
  48871. position: Vector3;
  48872. /**
  48873. * Stores the rotation
  48874. */
  48875. rotation: Vector3;
  48876. /**
  48877. * Stores the rotation quaternion
  48878. */
  48879. rotationQuaternion: Nullable<Quaternion>;
  48880. /**
  48881. * Stores the scaling vector
  48882. */
  48883. scaling: Vector3;
  48884. /**
  48885. * Convert the Mesh to CSG
  48886. * @param mesh The Mesh to convert to CSG
  48887. * @returns A new CSG from the Mesh
  48888. */
  48889. static FromMesh(mesh: Mesh): CSG;
  48890. /**
  48891. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48892. * @param polygons Polygons used to construct a CSG solid
  48893. */
  48894. private static FromPolygons;
  48895. /**
  48896. * Clones, or makes a deep copy, of the CSG
  48897. * @returns A new CSG
  48898. */
  48899. clone(): CSG;
  48900. /**
  48901. * Unions this CSG with another CSG
  48902. * @param csg The CSG to union against this CSG
  48903. * @returns The unioned CSG
  48904. */
  48905. union(csg: CSG): CSG;
  48906. /**
  48907. * Unions this CSG with another CSG in place
  48908. * @param csg The CSG to union against this CSG
  48909. */
  48910. unionInPlace(csg: CSG): void;
  48911. /**
  48912. * Subtracts this CSG with another CSG
  48913. * @param csg The CSG to subtract against this CSG
  48914. * @returns A new CSG
  48915. */
  48916. subtract(csg: CSG): CSG;
  48917. /**
  48918. * Subtracts this CSG with another CSG in place
  48919. * @param csg The CSG to subtact against this CSG
  48920. */
  48921. subtractInPlace(csg: CSG): void;
  48922. /**
  48923. * Intersect this CSG with another CSG
  48924. * @param csg The CSG to intersect against this CSG
  48925. * @returns A new CSG
  48926. */
  48927. intersect(csg: CSG): CSG;
  48928. /**
  48929. * Intersects this CSG with another CSG in place
  48930. * @param csg The CSG to intersect against this CSG
  48931. */
  48932. intersectInPlace(csg: CSG): void;
  48933. /**
  48934. * Return a new CSG solid with solid and empty space switched. This solid is
  48935. * not modified.
  48936. * @returns A new CSG solid with solid and empty space switched
  48937. */
  48938. inverse(): CSG;
  48939. /**
  48940. * Inverses the CSG in place
  48941. */
  48942. inverseInPlace(): void;
  48943. /**
  48944. * This is used to keep meshes transformations so they can be restored
  48945. * when we build back a Babylon Mesh
  48946. * NB : All CSG operations are performed in world coordinates
  48947. * @param csg The CSG to copy the transform attributes from
  48948. * @returns This CSG
  48949. */
  48950. copyTransformAttributes(csg: CSG): CSG;
  48951. /**
  48952. * Build Raw mesh from CSG
  48953. * Coordinates here are in world space
  48954. * @param name The name of the mesh geometry
  48955. * @param scene The Scene
  48956. * @param keepSubMeshes Specifies if the submeshes should be kept
  48957. * @returns A new Mesh
  48958. */
  48959. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48960. /**
  48961. * Build Mesh from CSG taking material and transforms into account
  48962. * @param name The name of the Mesh
  48963. * @param material The material of the Mesh
  48964. * @param scene The Scene
  48965. * @param keepSubMeshes Specifies if submeshes should be kept
  48966. * @returns The new Mesh
  48967. */
  48968. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48969. }
  48970. }
  48971. declare module BABYLON {
  48972. /**
  48973. * Class used to create a trail following a mesh
  48974. */
  48975. export class TrailMesh extends Mesh {
  48976. private _generator;
  48977. private _autoStart;
  48978. private _running;
  48979. private _diameter;
  48980. private _length;
  48981. private _sectionPolygonPointsCount;
  48982. private _sectionVectors;
  48983. private _sectionNormalVectors;
  48984. private _beforeRenderObserver;
  48985. /**
  48986. * @constructor
  48987. * @param name The value used by scene.getMeshByName() to do a lookup.
  48988. * @param generator The mesh to generate a trail.
  48989. * @param scene The scene to add this mesh to.
  48990. * @param diameter Diameter of trailing mesh. Default is 1.
  48991. * @param length Length of trailing mesh. Default is 60.
  48992. * @param autoStart Automatically start trailing mesh. Default true.
  48993. */
  48994. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  48995. /**
  48996. * "TrailMesh"
  48997. * @returns "TrailMesh"
  48998. */
  48999. getClassName(): string;
  49000. private _createMesh;
  49001. /**
  49002. * Start trailing mesh.
  49003. */
  49004. start(): void;
  49005. /**
  49006. * Stop trailing mesh.
  49007. */
  49008. stop(): void;
  49009. /**
  49010. * Update trailing mesh geometry.
  49011. */
  49012. update(): void;
  49013. /**
  49014. * Returns a new TrailMesh object.
  49015. * @param name is a string, the name given to the new mesh
  49016. * @param newGenerator use new generator object for cloned trail mesh
  49017. * @returns a new mesh
  49018. */
  49019. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49020. /**
  49021. * Serializes this trail mesh
  49022. * @param serializationObject object to write serialization to
  49023. */
  49024. serialize(serializationObject: any): void;
  49025. /**
  49026. * Parses a serialized trail mesh
  49027. * @param parsedMesh the serialized mesh
  49028. * @param scene the scene to create the trail mesh in
  49029. * @returns the created trail mesh
  49030. */
  49031. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49032. }
  49033. }
  49034. declare module BABYLON {
  49035. /**
  49036. * Class containing static functions to help procedurally build meshes
  49037. */
  49038. export class TorusKnotBuilder {
  49039. /**
  49040. * Creates a torus knot mesh
  49041. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49042. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49043. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49044. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49046. * * 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
  49047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49048. * @param name defines the name of the mesh
  49049. * @param options defines the options used to create the mesh
  49050. * @param scene defines the hosting scene
  49051. * @returns the torus knot mesh
  49052. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49053. */
  49054. static CreateTorusKnot(name: string, options: {
  49055. radius?: number;
  49056. tube?: number;
  49057. radialSegments?: number;
  49058. tubularSegments?: number;
  49059. p?: number;
  49060. q?: number;
  49061. updatable?: boolean;
  49062. sideOrientation?: number;
  49063. frontUVs?: Vector4;
  49064. backUVs?: Vector4;
  49065. }, scene: any): Mesh;
  49066. }
  49067. }
  49068. declare module BABYLON {
  49069. /**
  49070. * Polygon
  49071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49072. */
  49073. export class Polygon {
  49074. /**
  49075. * Creates a rectangle
  49076. * @param xmin bottom X coord
  49077. * @param ymin bottom Y coord
  49078. * @param xmax top X coord
  49079. * @param ymax top Y coord
  49080. * @returns points that make the resulting rectation
  49081. */
  49082. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49083. /**
  49084. * Creates a circle
  49085. * @param radius radius of circle
  49086. * @param cx scale in x
  49087. * @param cy scale in y
  49088. * @param numberOfSides number of sides that make up the circle
  49089. * @returns points that make the resulting circle
  49090. */
  49091. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49092. /**
  49093. * Creates a polygon from input string
  49094. * @param input Input polygon data
  49095. * @returns the parsed points
  49096. */
  49097. static Parse(input: string): Vector2[];
  49098. /**
  49099. * Starts building a polygon from x and y coordinates
  49100. * @param x x coordinate
  49101. * @param y y coordinate
  49102. * @returns the started path2
  49103. */
  49104. static StartingAt(x: number, y: number): Path2;
  49105. }
  49106. /**
  49107. * Builds a polygon
  49108. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49109. */
  49110. export class PolygonMeshBuilder {
  49111. private _points;
  49112. private _outlinepoints;
  49113. private _holes;
  49114. private _name;
  49115. private _scene;
  49116. private _epoints;
  49117. private _eholes;
  49118. private _addToepoint;
  49119. /**
  49120. * Babylon reference to the earcut plugin.
  49121. */
  49122. bjsEarcut: any;
  49123. /**
  49124. * Creates a PolygonMeshBuilder
  49125. * @param name name of the builder
  49126. * @param contours Path of the polygon
  49127. * @param scene scene to add to when creating the mesh
  49128. * @param earcutInjection can be used to inject your own earcut reference
  49129. */
  49130. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  49131. /**
  49132. * Adds a whole within the polygon
  49133. * @param hole Array of points defining the hole
  49134. * @returns this
  49135. */
  49136. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49137. /**
  49138. * Creates the polygon
  49139. * @param updatable If the mesh should be updatable
  49140. * @param depth The depth of the mesh created
  49141. * @returns the created mesh
  49142. */
  49143. build(updatable?: boolean, depth?: number): Mesh;
  49144. /**
  49145. * Creates the polygon
  49146. * @param depth The depth of the mesh created
  49147. * @returns the created VertexData
  49148. */
  49149. buildVertexData(depth?: number): VertexData;
  49150. /**
  49151. * Adds a side to the polygon
  49152. * @param positions points that make the polygon
  49153. * @param normals normals of the polygon
  49154. * @param uvs uvs of the polygon
  49155. * @param indices indices of the polygon
  49156. * @param bounds bounds of the polygon
  49157. * @param points points of the polygon
  49158. * @param depth depth of the polygon
  49159. * @param flip flip of the polygon
  49160. */
  49161. private addSide;
  49162. }
  49163. }
  49164. declare module BABYLON {
  49165. /**
  49166. * Class containing static functions to help procedurally build meshes
  49167. */
  49168. export class PolygonBuilder {
  49169. /**
  49170. * Creates a polygon mesh
  49171. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49172. * * 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
  49173. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49175. * * 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)
  49176. * * Remember you can only change the shape positions, not their number when updating a polygon
  49177. * @param name defines the name of the mesh
  49178. * @param options defines the options used to create the mesh
  49179. * @param scene defines the hosting scene
  49180. * @param earcutInjection can be used to inject your own earcut reference
  49181. * @returns the polygon mesh
  49182. */
  49183. static CreatePolygon(name: string, options: {
  49184. shape: Vector3[];
  49185. holes?: Vector3[][];
  49186. depth?: number;
  49187. faceUV?: Vector4[];
  49188. faceColors?: Color4[];
  49189. updatable?: boolean;
  49190. sideOrientation?: number;
  49191. frontUVs?: Vector4;
  49192. backUVs?: Vector4;
  49193. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49194. /**
  49195. * Creates an extruded polygon mesh, with depth in the Y direction.
  49196. * * 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)
  49197. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49198. * @param name defines the name of the mesh
  49199. * @param options defines the options used to create the mesh
  49200. * @param scene defines the hosting scene
  49201. * @param earcutInjection can be used to inject your own earcut reference
  49202. * @returns the polygon mesh
  49203. */
  49204. static ExtrudePolygon(name: string, options: {
  49205. shape: Vector3[];
  49206. holes?: Vector3[][];
  49207. depth?: number;
  49208. faceUV?: Vector4[];
  49209. faceColors?: Color4[];
  49210. updatable?: boolean;
  49211. sideOrientation?: number;
  49212. frontUVs?: Vector4;
  49213. backUVs?: Vector4;
  49214. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49215. }
  49216. }
  49217. declare module BABYLON {
  49218. /**
  49219. * Class containing static functions to help procedurally build meshes
  49220. */
  49221. export class LatheBuilder {
  49222. /**
  49223. * Creates lathe mesh.
  49224. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49225. * * 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
  49226. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49227. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49228. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49229. * * 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
  49230. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49231. * * 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
  49232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49233. * * 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
  49234. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49236. * @param name defines the name of the mesh
  49237. * @param options defines the options used to create the mesh
  49238. * @param scene defines the hosting scene
  49239. * @returns the lathe mesh
  49240. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49241. */
  49242. static CreateLathe(name: string, options: {
  49243. shape: Vector3[];
  49244. radius?: number;
  49245. tessellation?: number;
  49246. clip?: number;
  49247. arc?: number;
  49248. closed?: boolean;
  49249. updatable?: boolean;
  49250. sideOrientation?: number;
  49251. frontUVs?: Vector4;
  49252. backUVs?: Vector4;
  49253. cap?: number;
  49254. invertUV?: boolean;
  49255. }, scene?: Nullable<Scene>): Mesh;
  49256. }
  49257. }
  49258. declare module BABYLON {
  49259. /**
  49260. * Class containing static functions to help procedurally build meshes
  49261. */
  49262. export class TubeBuilder {
  49263. /**
  49264. * Creates a tube mesh.
  49265. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49266. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49267. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49268. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49269. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49270. * * 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)
  49271. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49272. * * 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
  49273. * * 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
  49274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49275. * * 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
  49276. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49278. * @param name defines the name of the mesh
  49279. * @param options defines the options used to create the mesh
  49280. * @param scene defines the hosting scene
  49281. * @returns the tube mesh
  49282. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49283. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49284. */
  49285. static CreateTube(name: string, options: {
  49286. path: Vector3[];
  49287. radius?: number;
  49288. tessellation?: number;
  49289. radiusFunction?: {
  49290. (i: number, distance: number): number;
  49291. };
  49292. cap?: number;
  49293. arc?: number;
  49294. updatable?: boolean;
  49295. sideOrientation?: number;
  49296. frontUVs?: Vector4;
  49297. backUVs?: Vector4;
  49298. instance?: Mesh;
  49299. invertUV?: boolean;
  49300. }, scene?: Nullable<Scene>): Mesh;
  49301. }
  49302. }
  49303. declare module BABYLON {
  49304. /**
  49305. * Class containing static functions to help procedurally build meshes
  49306. */
  49307. export class IcoSphereBuilder {
  49308. /**
  49309. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49310. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49311. * * 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`)
  49312. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49313. * * 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
  49314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49315. * * 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
  49316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49317. * @param name defines the name of the mesh
  49318. * @param options defines the options used to create the mesh
  49319. * @param scene defines the hosting scene
  49320. * @returns the icosahedron mesh
  49321. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49322. */
  49323. static CreateIcoSphere(name: string, options: {
  49324. radius?: number;
  49325. radiusX?: number;
  49326. radiusY?: number;
  49327. radiusZ?: number;
  49328. flat?: boolean;
  49329. subdivisions?: number;
  49330. sideOrientation?: number;
  49331. frontUVs?: Vector4;
  49332. backUVs?: Vector4;
  49333. updatable?: boolean;
  49334. }, scene?: Nullable<Scene>): Mesh;
  49335. }
  49336. }
  49337. declare module BABYLON {
  49338. /**
  49339. * Class containing static functions to help procedurally build meshes
  49340. */
  49341. export class DecalBuilder {
  49342. /**
  49343. * Creates a decal mesh.
  49344. * 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
  49345. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49346. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49347. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49348. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49349. * @param name defines the name of the mesh
  49350. * @param sourceMesh defines the mesh where the decal must be applied
  49351. * @param options defines the options used to create the mesh
  49352. * @param scene defines the hosting scene
  49353. * @returns the decal mesh
  49354. * @see https://doc.babylonjs.com/how_to/decals
  49355. */
  49356. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49357. position?: Vector3;
  49358. normal?: Vector3;
  49359. size?: Vector3;
  49360. angle?: number;
  49361. }): Mesh;
  49362. }
  49363. }
  49364. declare module BABYLON {
  49365. /**
  49366. * Class containing static functions to help procedurally build meshes
  49367. */
  49368. export class MeshBuilder {
  49369. /**
  49370. * Creates a box mesh
  49371. * * The parameter `size` sets the size (float) of each box side (default 1)
  49372. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49373. * * 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)
  49374. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49376. * * 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
  49377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49378. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49379. * @param name defines the name of the mesh
  49380. * @param options defines the options used to create the mesh
  49381. * @param scene defines the hosting scene
  49382. * @returns the box mesh
  49383. */
  49384. static CreateBox(name: string, options: {
  49385. size?: number;
  49386. width?: number;
  49387. height?: number;
  49388. depth?: number;
  49389. faceUV?: Vector4[];
  49390. faceColors?: Color4[];
  49391. sideOrientation?: number;
  49392. frontUVs?: Vector4;
  49393. backUVs?: Vector4;
  49394. updatable?: boolean;
  49395. }, scene?: Nullable<Scene>): Mesh;
  49396. /**
  49397. * Creates a sphere mesh
  49398. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49399. * * 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`)
  49400. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49401. * * 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
  49402. * * 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)
  49403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49404. * * 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
  49405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49406. * @param name defines the name of the mesh
  49407. * @param options defines the options used to create the mesh
  49408. * @param scene defines the hosting scene
  49409. * @returns the sphere mesh
  49410. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49411. */
  49412. static CreateSphere(name: string, options: {
  49413. segments?: number;
  49414. diameter?: number;
  49415. diameterX?: number;
  49416. diameterY?: number;
  49417. diameterZ?: number;
  49418. arc?: number;
  49419. slice?: number;
  49420. sideOrientation?: number;
  49421. frontUVs?: Vector4;
  49422. backUVs?: Vector4;
  49423. updatable?: boolean;
  49424. }, scene?: Nullable<Scene>): Mesh;
  49425. /**
  49426. * Creates a plane polygonal mesh. By default, this is a disc
  49427. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49428. * * 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
  49429. * * 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
  49430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49431. * * 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
  49432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49433. * @param name defines the name of the mesh
  49434. * @param options defines the options used to create the mesh
  49435. * @param scene defines the hosting scene
  49436. * @returns the plane polygonal mesh
  49437. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49438. */
  49439. static CreateDisc(name: string, options: {
  49440. radius?: number;
  49441. tessellation?: number;
  49442. arc?: number;
  49443. updatable?: boolean;
  49444. sideOrientation?: number;
  49445. frontUVs?: Vector4;
  49446. backUVs?: Vector4;
  49447. }, scene?: Nullable<Scene>): Mesh;
  49448. /**
  49449. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49450. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49451. * * 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`)
  49452. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49453. * * 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
  49454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49455. * * 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
  49456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49457. * @param name defines the name of the mesh
  49458. * @param options defines the options used to create the mesh
  49459. * @param scene defines the hosting scene
  49460. * @returns the icosahedron mesh
  49461. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49462. */
  49463. static CreateIcoSphere(name: string, options: {
  49464. radius?: number;
  49465. radiusX?: number;
  49466. radiusY?: number;
  49467. radiusZ?: number;
  49468. flat?: boolean;
  49469. subdivisions?: number;
  49470. sideOrientation?: number;
  49471. frontUVs?: Vector4;
  49472. backUVs?: Vector4;
  49473. updatable?: boolean;
  49474. }, scene?: Nullable<Scene>): Mesh;
  49475. /**
  49476. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49477. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49478. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49479. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49480. * * 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
  49481. * * 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
  49482. * * 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
  49483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49484. * * 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
  49485. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49486. * * 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
  49487. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49488. * * 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
  49489. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49491. * @param name defines the name of the mesh
  49492. * @param options defines the options used to create the mesh
  49493. * @param scene defines the hosting scene
  49494. * @returns the ribbon mesh
  49495. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49497. */
  49498. static CreateRibbon(name: string, options: {
  49499. pathArray: Vector3[][];
  49500. closeArray?: boolean;
  49501. closePath?: boolean;
  49502. offset?: number;
  49503. updatable?: boolean;
  49504. sideOrientation?: number;
  49505. frontUVs?: Vector4;
  49506. backUVs?: Vector4;
  49507. instance?: Mesh;
  49508. invertUV?: boolean;
  49509. uvs?: Vector2[];
  49510. colors?: Color4[];
  49511. }, scene?: Nullable<Scene>): Mesh;
  49512. /**
  49513. * Creates a cylinder or a cone mesh
  49514. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49515. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49516. * * 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.
  49517. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49518. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49519. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49520. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49521. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49522. * * 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).
  49523. * * 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
  49524. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49525. * * 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
  49526. * * 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.
  49527. * * If `enclose` is false, a ring surface is one element.
  49528. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49529. * * 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
  49530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49531. * * 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
  49532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49533. * @param name defines the name of the mesh
  49534. * @param options defines the options used to create the mesh
  49535. * @param scene defines the hosting scene
  49536. * @returns the cylinder mesh
  49537. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49538. */
  49539. static CreateCylinder(name: string, options: {
  49540. height?: number;
  49541. diameterTop?: number;
  49542. diameterBottom?: number;
  49543. diameter?: number;
  49544. tessellation?: number;
  49545. subdivisions?: number;
  49546. arc?: number;
  49547. faceColors?: Color4[];
  49548. faceUV?: Vector4[];
  49549. updatable?: boolean;
  49550. hasRings?: boolean;
  49551. enclose?: boolean;
  49552. sideOrientation?: number;
  49553. frontUVs?: Vector4;
  49554. backUVs?: Vector4;
  49555. }, scene?: Nullable<Scene>): Mesh;
  49556. /**
  49557. * Creates a torus mesh
  49558. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49559. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49560. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49562. * * 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
  49563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49564. * @param name defines the name of the mesh
  49565. * @param options defines the options used to create the mesh
  49566. * @param scene defines the hosting scene
  49567. * @returns the torus mesh
  49568. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49569. */
  49570. static CreateTorus(name: string, options: {
  49571. diameter?: number;
  49572. thickness?: number;
  49573. tessellation?: number;
  49574. updatable?: boolean;
  49575. sideOrientation?: number;
  49576. frontUVs?: Vector4;
  49577. backUVs?: Vector4;
  49578. }, scene?: Nullable<Scene>): Mesh;
  49579. /**
  49580. * Creates a torus knot mesh
  49581. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49582. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49583. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49584. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49586. * * 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
  49587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49588. * @param name defines the name of the mesh
  49589. * @param options defines the options used to create the mesh
  49590. * @param scene defines the hosting scene
  49591. * @returns the torus knot mesh
  49592. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49593. */
  49594. static CreateTorusKnot(name: string, options: {
  49595. radius?: number;
  49596. tube?: number;
  49597. radialSegments?: number;
  49598. tubularSegments?: number;
  49599. p?: number;
  49600. q?: number;
  49601. updatable?: boolean;
  49602. sideOrientation?: number;
  49603. frontUVs?: Vector4;
  49604. backUVs?: Vector4;
  49605. }, scene?: Nullable<Scene>): Mesh;
  49606. /**
  49607. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49608. * * 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
  49609. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49610. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49611. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49612. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49613. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49614. * * 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
  49615. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49618. * @param name defines the name of the new line system
  49619. * @param options defines the options used to create the line system
  49620. * @param scene defines the hosting scene
  49621. * @returns a new line system mesh
  49622. */
  49623. static CreateLineSystem(name: string, options: {
  49624. lines: Vector3[][];
  49625. updatable?: boolean;
  49626. instance?: Nullable<LinesMesh>;
  49627. colors?: Nullable<Color4[][]>;
  49628. useVertexAlpha?: boolean;
  49629. }, scene: Nullable<Scene>): LinesMesh;
  49630. /**
  49631. * Creates a line mesh
  49632. * 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
  49633. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49634. * * The parameter `points` is an array successive Vector3
  49635. * * 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
  49636. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49637. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49638. * * When updating an instance, remember that only point positions can change, not the number of points
  49639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49641. * @param name defines the name of the new line system
  49642. * @param options defines the options used to create the line system
  49643. * @param scene defines the hosting scene
  49644. * @returns a new line mesh
  49645. */
  49646. static CreateLines(name: string, options: {
  49647. points: Vector3[];
  49648. updatable?: boolean;
  49649. instance?: Nullable<LinesMesh>;
  49650. colors?: Color4[];
  49651. useVertexAlpha?: boolean;
  49652. }, scene?: Nullable<Scene>): LinesMesh;
  49653. /**
  49654. * Creates a dashed line mesh
  49655. * * 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
  49656. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49657. * * The parameter `points` is an array successive Vector3
  49658. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49659. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49660. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49661. * * 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
  49662. * * When updating an instance, remember that only point positions can change, not the number of points
  49663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49664. * @param name defines the name of the mesh
  49665. * @param options defines the options used to create the mesh
  49666. * @param scene defines the hosting scene
  49667. * @returns the dashed line mesh
  49668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49669. */
  49670. static CreateDashedLines(name: string, options: {
  49671. points: Vector3[];
  49672. dashSize?: number;
  49673. gapSize?: number;
  49674. dashNb?: number;
  49675. updatable?: boolean;
  49676. instance?: LinesMesh;
  49677. }, scene?: Nullable<Scene>): LinesMesh;
  49678. /**
  49679. * 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.
  49680. * * 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.
  49681. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49682. * * 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.
  49683. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49684. * * 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
  49685. * * 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
  49686. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49688. * * 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
  49689. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49691. * @param name defines the name of the mesh
  49692. * @param options defines the options used to create the mesh
  49693. * @param scene defines the hosting scene
  49694. * @returns the extruded shape mesh
  49695. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49697. */
  49698. static ExtrudeShape(name: string, options: {
  49699. shape: Vector3[];
  49700. path: Vector3[];
  49701. scale?: number;
  49702. rotation?: number;
  49703. cap?: number;
  49704. updatable?: boolean;
  49705. sideOrientation?: number;
  49706. frontUVs?: Vector4;
  49707. backUVs?: Vector4;
  49708. instance?: Mesh;
  49709. invertUV?: boolean;
  49710. }, scene?: Nullable<Scene>): Mesh;
  49711. /**
  49712. * Creates an custom extruded shape mesh.
  49713. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49714. * * 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.
  49715. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49716. * * 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
  49717. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49718. * * 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
  49719. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49720. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49721. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49722. * * 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
  49723. * * 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
  49724. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49726. * * 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
  49727. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49729. * @param name defines the name of the mesh
  49730. * @param options defines the options used to create the mesh
  49731. * @param scene defines the hosting scene
  49732. * @returns the custom extruded shape mesh
  49733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49734. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49736. */
  49737. static ExtrudeShapeCustom(name: string, options: {
  49738. shape: Vector3[];
  49739. path: Vector3[];
  49740. scaleFunction?: any;
  49741. rotationFunction?: any;
  49742. ribbonCloseArray?: boolean;
  49743. ribbonClosePath?: boolean;
  49744. cap?: number;
  49745. updatable?: boolean;
  49746. sideOrientation?: number;
  49747. frontUVs?: Vector4;
  49748. backUVs?: Vector4;
  49749. instance?: Mesh;
  49750. invertUV?: boolean;
  49751. }, scene?: Nullable<Scene>): Mesh;
  49752. /**
  49753. * Creates lathe mesh.
  49754. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49755. * * 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
  49756. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49757. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49758. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49759. * * 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
  49760. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49761. * * 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
  49762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49763. * * 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
  49764. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49766. * @param name defines the name of the mesh
  49767. * @param options defines the options used to create the mesh
  49768. * @param scene defines the hosting scene
  49769. * @returns the lathe mesh
  49770. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49771. */
  49772. static CreateLathe(name: string, options: {
  49773. shape: Vector3[];
  49774. radius?: number;
  49775. tessellation?: number;
  49776. clip?: number;
  49777. arc?: number;
  49778. closed?: boolean;
  49779. updatable?: boolean;
  49780. sideOrientation?: number;
  49781. frontUVs?: Vector4;
  49782. backUVs?: Vector4;
  49783. cap?: number;
  49784. invertUV?: boolean;
  49785. }, scene?: Nullable<Scene>): Mesh;
  49786. /**
  49787. * Creates a plane mesh
  49788. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49789. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49790. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49792. * * 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
  49793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49794. * @param name defines the name of the mesh
  49795. * @param options defines the options used to create the mesh
  49796. * @param scene defines the hosting scene
  49797. * @returns the plane mesh
  49798. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49799. */
  49800. static CreatePlane(name: string, options: {
  49801. size?: number;
  49802. width?: number;
  49803. height?: number;
  49804. sideOrientation?: number;
  49805. frontUVs?: Vector4;
  49806. backUVs?: Vector4;
  49807. updatable?: boolean;
  49808. sourcePlane?: Plane;
  49809. }, scene?: Nullable<Scene>): Mesh;
  49810. /**
  49811. * Creates a ground mesh
  49812. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49813. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49815. * @param name defines the name of the mesh
  49816. * @param options defines the options used to create the mesh
  49817. * @param scene defines the hosting scene
  49818. * @returns the ground mesh
  49819. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49820. */
  49821. static CreateGround(name: string, options: {
  49822. width?: number;
  49823. height?: number;
  49824. subdivisions?: number;
  49825. subdivisionsX?: number;
  49826. subdivisionsY?: number;
  49827. updatable?: boolean;
  49828. }, scene?: Nullable<Scene>): Mesh;
  49829. /**
  49830. * Creates a tiled ground mesh
  49831. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49832. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49833. * * 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
  49834. * * 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
  49835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49836. * @param name defines the name of the mesh
  49837. * @param options defines the options used to create the mesh
  49838. * @param scene defines the hosting scene
  49839. * @returns the tiled ground mesh
  49840. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49841. */
  49842. static CreateTiledGround(name: string, options: {
  49843. xmin: number;
  49844. zmin: number;
  49845. xmax: number;
  49846. zmax: number;
  49847. subdivisions?: {
  49848. w: number;
  49849. h: number;
  49850. };
  49851. precision?: {
  49852. w: number;
  49853. h: number;
  49854. };
  49855. updatable?: boolean;
  49856. }, scene?: Nullable<Scene>): Mesh;
  49857. /**
  49858. * Creates a ground mesh from a height map
  49859. * * The parameter `url` sets the URL of the height map image resource.
  49860. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49861. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49862. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49863. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49864. * * 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.
  49865. * * 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).
  49866. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49868. * @param name defines the name of the mesh
  49869. * @param url defines the url to the height map
  49870. * @param options defines the options used to create the mesh
  49871. * @param scene defines the hosting scene
  49872. * @returns the ground mesh
  49873. * @see https://doc.babylonjs.com/babylon101/height_map
  49874. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49875. */
  49876. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49877. width?: number;
  49878. height?: number;
  49879. subdivisions?: number;
  49880. minHeight?: number;
  49881. maxHeight?: number;
  49882. colorFilter?: Color3;
  49883. alphaFilter?: number;
  49884. updatable?: boolean;
  49885. onReady?: (mesh: GroundMesh) => void;
  49886. }, scene?: Nullable<Scene>): GroundMesh;
  49887. /**
  49888. * Creates a polygon mesh
  49889. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49890. * * 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
  49891. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49893. * * 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)
  49894. * * Remember you can only change the shape positions, not their number when updating a polygon
  49895. * @param name defines the name of the mesh
  49896. * @param options defines the options used to create the mesh
  49897. * @param scene defines the hosting scene
  49898. * @param earcutInjection can be used to inject your own earcut reference
  49899. * @returns the polygon mesh
  49900. */
  49901. static CreatePolygon(name: string, options: {
  49902. shape: Vector3[];
  49903. holes?: Vector3[][];
  49904. depth?: number;
  49905. faceUV?: Vector4[];
  49906. faceColors?: Color4[];
  49907. updatable?: boolean;
  49908. sideOrientation?: number;
  49909. frontUVs?: Vector4;
  49910. backUVs?: Vector4;
  49911. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49912. /**
  49913. * Creates an extruded polygon mesh, with depth in the Y direction.
  49914. * * 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)
  49915. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49916. * @param name defines the name of the mesh
  49917. * @param options defines the options used to create the mesh
  49918. * @param scene defines the hosting scene
  49919. * @param earcutInjection can be used to inject your own earcut reference
  49920. * @returns the polygon mesh
  49921. */
  49922. static ExtrudePolygon(name: string, options: {
  49923. shape: Vector3[];
  49924. holes?: Vector3[][];
  49925. depth?: number;
  49926. faceUV?: Vector4[];
  49927. faceColors?: Color4[];
  49928. updatable?: boolean;
  49929. sideOrientation?: number;
  49930. frontUVs?: Vector4;
  49931. backUVs?: Vector4;
  49932. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49933. /**
  49934. * Creates a tube mesh.
  49935. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49936. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49937. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49938. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49939. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49940. * * 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)
  49941. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49942. * * 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
  49943. * * 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
  49944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49945. * * 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
  49946. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49948. * @param name defines the name of the mesh
  49949. * @param options defines the options used to create the mesh
  49950. * @param scene defines the hosting scene
  49951. * @returns the tube mesh
  49952. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49953. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49954. */
  49955. static CreateTube(name: string, options: {
  49956. path: Vector3[];
  49957. radius?: number;
  49958. tessellation?: number;
  49959. radiusFunction?: {
  49960. (i: number, distance: number): number;
  49961. };
  49962. cap?: number;
  49963. arc?: number;
  49964. updatable?: boolean;
  49965. sideOrientation?: number;
  49966. frontUVs?: Vector4;
  49967. backUVs?: Vector4;
  49968. instance?: Mesh;
  49969. invertUV?: boolean;
  49970. }, scene?: Nullable<Scene>): Mesh;
  49971. /**
  49972. * Creates a polyhedron mesh
  49973. * * 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
  49974. * * The parameter `size` (positive float, default 1) sets the polygon size
  49975. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49976. * * 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`
  49977. * * 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
  49978. * * 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)`)
  49979. * * 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
  49980. * * 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
  49981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49982. * * 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
  49983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49984. * @param name defines the name of the mesh
  49985. * @param options defines the options used to create the mesh
  49986. * @param scene defines the hosting scene
  49987. * @returns the polyhedron mesh
  49988. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49989. */
  49990. static CreatePolyhedron(name: string, options: {
  49991. type?: number;
  49992. size?: number;
  49993. sizeX?: number;
  49994. sizeY?: number;
  49995. sizeZ?: number;
  49996. custom?: any;
  49997. faceUV?: Vector4[];
  49998. faceColors?: Color4[];
  49999. flat?: boolean;
  50000. updatable?: boolean;
  50001. sideOrientation?: number;
  50002. frontUVs?: Vector4;
  50003. backUVs?: Vector4;
  50004. }, scene?: Nullable<Scene>): Mesh;
  50005. /**
  50006. * Creates a decal mesh.
  50007. * 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
  50008. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50009. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50010. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50011. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50012. * @param name defines the name of the mesh
  50013. * @param sourceMesh defines the mesh where the decal must be applied
  50014. * @param options defines the options used to create the mesh
  50015. * @param scene defines the hosting scene
  50016. * @returns the decal mesh
  50017. * @see https://doc.babylonjs.com/how_to/decals
  50018. */
  50019. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50020. position?: Vector3;
  50021. normal?: Vector3;
  50022. size?: Vector3;
  50023. angle?: number;
  50024. }): Mesh;
  50025. }
  50026. }
  50027. declare module BABYLON {
  50028. /**
  50029. * A simplifier interface for future simplification implementations
  50030. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50031. */
  50032. export interface ISimplifier {
  50033. /**
  50034. * Simplification of a given mesh according to the given settings.
  50035. * Since this requires computation, it is assumed that the function runs async.
  50036. * @param settings The settings of the simplification, including quality and distance
  50037. * @param successCallback A callback that will be called after the mesh was simplified.
  50038. * @param errorCallback in case of an error, this callback will be called. optional.
  50039. */
  50040. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50041. }
  50042. /**
  50043. * Expected simplification settings.
  50044. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50045. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50046. */
  50047. export interface ISimplificationSettings {
  50048. /**
  50049. * Gets or sets the expected quality
  50050. */
  50051. quality: number;
  50052. /**
  50053. * Gets or sets the distance when this optimized version should be used
  50054. */
  50055. distance: number;
  50056. /**
  50057. * Gets an already optimized mesh
  50058. */
  50059. optimizeMesh?: boolean;
  50060. }
  50061. /**
  50062. * Class used to specify simplification options
  50063. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50064. */
  50065. export class SimplificationSettings implements ISimplificationSettings {
  50066. /** expected quality */
  50067. quality: number;
  50068. /** distance when this optimized version should be used */
  50069. distance: number;
  50070. /** already optimized mesh */
  50071. optimizeMesh?: boolean | undefined;
  50072. /**
  50073. * Creates a SimplificationSettings
  50074. * @param quality expected quality
  50075. * @param distance distance when this optimized version should be used
  50076. * @param optimizeMesh already optimized mesh
  50077. */
  50078. constructor(
  50079. /** expected quality */
  50080. quality: number,
  50081. /** distance when this optimized version should be used */
  50082. distance: number,
  50083. /** already optimized mesh */
  50084. optimizeMesh?: boolean | undefined);
  50085. }
  50086. /**
  50087. * Interface used to define a simplification task
  50088. */
  50089. export interface ISimplificationTask {
  50090. /**
  50091. * Array of settings
  50092. */
  50093. settings: Array<ISimplificationSettings>;
  50094. /**
  50095. * Simplification type
  50096. */
  50097. simplificationType: SimplificationType;
  50098. /**
  50099. * Mesh to simplify
  50100. */
  50101. mesh: Mesh;
  50102. /**
  50103. * Callback called on success
  50104. */
  50105. successCallback?: () => void;
  50106. /**
  50107. * Defines if parallel processing can be used
  50108. */
  50109. parallelProcessing: boolean;
  50110. }
  50111. /**
  50112. * Queue used to order the simplification tasks
  50113. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50114. */
  50115. export class SimplificationQueue {
  50116. private _simplificationArray;
  50117. /**
  50118. * Gets a boolean indicating that the process is still running
  50119. */
  50120. running: boolean;
  50121. /**
  50122. * Creates a new queue
  50123. */
  50124. constructor();
  50125. /**
  50126. * Adds a new simplification task
  50127. * @param task defines a task to add
  50128. */
  50129. addTask(task: ISimplificationTask): void;
  50130. /**
  50131. * Execute next task
  50132. */
  50133. executeNext(): void;
  50134. /**
  50135. * Execute a simplification task
  50136. * @param task defines the task to run
  50137. */
  50138. runSimplification(task: ISimplificationTask): void;
  50139. private getSimplifier;
  50140. }
  50141. /**
  50142. * The implemented types of simplification
  50143. * At the moment only Quadratic Error Decimation is implemented
  50144. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50145. */
  50146. export enum SimplificationType {
  50147. /** Quadratic error decimation */
  50148. QUADRATIC = 0
  50149. }
  50150. }
  50151. declare module BABYLON {
  50152. interface Scene {
  50153. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  50154. /**
  50155. * Gets or sets the simplification queue attached to the scene
  50156. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50157. */
  50158. simplificationQueue: SimplificationQueue;
  50159. }
  50160. interface Mesh {
  50161. /**
  50162. * Simplify the mesh according to the given array of settings.
  50163. * Function will return immediately and will simplify async
  50164. * @param settings a collection of simplification settings
  50165. * @param parallelProcessing should all levels calculate parallel or one after the other
  50166. * @param simplificationType the type of simplification to run
  50167. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50168. * @returns the current mesh
  50169. */
  50170. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50171. }
  50172. /**
  50173. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50174. * created in a scene
  50175. */
  50176. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50177. /**
  50178. * The component name helpfull to identify the component in the list of scene components.
  50179. */
  50180. readonly name: string;
  50181. /**
  50182. * The scene the component belongs to.
  50183. */
  50184. scene: Scene;
  50185. /**
  50186. * Creates a new instance of the component for the given scene
  50187. * @param scene Defines the scene to register the component in
  50188. */
  50189. constructor(scene: Scene);
  50190. /**
  50191. * Registers the component in a given scene
  50192. */
  50193. register(): void;
  50194. /**
  50195. * Rebuilds the elements related to this component in case of
  50196. * context lost for instance.
  50197. */
  50198. rebuild(): void;
  50199. /**
  50200. * Disposes the component and the associated ressources
  50201. */
  50202. dispose(): void;
  50203. private _beforeCameraUpdate;
  50204. }
  50205. }
  50206. declare module BABYLON {
  50207. /**
  50208. * Class used to enable access to IndexedDB
  50209. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50210. */
  50211. export class Database implements IOfflineProvider {
  50212. private _callbackManifestChecked;
  50213. private _currentSceneUrl;
  50214. private _db;
  50215. private _enableSceneOffline;
  50216. private _enableTexturesOffline;
  50217. private _manifestVersionFound;
  50218. private _mustUpdateRessources;
  50219. private _hasReachedQuota;
  50220. private _isSupported;
  50221. private _idbFactory;
  50222. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50223. private static IsUASupportingBlobStorage;
  50224. /**
  50225. * Gets a boolean indicating if Database storate is enabled (off by default)
  50226. */
  50227. static IDBStorageEnabled: boolean;
  50228. /**
  50229. * Gets a boolean indicating if scene must be saved in the database
  50230. */
  50231. readonly enableSceneOffline: boolean;
  50232. /**
  50233. * Gets a boolean indicating if textures must be saved in the database
  50234. */
  50235. readonly enableTexturesOffline: boolean;
  50236. /**
  50237. * Creates a new Database
  50238. * @param urlToScene defines the url to load the scene
  50239. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50240. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50241. */
  50242. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50243. private static _ParseURL;
  50244. private static _ReturnFullUrlLocation;
  50245. private _checkManifestFile;
  50246. /**
  50247. * Open the database and make it available
  50248. * @param successCallback defines the callback to call on success
  50249. * @param errorCallback defines the callback to call on error
  50250. */
  50251. open(successCallback: () => void, errorCallback: () => void): void;
  50252. /**
  50253. * Loads an image from the database
  50254. * @param url defines the url to load from
  50255. * @param image defines the target DOM image
  50256. */
  50257. loadImage(url: string, image: HTMLImageElement): void;
  50258. private _loadImageFromDBAsync;
  50259. private _saveImageIntoDBAsync;
  50260. private _checkVersionFromDB;
  50261. private _loadVersionFromDBAsync;
  50262. private _saveVersionIntoDBAsync;
  50263. /**
  50264. * Loads a file from database
  50265. * @param url defines the URL to load from
  50266. * @param sceneLoaded defines a callback to call on success
  50267. * @param progressCallBack defines a callback to call when progress changed
  50268. * @param errorCallback defines a callback to call on error
  50269. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50270. */
  50271. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50272. private _loadFileAsync;
  50273. private _saveFileAsync;
  50274. /**
  50275. * Validates if xhr data is correct
  50276. * @param xhr defines the request to validate
  50277. * @param dataType defines the expected data type
  50278. * @returns true if data is correct
  50279. */
  50280. private static _ValidateXHRData;
  50281. }
  50282. }
  50283. declare module BABYLON {
  50284. /** @hidden */
  50285. export var gpuUpdateParticlesPixelShader: {
  50286. name: string;
  50287. shader: string;
  50288. };
  50289. }
  50290. declare module BABYLON {
  50291. /** @hidden */
  50292. export var gpuUpdateParticlesVertexShader: {
  50293. name: string;
  50294. shader: string;
  50295. };
  50296. }
  50297. declare module BABYLON {
  50298. /** @hidden */
  50299. export var clipPlaneFragmentDeclaration2: {
  50300. name: string;
  50301. shader: string;
  50302. };
  50303. }
  50304. declare module BABYLON {
  50305. /** @hidden */
  50306. export var gpuRenderParticlesPixelShader: {
  50307. name: string;
  50308. shader: string;
  50309. };
  50310. }
  50311. declare module BABYLON {
  50312. /** @hidden */
  50313. export var clipPlaneVertexDeclaration2: {
  50314. name: string;
  50315. shader: string;
  50316. };
  50317. }
  50318. declare module BABYLON {
  50319. /** @hidden */
  50320. export var gpuRenderParticlesVertexShader: {
  50321. name: string;
  50322. shader: string;
  50323. };
  50324. }
  50325. declare module BABYLON {
  50326. /**
  50327. * This represents a GPU particle system in Babylon
  50328. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50329. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50330. */
  50331. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50332. /**
  50333. * The layer mask we are rendering the particles through.
  50334. */
  50335. layerMask: number;
  50336. private _capacity;
  50337. private _activeCount;
  50338. private _currentActiveCount;
  50339. private _accumulatedCount;
  50340. private _renderEffect;
  50341. private _updateEffect;
  50342. private _buffer0;
  50343. private _buffer1;
  50344. private _spriteBuffer;
  50345. private _updateVAO;
  50346. private _renderVAO;
  50347. private _targetIndex;
  50348. private _sourceBuffer;
  50349. private _targetBuffer;
  50350. private _engine;
  50351. private _currentRenderId;
  50352. private _started;
  50353. private _stopped;
  50354. private _timeDelta;
  50355. private _randomTexture;
  50356. private _randomTexture2;
  50357. private _attributesStrideSize;
  50358. private _updateEffectOptions;
  50359. private _randomTextureSize;
  50360. private _actualFrame;
  50361. private readonly _rawTextureWidth;
  50362. /**
  50363. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50364. */
  50365. static readonly IsSupported: boolean;
  50366. /**
  50367. * An event triggered when the system is disposed.
  50368. */
  50369. onDisposeObservable: Observable<GPUParticleSystem>;
  50370. /**
  50371. * Gets the maximum number of particles active at the same time.
  50372. * @returns The max number of active particles.
  50373. */
  50374. getCapacity(): number;
  50375. /**
  50376. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50377. * to override the particles.
  50378. */
  50379. forceDepthWrite: boolean;
  50380. /**
  50381. * Gets or set the number of active particles
  50382. */
  50383. activeParticleCount: number;
  50384. private _preWarmDone;
  50385. /**
  50386. * Is this system ready to be used/rendered
  50387. * @return true if the system is ready
  50388. */
  50389. isReady(): boolean;
  50390. /**
  50391. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50392. * @returns True if it has been started, otherwise false.
  50393. */
  50394. isStarted(): boolean;
  50395. /**
  50396. * Starts the particle system and begins to emit
  50397. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50398. */
  50399. start(delay?: number): void;
  50400. /**
  50401. * Stops the particle system.
  50402. */
  50403. stop(): void;
  50404. /**
  50405. * Remove all active particles
  50406. */
  50407. reset(): void;
  50408. /**
  50409. * Returns the string "GPUParticleSystem"
  50410. * @returns a string containing the class name
  50411. */
  50412. getClassName(): string;
  50413. private _colorGradientsTexture;
  50414. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50415. /**
  50416. * Adds a new color gradient
  50417. * @param gradient defines the gradient to use (between 0 and 1)
  50418. * @param color1 defines the color to affect to the specified gradient
  50419. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50420. * @returns the current particle system
  50421. */
  50422. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50423. /**
  50424. * Remove a specific color gradient
  50425. * @param gradient defines the gradient to remove
  50426. * @returns the current particle system
  50427. */
  50428. removeColorGradient(gradient: number): GPUParticleSystem;
  50429. private _angularSpeedGradientsTexture;
  50430. private _sizeGradientsTexture;
  50431. private _velocityGradientsTexture;
  50432. private _limitVelocityGradientsTexture;
  50433. private _dragGradientsTexture;
  50434. private _addFactorGradient;
  50435. /**
  50436. * Adds a new size gradient
  50437. * @param gradient defines the gradient to use (between 0 and 1)
  50438. * @param factor defines the size factor to affect to the specified gradient
  50439. * @returns the current particle system
  50440. */
  50441. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50442. /**
  50443. * Remove a specific size gradient
  50444. * @param gradient defines the gradient to remove
  50445. * @returns the current particle system
  50446. */
  50447. removeSizeGradient(gradient: number): GPUParticleSystem;
  50448. /**
  50449. * Adds a new angular speed gradient
  50450. * @param gradient defines the gradient to use (between 0 and 1)
  50451. * @param factor defines the angular speed to affect to the specified gradient
  50452. * @returns the current particle system
  50453. */
  50454. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50455. /**
  50456. * Remove a specific angular speed gradient
  50457. * @param gradient defines the gradient to remove
  50458. * @returns the current particle system
  50459. */
  50460. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50461. /**
  50462. * Adds a new velocity gradient
  50463. * @param gradient defines the gradient to use (between 0 and 1)
  50464. * @param factor defines the velocity to affect to the specified gradient
  50465. * @returns the current particle system
  50466. */
  50467. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50468. /**
  50469. * Remove a specific velocity gradient
  50470. * @param gradient defines the gradient to remove
  50471. * @returns the current particle system
  50472. */
  50473. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50474. /**
  50475. * Adds a new limit velocity gradient
  50476. * @param gradient defines the gradient to use (between 0 and 1)
  50477. * @param factor defines the limit velocity value to affect to the specified gradient
  50478. * @returns the current particle system
  50479. */
  50480. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50481. /**
  50482. * Remove a specific limit velocity gradient
  50483. * @param gradient defines the gradient to remove
  50484. * @returns the current particle system
  50485. */
  50486. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50487. /**
  50488. * Adds a new drag gradient
  50489. * @param gradient defines the gradient to use (between 0 and 1)
  50490. * @param factor defines the drag value to affect to the specified gradient
  50491. * @returns the current particle system
  50492. */
  50493. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50494. /**
  50495. * Remove a specific drag gradient
  50496. * @param gradient defines the gradient to remove
  50497. * @returns the current particle system
  50498. */
  50499. removeDragGradient(gradient: number): GPUParticleSystem;
  50500. /**
  50501. * Not supported by GPUParticleSystem
  50502. * @param gradient defines the gradient to use (between 0 and 1)
  50503. * @param factor defines the emit rate value to affect to the specified gradient
  50504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50505. * @returns the current particle system
  50506. */
  50507. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50508. /**
  50509. * Not supported by GPUParticleSystem
  50510. * @param gradient defines the gradient to remove
  50511. * @returns the current particle system
  50512. */
  50513. removeEmitRateGradient(gradient: number): IParticleSystem;
  50514. /**
  50515. * Not supported by GPUParticleSystem
  50516. * @param gradient defines the gradient to use (between 0 and 1)
  50517. * @param factor defines the start size value to affect to the specified gradient
  50518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50519. * @returns the current particle system
  50520. */
  50521. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50522. /**
  50523. * Not supported by GPUParticleSystem
  50524. * @param gradient defines the gradient to remove
  50525. * @returns the current particle system
  50526. */
  50527. removeStartSizeGradient(gradient: number): IParticleSystem;
  50528. /**
  50529. * Not supported by GPUParticleSystem
  50530. * @param gradient defines the gradient to use (between 0 and 1)
  50531. * @param min defines the color remap minimal range
  50532. * @param max defines the color remap maximal range
  50533. * @returns the current particle system
  50534. */
  50535. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50536. /**
  50537. * Not supported by GPUParticleSystem
  50538. * @param gradient defines the gradient to remove
  50539. * @returns the current particle system
  50540. */
  50541. removeColorRemapGradient(): IParticleSystem;
  50542. /**
  50543. * Not supported by GPUParticleSystem
  50544. * @param gradient defines the gradient to use (between 0 and 1)
  50545. * @param min defines the alpha remap minimal range
  50546. * @param max defines the alpha remap maximal range
  50547. * @returns the current particle system
  50548. */
  50549. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50550. /**
  50551. * Not supported by GPUParticleSystem
  50552. * @param gradient defines the gradient to remove
  50553. * @returns the current particle system
  50554. */
  50555. removeAlphaRemapGradient(): IParticleSystem;
  50556. /**
  50557. * Not supported by GPUParticleSystem
  50558. * @param gradient defines the gradient to use (between 0 and 1)
  50559. * @param color defines the color to affect to the specified gradient
  50560. * @returns the current particle system
  50561. */
  50562. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50563. /**
  50564. * Not supported by GPUParticleSystem
  50565. * @param gradient defines the gradient to remove
  50566. * @returns the current particle system
  50567. */
  50568. removeRampGradient(): IParticleSystem;
  50569. /**
  50570. * Not supported by GPUParticleSystem
  50571. * @returns the list of ramp gradients
  50572. */
  50573. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50574. /**
  50575. * Not supported by GPUParticleSystem
  50576. * Gets or sets a boolean indicating that ramp gradients must be used
  50577. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50578. */
  50579. useRampGradients: boolean;
  50580. /**
  50581. * Not supported by GPUParticleSystem
  50582. * @param gradient defines the gradient to use (between 0 and 1)
  50583. * @param factor defines the life time factor to affect to the specified gradient
  50584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50585. * @returns the current particle system
  50586. */
  50587. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50588. /**
  50589. * Not supported by GPUParticleSystem
  50590. * @param gradient defines the gradient to remove
  50591. * @returns the current particle system
  50592. */
  50593. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50594. /**
  50595. * Instantiates a GPU particle system.
  50596. * 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.
  50597. * @param name The name of the particle system
  50598. * @param options The options used to create the system
  50599. * @param scene The scene the particle system belongs to
  50600. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50601. */
  50602. constructor(name: string, options: Partial<{
  50603. capacity: number;
  50604. randomTextureSize: number;
  50605. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50606. protected _reset(): void;
  50607. private _createUpdateVAO;
  50608. private _createRenderVAO;
  50609. private _initialize;
  50610. /** @hidden */ recreateUpdateEffect(): void;
  50611. /** @hidden */ recreateRenderEffect(): void;
  50612. /**
  50613. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50614. * @param preWarm defines if we are in the pre-warmimg phase
  50615. */
  50616. animate(preWarm?: boolean): void;
  50617. private _createFactorGradientTexture;
  50618. private _createSizeGradientTexture;
  50619. private _createAngularSpeedGradientTexture;
  50620. private _createVelocityGradientTexture;
  50621. private _createLimitVelocityGradientTexture;
  50622. private _createDragGradientTexture;
  50623. private _createColorGradientTexture;
  50624. /**
  50625. * Renders the particle system in its current state
  50626. * @param preWarm defines if the system should only update the particles but not render them
  50627. * @returns the current number of particles
  50628. */
  50629. render(preWarm?: boolean): number;
  50630. /**
  50631. * Rebuilds the particle system
  50632. */
  50633. rebuild(): void;
  50634. private _releaseBuffers;
  50635. private _releaseVAOs;
  50636. /**
  50637. * Disposes the particle system and free the associated resources
  50638. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50639. */
  50640. dispose(disposeTexture?: boolean): void;
  50641. /**
  50642. * Clones the particle system.
  50643. * @param name The name of the cloned object
  50644. * @param newEmitter The new emitter to use
  50645. * @returns the cloned particle system
  50646. */
  50647. clone(name: string, newEmitter: any): GPUParticleSystem;
  50648. /**
  50649. * Serializes the particle system to a JSON object.
  50650. * @returns the JSON object
  50651. */
  50652. serialize(): any;
  50653. /**
  50654. * Parses a JSON object to create a GPU particle system.
  50655. * @param parsedParticleSystem The JSON object to parse
  50656. * @param scene The scene to create the particle system in
  50657. * @param rootUrl The root url to use to load external dependencies like texture
  50658. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50659. * @returns the parsed GPU particle system
  50660. */
  50661. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50662. }
  50663. }
  50664. declare module BABYLON {
  50665. /**
  50666. * Represents a set of particle systems working together to create a specific effect
  50667. */
  50668. export class ParticleSystemSet implements IDisposable {
  50669. private _emitterCreationOptions;
  50670. private _emitterNode;
  50671. /**
  50672. * Gets the particle system list
  50673. */
  50674. systems: IParticleSystem[];
  50675. /**
  50676. * Gets the emitter node used with this set
  50677. */
  50678. readonly emitterNode: Nullable<TransformNode>;
  50679. /**
  50680. * Creates a new emitter mesh as a sphere
  50681. * @param options defines the options used to create the sphere
  50682. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50683. * @param scene defines the hosting scene
  50684. */
  50685. setEmitterAsSphere(options: {
  50686. diameter: number;
  50687. segments: number;
  50688. color: Color3;
  50689. }, renderingGroupId: number, scene: Scene): void;
  50690. /**
  50691. * Starts all particle systems of the set
  50692. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50693. */
  50694. start(emitter?: AbstractMesh): void;
  50695. /**
  50696. * Release all associated resources
  50697. */
  50698. dispose(): void;
  50699. /**
  50700. * Serialize the set into a JSON compatible object
  50701. * @returns a JSON compatible representation of the set
  50702. */
  50703. serialize(): any;
  50704. /**
  50705. * Parse a new ParticleSystemSet from a serialized source
  50706. * @param data defines a JSON compatible representation of the set
  50707. * @param scene defines the hosting scene
  50708. * @param gpu defines if we want GPU particles or CPU particles
  50709. * @returns a new ParticleSystemSet
  50710. */
  50711. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50712. }
  50713. }
  50714. declare module BABYLON {
  50715. /**
  50716. * This class is made for on one-liner static method to help creating particle system set.
  50717. */
  50718. export class ParticleHelper {
  50719. /**
  50720. * Gets or sets base Assets URL
  50721. */
  50722. static BaseAssetsUrl: string;
  50723. /**
  50724. * Create a default particle system that you can tweak
  50725. * @param emitter defines the emitter to use
  50726. * @param capacity defines the system capacity (default is 500 particles)
  50727. * @param scene defines the hosting scene
  50728. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50729. * @returns the new Particle system
  50730. */
  50731. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50732. /**
  50733. * This is the main static method (one-liner) of this helper to create different particle systems
  50734. * @param type This string represents the type to the particle system to create
  50735. * @param scene The scene where the particle system should live
  50736. * @param gpu If the system will use gpu
  50737. * @returns the ParticleSystemSet created
  50738. */
  50739. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50740. /**
  50741. * Static function used to export a particle system to a ParticleSystemSet variable.
  50742. * Please note that the emitter shape is not exported
  50743. * @param systems defines the particle systems to export
  50744. * @returns the created particle system set
  50745. */
  50746. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50747. }
  50748. }
  50749. declare module BABYLON {
  50750. interface Engine {
  50751. /**
  50752. * Create an effect to use with particle systems.
  50753. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50754. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50755. * @param uniformsNames defines a list of attribute names
  50756. * @param samplers defines an array of string used to represent textures
  50757. * @param defines defines the string containing the defines to use to compile the shaders
  50758. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50759. * @param onCompiled defines a function to call when the effect creation is successful
  50760. * @param onError defines a function to call when the effect creation has failed
  50761. * @returns the new Effect
  50762. */
  50763. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50764. }
  50765. interface Mesh {
  50766. /**
  50767. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50768. * @returns an array of IParticleSystem
  50769. */
  50770. getEmittedParticleSystems(): IParticleSystem[];
  50771. /**
  50772. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50773. * @returns an array of IParticleSystem
  50774. */
  50775. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50776. }
  50777. /**
  50778. * @hidden
  50779. */
  50780. export var _IDoNeedToBeInTheBuild: number;
  50781. }
  50782. declare module BABYLON {
  50783. interface Scene {
  50784. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  50785. /**
  50786. * Gets the current physics engine
  50787. * @returns a IPhysicsEngine or null if none attached
  50788. */
  50789. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50790. /**
  50791. * Enables physics to the current scene
  50792. * @param gravity defines the scene's gravity for the physics engine
  50793. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50794. * @return a boolean indicating if the physics engine was initialized
  50795. */
  50796. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50797. /**
  50798. * Disables and disposes the physics engine associated with the scene
  50799. */
  50800. disablePhysicsEngine(): void;
  50801. /**
  50802. * Gets a boolean indicating if there is an active physics engine
  50803. * @returns a boolean indicating if there is an active physics engine
  50804. */
  50805. isPhysicsEnabled(): boolean;
  50806. /**
  50807. * Deletes a physics compound impostor
  50808. * @param compound defines the compound to delete
  50809. */
  50810. deleteCompoundImpostor(compound: any): void;
  50811. /**
  50812. * An event triggered when physic simulation is about to be run
  50813. */
  50814. onBeforePhysicsObservable: Observable<Scene>;
  50815. /**
  50816. * An event triggered when physic simulation has been done
  50817. */
  50818. onAfterPhysicsObservable: Observable<Scene>;
  50819. }
  50820. interface AbstractMesh {
  50821. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  50822. /**
  50823. * Gets or sets impostor used for physic simulation
  50824. * @see http://doc.babylonjs.com/features/physics_engine
  50825. */
  50826. physicsImpostor: Nullable<PhysicsImpostor>;
  50827. /**
  50828. * Gets the current physics impostor
  50829. * @see http://doc.babylonjs.com/features/physics_engine
  50830. * @returns a physics impostor or null
  50831. */
  50832. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50833. /** Apply a physic impulse to the mesh
  50834. * @param force defines the force to apply
  50835. * @param contactPoint defines where to apply the force
  50836. * @returns the current mesh
  50837. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50838. */
  50839. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50840. /**
  50841. * Creates a physic joint between two meshes
  50842. * @param otherMesh defines the other mesh to use
  50843. * @param pivot1 defines the pivot to use on this mesh
  50844. * @param pivot2 defines the pivot to use on the other mesh
  50845. * @param options defines additional options (can be plugin dependent)
  50846. * @returns the current mesh
  50847. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50848. */
  50849. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50850. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  50851. }
  50852. /**
  50853. * Defines the physics engine scene component responsible to manage a physics engine
  50854. */
  50855. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50856. /**
  50857. * The component name helpful to identify the component in the list of scene components.
  50858. */
  50859. readonly name: string;
  50860. /**
  50861. * The scene the component belongs to.
  50862. */
  50863. scene: Scene;
  50864. /**
  50865. * Creates a new instance of the component for the given scene
  50866. * @param scene Defines the scene to register the component in
  50867. */
  50868. constructor(scene: Scene);
  50869. /**
  50870. * Registers the component in a given scene
  50871. */
  50872. register(): void;
  50873. /**
  50874. * Rebuilds the elements related to this component in case of
  50875. * context lost for instance.
  50876. */
  50877. rebuild(): void;
  50878. /**
  50879. * Disposes the component and the associated ressources
  50880. */
  50881. dispose(): void;
  50882. }
  50883. }
  50884. declare module BABYLON {
  50885. /**
  50886. * A helper for physics simulations
  50887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50888. */
  50889. export class PhysicsHelper {
  50890. private _scene;
  50891. private _physicsEngine;
  50892. /**
  50893. * Initializes the Physics helper
  50894. * @param scene Babylon.js scene
  50895. */
  50896. constructor(scene: Scene);
  50897. /**
  50898. * Applies a radial explosion impulse
  50899. * @param origin the origin of the explosion
  50900. * @param radiusOrEventOptions the radius or the options of radial explosion
  50901. * @param strength the explosion strength
  50902. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50903. * @returns A physics radial explosion event, or null
  50904. */
  50905. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50906. /**
  50907. * Applies a radial explosion force
  50908. * @param origin the origin of the explosion
  50909. * @param radiusOrEventOptions the radius or the options of radial explosion
  50910. * @param strength the explosion strength
  50911. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50912. * @returns A physics radial explosion event, or null
  50913. */
  50914. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50915. /**
  50916. * Creates a gravitational field
  50917. * @param origin the origin of the explosion
  50918. * @param radiusOrEventOptions the radius or the options of radial explosion
  50919. * @param strength the explosion strength
  50920. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50921. * @returns A physics gravitational field event, or null
  50922. */
  50923. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50924. /**
  50925. * Creates a physics updraft event
  50926. * @param origin the origin of the updraft
  50927. * @param radiusOrEventOptions the radius or the options of the updraft
  50928. * @param strength the strength of the updraft
  50929. * @param height the height of the updraft
  50930. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50931. * @returns A physics updraft event, or null
  50932. */
  50933. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50934. /**
  50935. * Creates a physics vortex event
  50936. * @param origin the of the vortex
  50937. * @param radiusOrEventOptions the radius or the options of the vortex
  50938. * @param strength the strength of the vortex
  50939. * @param height the height of the vortex
  50940. * @returns a Physics vortex event, or null
  50941. * A physics vortex event or null
  50942. */
  50943. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  50944. }
  50945. /**
  50946. * Represents a physics radial explosion event
  50947. */
  50948. class PhysicsRadialExplosionEvent {
  50949. private _scene;
  50950. private _options;
  50951. private _sphere;
  50952. private _dataFetched;
  50953. /**
  50954. * Initializes a radial explosioin event
  50955. * @param _scene BabylonJS scene
  50956. * @param _options The options for the vortex event
  50957. */
  50958. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  50959. /**
  50960. * Returns the data related to the radial explosion event (sphere).
  50961. * @returns The radial explosion event data
  50962. */
  50963. getData(): PhysicsRadialExplosionEventData;
  50964. /**
  50965. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50966. * @param impostor A physics imposter
  50967. * @param origin the origin of the explosion
  50968. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  50969. */
  50970. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  50971. /**
  50972. * Triggers affecterd impostors callbacks
  50973. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  50974. */
  50975. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  50976. /**
  50977. * Disposes the sphere.
  50978. * @param force Specifies if the sphere should be disposed by force
  50979. */
  50980. dispose(force?: boolean): void;
  50981. /*** Helpers ***/
  50982. private _prepareSphere;
  50983. private _intersectsWithSphere;
  50984. }
  50985. /**
  50986. * Represents a gravitational field event
  50987. */
  50988. class PhysicsGravitationalFieldEvent {
  50989. private _physicsHelper;
  50990. private _scene;
  50991. private _origin;
  50992. private _options;
  50993. private _tickCallback;
  50994. private _sphere;
  50995. private _dataFetched;
  50996. /**
  50997. * Initializes the physics gravitational field event
  50998. * @param _physicsHelper A physics helper
  50999. * @param _scene BabylonJS scene
  51000. * @param _origin The origin position of the gravitational field event
  51001. * @param _options The options for the vortex event
  51002. */
  51003. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51004. /**
  51005. * Returns the data related to the gravitational field event (sphere).
  51006. * @returns A gravitational field event
  51007. */
  51008. getData(): PhysicsGravitationalFieldEventData;
  51009. /**
  51010. * Enables the gravitational field.
  51011. */
  51012. enable(): void;
  51013. /**
  51014. * Disables the gravitational field.
  51015. */
  51016. disable(): void;
  51017. /**
  51018. * Disposes the sphere.
  51019. * @param force The force to dispose from the gravitational field event
  51020. */
  51021. dispose(force?: boolean): void;
  51022. private _tick;
  51023. }
  51024. /**
  51025. * Represents a physics updraft event
  51026. */
  51027. class PhysicsUpdraftEvent {
  51028. private _scene;
  51029. private _origin;
  51030. private _options;
  51031. private _physicsEngine;
  51032. private _originTop;
  51033. private _originDirection;
  51034. private _tickCallback;
  51035. private _cylinder;
  51036. private _cylinderPosition;
  51037. private _dataFetched;
  51038. /**
  51039. * Initializes the physics updraft event
  51040. * @param _scene BabylonJS scene
  51041. * @param _origin The origin position of the updraft
  51042. * @param _options The options for the updraft event
  51043. */
  51044. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  51045. /**
  51046. * Returns the data related to the updraft event (cylinder).
  51047. * @returns A physics updraft event
  51048. */
  51049. getData(): PhysicsUpdraftEventData;
  51050. /**
  51051. * Enables the updraft.
  51052. */
  51053. enable(): void;
  51054. /**
  51055. * Disables the updraft.
  51056. */
  51057. disable(): void;
  51058. /**
  51059. * Disposes the cylinder.
  51060. * @param force Specifies if the updraft should be disposed by force
  51061. */
  51062. dispose(force?: boolean): void;
  51063. private getImpostorHitData;
  51064. private _tick;
  51065. /*** Helpers ***/
  51066. private _prepareCylinder;
  51067. private _intersectsWithCylinder;
  51068. }
  51069. /**
  51070. * Represents a physics vortex event
  51071. */
  51072. class PhysicsVortexEvent {
  51073. private _scene;
  51074. private _origin;
  51075. private _options;
  51076. private _physicsEngine;
  51077. private _originTop;
  51078. private _tickCallback;
  51079. private _cylinder;
  51080. private _cylinderPosition;
  51081. private _dataFetched;
  51082. /**
  51083. * Initializes the physics vortex event
  51084. * @param _scene The BabylonJS scene
  51085. * @param _origin The origin position of the vortex
  51086. * @param _options The options for the vortex event
  51087. */
  51088. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  51089. /**
  51090. * Returns the data related to the vortex event (cylinder).
  51091. * @returns The physics vortex event data
  51092. */
  51093. getData(): PhysicsVortexEventData;
  51094. /**
  51095. * Enables the vortex.
  51096. */
  51097. enable(): void;
  51098. /**
  51099. * Disables the cortex.
  51100. */
  51101. disable(): void;
  51102. /**
  51103. * Disposes the sphere.
  51104. * @param force
  51105. */
  51106. dispose(force?: boolean): void;
  51107. private getImpostorHitData;
  51108. private _tick;
  51109. /*** Helpers ***/
  51110. private _prepareCylinder;
  51111. private _intersectsWithCylinder;
  51112. }
  51113. /**
  51114. * Options fot the radial explosion event
  51115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51116. */
  51117. export class PhysicsRadialExplosionEventOptions {
  51118. /**
  51119. * The radius of the sphere for the radial explosion.
  51120. */
  51121. radius: number;
  51122. /**
  51123. * The strenth of the explosion.
  51124. */
  51125. strength: number;
  51126. /**
  51127. * The strenght of the force in correspondence to the distance of the affected object
  51128. */
  51129. falloff: PhysicsRadialImpulseFalloff;
  51130. /**
  51131. * Sphere options for the radial explosion.
  51132. */
  51133. sphere: {
  51134. segments: number;
  51135. diameter: number;
  51136. };
  51137. /**
  51138. * Sphere options for the radial explosion.
  51139. */
  51140. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  51141. }
  51142. /**
  51143. * Options fot the updraft event
  51144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51145. */
  51146. export class PhysicsUpdraftEventOptions {
  51147. /**
  51148. * The radius of the cylinder for the vortex
  51149. */
  51150. radius: number;
  51151. /**
  51152. * The strenth of the updraft.
  51153. */
  51154. strength: number;
  51155. /**
  51156. * The height of the cylinder for the updraft.
  51157. */
  51158. height: number;
  51159. /**
  51160. * The mode for the the updraft.
  51161. */
  51162. updraftMode: PhysicsUpdraftMode;
  51163. }
  51164. /**
  51165. * Options fot the vortex event
  51166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51167. */
  51168. export class PhysicsVortexEventOptions {
  51169. /**
  51170. * The radius of the cylinder for the vortex
  51171. */
  51172. radius: number;
  51173. /**
  51174. * The strenth of the vortex.
  51175. */
  51176. strength: number;
  51177. /**
  51178. * The height of the cylinder for the vortex.
  51179. */
  51180. height: number;
  51181. /**
  51182. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51183. */
  51184. centripetalForceThreshold: number;
  51185. /**
  51186. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51187. */
  51188. centripetalForceMultiplier: number;
  51189. /**
  51190. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51191. */
  51192. centrifugalForceMultiplier: number;
  51193. /**
  51194. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51195. */
  51196. updraftForceMultiplier: number;
  51197. }
  51198. /**
  51199. * The strenght of the force in correspondence to the distance of the affected object
  51200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51201. */
  51202. export enum PhysicsRadialImpulseFalloff {
  51203. /** Defines that impulse is constant in strength across it's whole radius */
  51204. Constant = 0,
  51205. /** Defines that impulse gets weaker if it's further from the origin */
  51206. Linear = 1
  51207. }
  51208. /**
  51209. * The strength of the force in correspondence to the distance of the affected object
  51210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51211. */
  51212. export enum PhysicsUpdraftMode {
  51213. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51214. Center = 0,
  51215. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51216. Perpendicular = 1
  51217. }
  51218. /**
  51219. * Interface for a physics hit data
  51220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51221. */
  51222. export interface PhysicsHitData {
  51223. /**
  51224. * The force applied at the contact point
  51225. */
  51226. force: Vector3;
  51227. /**
  51228. * The contact point
  51229. */
  51230. contactPoint: Vector3;
  51231. /**
  51232. * The distance from the origin to the contact point
  51233. */
  51234. distanceFromOrigin: number;
  51235. }
  51236. /**
  51237. * Interface for radial explosion event data
  51238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51239. */
  51240. export interface PhysicsRadialExplosionEventData {
  51241. /**
  51242. * A sphere used for the radial explosion event
  51243. */
  51244. sphere: Mesh;
  51245. }
  51246. /**
  51247. * Interface for gravitational field event data
  51248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51249. */
  51250. export interface PhysicsGravitationalFieldEventData {
  51251. /**
  51252. * A sphere mesh used for the gravitational field event
  51253. */
  51254. sphere: Mesh;
  51255. }
  51256. /**
  51257. * Interface for updraft event data
  51258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51259. */
  51260. export interface PhysicsUpdraftEventData {
  51261. /**
  51262. * A cylinder used for the updraft event
  51263. */
  51264. cylinder: Mesh;
  51265. }
  51266. /**
  51267. * Interface for vortex event data
  51268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51269. */
  51270. export interface PhysicsVortexEventData {
  51271. /**
  51272. * A cylinder used for the vortex event
  51273. */
  51274. cylinder: Mesh;
  51275. }
  51276. /**
  51277. * Interface for an affected physics impostor
  51278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51279. */
  51280. export interface PhysicsAffectedImpostorWithData {
  51281. /**
  51282. * The impostor affected by the effect
  51283. */
  51284. impostor: PhysicsImpostor;
  51285. /**
  51286. * The data about the hit/horce from the explosion
  51287. */
  51288. hitData: PhysicsHitData;
  51289. }
  51290. }
  51291. declare module BABYLON {
  51292. /** @hidden */
  51293. export var blackAndWhitePixelShader: {
  51294. name: string;
  51295. shader: string;
  51296. };
  51297. }
  51298. declare module BABYLON {
  51299. /**
  51300. * Post process used to render in black and white
  51301. */
  51302. export class BlackAndWhitePostProcess extends PostProcess {
  51303. /**
  51304. * Linear about to convert he result to black and white (default: 1)
  51305. */
  51306. degree: number;
  51307. /**
  51308. * Creates a black and white post process
  51309. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51310. * @param name The name of the effect.
  51311. * @param options The required width/height ratio to downsize to before computing the render pass.
  51312. * @param camera The camera to apply the render pass to.
  51313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51314. * @param engine The engine which the post process will be applied. (default: current engine)
  51315. * @param reusable If the post process can be reused on the same frame. (default: false)
  51316. */
  51317. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51318. }
  51319. }
  51320. declare module BABYLON {
  51321. /**
  51322. * This represents a set of one or more post processes in Babylon.
  51323. * A post process can be used to apply a shader to a texture after it is rendered.
  51324. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51325. */
  51326. export class PostProcessRenderEffect {
  51327. private _postProcesses;
  51328. private _getPostProcesses;
  51329. private _singleInstance;
  51330. private _cameras;
  51331. private _indicesForCamera;
  51332. /**
  51333. * Name of the effect
  51334. * @hidden
  51335. */ name: string;
  51336. /**
  51337. * Instantiates a post process render effect.
  51338. * A post process can be used to apply a shader to a texture after it is rendered.
  51339. * @param engine The engine the effect is tied to
  51340. * @param name The name of the effect
  51341. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51342. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51343. */
  51344. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51345. /**
  51346. * Checks if all the post processes in the effect are supported.
  51347. */
  51348. readonly isSupported: boolean;
  51349. /**
  51350. * Updates the current state of the effect
  51351. * @hidden
  51352. */ update(): void;
  51353. /**
  51354. * Attaches the effect on cameras
  51355. * @param cameras The camera to attach to.
  51356. * @hidden
  51357. */ attachCameras(cameras: Camera): void;
  51358. /**
  51359. * Attaches the effect on cameras
  51360. * @param cameras The camera to attach to.
  51361. * @hidden
  51362. */ attachCameras(cameras: Camera[]): void;
  51363. /**
  51364. * Detatches the effect on cameras
  51365. * @param cameras The camera to detatch from.
  51366. * @hidden
  51367. */ detachCameras(cameras: Camera): void;
  51368. /**
  51369. * Detatches the effect on cameras
  51370. * @param cameras The camera to detatch from.
  51371. * @hidden
  51372. */ detachCameras(cameras: Camera[]): void;
  51373. /**
  51374. * Enables the effect on given cameras
  51375. * @param cameras The camera to enable.
  51376. * @hidden
  51377. */ enable(cameras: Camera): void;
  51378. /**
  51379. * Enables the effect on given cameras
  51380. * @param cameras The camera to enable.
  51381. * @hidden
  51382. */ enable(cameras: Nullable<Camera[]>): void;
  51383. /**
  51384. * Disables the effect on the given cameras
  51385. * @param cameras The camera to disable.
  51386. * @hidden
  51387. */ disable(cameras: Camera): void;
  51388. /**
  51389. * Disables the effect on the given cameras
  51390. * @param cameras The camera to disable.
  51391. * @hidden
  51392. */ disable(cameras: Nullable<Camera[]>): void;
  51393. /**
  51394. * Gets a list of the post processes contained in the effect.
  51395. * @param camera The camera to get the post processes on.
  51396. * @returns The list of the post processes in the effect.
  51397. */
  51398. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51399. }
  51400. }
  51401. declare module BABYLON {
  51402. /** @hidden */
  51403. export var extractHighlightsPixelShader: {
  51404. name: string;
  51405. shader: string;
  51406. };
  51407. }
  51408. declare module BABYLON {
  51409. /**
  51410. * 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.
  51411. */
  51412. export class ExtractHighlightsPostProcess extends PostProcess {
  51413. /**
  51414. * The luminance threshold, pixels below this value will be set to black.
  51415. */
  51416. threshold: number;
  51417. /** @hidden */ exposure: number;
  51418. /**
  51419. * Post process which has the input texture to be used when performing highlight extraction
  51420. * @hidden
  51421. */ inputPostProcess: Nullable<PostProcess>;
  51422. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51423. }
  51424. }
  51425. declare module BABYLON {
  51426. /** @hidden */
  51427. export var bloomMergePixelShader: {
  51428. name: string;
  51429. shader: string;
  51430. };
  51431. }
  51432. declare module BABYLON {
  51433. /**
  51434. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51435. */
  51436. export class BloomMergePostProcess extends PostProcess {
  51437. /** Weight of the bloom to be added to the original input. */
  51438. weight: number;
  51439. /**
  51440. * Creates a new instance of @see BloomMergePostProcess
  51441. * @param name The name of the effect.
  51442. * @param originalFromInput Post process which's input will be used for the merge.
  51443. * @param blurred Blurred highlights post process which's output will be used.
  51444. * @param weight Weight of the bloom to be added to the original input.
  51445. * @param options The required width/height ratio to downsize to before computing the render pass.
  51446. * @param camera The camera to apply the render pass to.
  51447. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51448. * @param engine The engine which the post process will be applied. (default: current engine)
  51449. * @param reusable If the post process can be reused on the same frame. (default: false)
  51450. * @param textureType Type of textures used when performing the post process. (default: 0)
  51451. * @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)
  51452. */
  51453. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51454. /** Weight of the bloom to be added to the original input. */
  51455. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51456. }
  51457. }
  51458. declare module BABYLON {
  51459. /**
  51460. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51461. */
  51462. export class BloomEffect extends PostProcessRenderEffect {
  51463. private bloomScale;
  51464. /**
  51465. * @hidden Internal
  51466. */ effects: Array<PostProcess>;
  51467. /**
  51468. * @hidden Internal
  51469. */ downscale: ExtractHighlightsPostProcess;
  51470. private _blurX;
  51471. private _blurY;
  51472. private _merge;
  51473. /**
  51474. * The luminance threshold to find bright areas of the image to bloom.
  51475. */
  51476. threshold: number;
  51477. /**
  51478. * The strength of the bloom.
  51479. */
  51480. weight: number;
  51481. /**
  51482. * Specifies the size of the bloom blur kernel, relative to the final output size
  51483. */
  51484. kernel: number;
  51485. /**
  51486. * Creates a new instance of @see BloomEffect
  51487. * @param scene The scene the effect belongs to.
  51488. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51489. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51490. * @param bloomWeight The the strength of bloom.
  51491. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51492. * @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)
  51493. */
  51494. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51495. /**
  51496. * Disposes each of the internal effects for a given camera.
  51497. * @param camera The camera to dispose the effect on.
  51498. */
  51499. disposeEffects(camera: Camera): void;
  51500. /**
  51501. * @hidden Internal
  51502. */ updateEffects(): void;
  51503. /**
  51504. * Internal
  51505. * @returns if all the contained post processes are ready.
  51506. * @hidden
  51507. */ isReady(): boolean;
  51508. }
  51509. }
  51510. declare module BABYLON {
  51511. /** @hidden */
  51512. export var chromaticAberrationPixelShader: {
  51513. name: string;
  51514. shader: string;
  51515. };
  51516. }
  51517. declare module BABYLON {
  51518. /**
  51519. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51520. */
  51521. export class ChromaticAberrationPostProcess extends PostProcess {
  51522. /**
  51523. * The amount of seperation of rgb channels (default: 30)
  51524. */
  51525. aberrationAmount: number;
  51526. /**
  51527. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51528. */
  51529. radialIntensity: number;
  51530. /**
  51531. * 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))
  51532. */
  51533. direction: Vector2;
  51534. /**
  51535. * 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))
  51536. */
  51537. centerPosition: Vector2;
  51538. /**
  51539. * Creates a new instance ChromaticAberrationPostProcess
  51540. * @param name The name of the effect.
  51541. * @param screenWidth The width of the screen to apply the effect on.
  51542. * @param screenHeight The height of the screen to apply the effect on.
  51543. * @param options The required width/height ratio to downsize to before computing the render pass.
  51544. * @param camera The camera to apply the render pass to.
  51545. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51546. * @param engine The engine which the post process will be applied. (default: current engine)
  51547. * @param reusable If the post process can be reused on the same frame. (default: false)
  51548. * @param textureType Type of textures used when performing the post process. (default: 0)
  51549. * @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)
  51550. */
  51551. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51552. }
  51553. }
  51554. declare module BABYLON {
  51555. /** @hidden */
  51556. export var circleOfConfusionPixelShader: {
  51557. name: string;
  51558. shader: string;
  51559. };
  51560. }
  51561. declare module BABYLON {
  51562. /**
  51563. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51564. */
  51565. export class CircleOfConfusionPostProcess extends PostProcess {
  51566. /**
  51567. * 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.
  51568. */
  51569. lensSize: number;
  51570. /**
  51571. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51572. */
  51573. fStop: number;
  51574. /**
  51575. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51576. */
  51577. focusDistance: number;
  51578. /**
  51579. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51580. */
  51581. focalLength: number;
  51582. private _depthTexture;
  51583. /**
  51584. * Creates a new instance CircleOfConfusionPostProcess
  51585. * @param name The name of the effect.
  51586. * @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.
  51587. * @param options The required width/height ratio to downsize to before computing the render pass.
  51588. * @param camera The camera to apply the render pass to.
  51589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51590. * @param engine The engine which the post process will be applied. (default: current engine)
  51591. * @param reusable If the post process can be reused on the same frame. (default: false)
  51592. * @param textureType Type of textures used when performing the post process. (default: 0)
  51593. * @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)
  51594. */
  51595. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51596. /**
  51597. * 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.
  51598. */
  51599. depthTexture: RenderTargetTexture;
  51600. }
  51601. }
  51602. declare module BABYLON {
  51603. /** @hidden */
  51604. export var colorCorrectionPixelShader: {
  51605. name: string;
  51606. shader: string;
  51607. };
  51608. }
  51609. declare module BABYLON {
  51610. /**
  51611. *
  51612. * This post-process allows the modification of rendered colors by using
  51613. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51614. *
  51615. * The object needs to be provided an url to a texture containing the color
  51616. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51617. * Use an image editing software to tweak the LUT to match your needs.
  51618. *
  51619. * For an example of a color LUT, see here:
  51620. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51621. * For explanations on color grading, see here:
  51622. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51623. *
  51624. */
  51625. export class ColorCorrectionPostProcess extends PostProcess {
  51626. private _colorTableTexture;
  51627. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51628. }
  51629. }
  51630. declare module BABYLON {
  51631. /** @hidden */
  51632. export var convolutionPixelShader: {
  51633. name: string;
  51634. shader: string;
  51635. };
  51636. }
  51637. declare module BABYLON {
  51638. /**
  51639. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51640. * input texture to perform effects such as edge detection or sharpening
  51641. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51642. */
  51643. export class ConvolutionPostProcess extends PostProcess {
  51644. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51645. kernel: number[];
  51646. /**
  51647. * Creates a new instance ConvolutionPostProcess
  51648. * @param name The name of the effect.
  51649. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51650. * @param options The required width/height ratio to downsize to before computing the render pass.
  51651. * @param camera The camera to apply the render pass to.
  51652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51653. * @param engine The engine which the post process will be applied. (default: current engine)
  51654. * @param reusable If the post process can be reused on the same frame. (default: false)
  51655. * @param textureType Type of textures used when performing the post process. (default: 0)
  51656. */
  51657. constructor(name: string,
  51658. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51659. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51660. /**
  51661. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51662. */
  51663. static EdgeDetect0Kernel: number[];
  51664. /**
  51665. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51666. */
  51667. static EdgeDetect1Kernel: number[];
  51668. /**
  51669. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51670. */
  51671. static EdgeDetect2Kernel: number[];
  51672. /**
  51673. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51674. */
  51675. static SharpenKernel: number[];
  51676. /**
  51677. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51678. */
  51679. static EmbossKernel: number[];
  51680. /**
  51681. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51682. */
  51683. static GaussianKernel: number[];
  51684. }
  51685. }
  51686. declare module BABYLON {
  51687. /**
  51688. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51689. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51690. * based on samples that have a large difference in distance than the center pixel.
  51691. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51692. */
  51693. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51694. direction: Vector2;
  51695. /**
  51696. * Creates a new instance CircleOfConfusionPostProcess
  51697. * @param name The name of the effect.
  51698. * @param scene The scene the effect belongs to.
  51699. * @param direction The direction the blur should be applied.
  51700. * @param kernel The size of the kernel used to blur.
  51701. * @param options The required width/height ratio to downsize to before computing the render pass.
  51702. * @param camera The camera to apply the render pass to.
  51703. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51704. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51705. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51706. * @param engine The engine which the post process will be applied. (default: current engine)
  51707. * @param reusable If the post process can be reused on the same frame. (default: false)
  51708. * @param textureType Type of textures used when performing the post process. (default: 0)
  51709. * @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)
  51710. */
  51711. 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);
  51712. }
  51713. }
  51714. declare module BABYLON {
  51715. /** @hidden */
  51716. export var depthOfFieldMergePixelShader: {
  51717. name: string;
  51718. shader: string;
  51719. };
  51720. }
  51721. declare module BABYLON {
  51722. /**
  51723. * Options to be set when merging outputs from the default pipeline.
  51724. */
  51725. export class DepthOfFieldMergePostProcessOptions {
  51726. /**
  51727. * The original image to merge on top of
  51728. */
  51729. originalFromInput: PostProcess;
  51730. /**
  51731. * Parameters to perform the merge of the depth of field effect
  51732. */
  51733. depthOfField?: {
  51734. circleOfConfusion: PostProcess;
  51735. blurSteps: Array<PostProcess>;
  51736. };
  51737. /**
  51738. * Parameters to perform the merge of bloom effect
  51739. */
  51740. bloom?: {
  51741. blurred: PostProcess;
  51742. weight: number;
  51743. };
  51744. }
  51745. /**
  51746. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51747. */
  51748. export class DepthOfFieldMergePostProcess extends PostProcess {
  51749. private blurSteps;
  51750. /**
  51751. * Creates a new instance of DepthOfFieldMergePostProcess
  51752. * @param name The name of the effect.
  51753. * @param originalFromInput Post process which's input will be used for the merge.
  51754. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51755. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51756. * @param options The required width/height ratio to downsize to before computing the render pass.
  51757. * @param camera The camera to apply the render pass to.
  51758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51759. * @param engine The engine which the post process will be applied. (default: current engine)
  51760. * @param reusable If the post process can be reused on the same frame. (default: false)
  51761. * @param textureType Type of textures used when performing the post process. (default: 0)
  51762. * @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)
  51763. */
  51764. 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);
  51765. /**
  51766. * Updates the effect with the current post process compile time values and recompiles the shader.
  51767. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51768. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51769. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51770. * @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
  51771. * @param onCompiled Called when the shader has been compiled.
  51772. * @param onError Called if there is an error when compiling a shader.
  51773. */
  51774. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51775. }
  51776. }
  51777. declare module BABYLON {
  51778. /**
  51779. * Specifies the level of max blur that should be applied when using the depth of field effect
  51780. */
  51781. export enum DepthOfFieldEffectBlurLevel {
  51782. /**
  51783. * Subtle blur
  51784. */
  51785. Low = 0,
  51786. /**
  51787. * Medium blur
  51788. */
  51789. Medium = 1,
  51790. /**
  51791. * Large blur
  51792. */
  51793. High = 2
  51794. }
  51795. /**
  51796. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51797. */
  51798. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51799. private _circleOfConfusion;
  51800. /**
  51801. * @hidden Internal, blurs from high to low
  51802. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51803. private _depthOfFieldBlurY;
  51804. private _dofMerge;
  51805. /**
  51806. * @hidden Internal post processes in depth of field effect
  51807. */ effects: Array<PostProcess>;
  51808. /**
  51809. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51810. */
  51811. focalLength: number;
  51812. /**
  51813. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51814. */
  51815. fStop: number;
  51816. /**
  51817. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51818. */
  51819. focusDistance: number;
  51820. /**
  51821. * 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.
  51822. */
  51823. lensSize: number;
  51824. /**
  51825. * Creates a new instance DepthOfFieldEffect
  51826. * @param scene The scene the effect belongs to.
  51827. * @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.
  51828. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51829. * @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)
  51830. */
  51831. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  51832. /**
  51833. * 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.
  51834. */
  51835. depthTexture: RenderTargetTexture;
  51836. /**
  51837. * Disposes each of the internal effects for a given camera.
  51838. * @param camera The camera to dispose the effect on.
  51839. */
  51840. disposeEffects(camera: Camera): void;
  51841. /**
  51842. * @hidden Internal
  51843. */ updateEffects(): void;
  51844. /**
  51845. * Internal
  51846. * @returns if all the contained post processes are ready.
  51847. * @hidden
  51848. */ isReady(): boolean;
  51849. }
  51850. }
  51851. declare module BABYLON {
  51852. /** @hidden */
  51853. export var displayPassPixelShader: {
  51854. name: string;
  51855. shader: string;
  51856. };
  51857. }
  51858. declare module BABYLON {
  51859. /**
  51860. * DisplayPassPostProcess which produces an output the same as it's input
  51861. */
  51862. export class DisplayPassPostProcess extends PostProcess {
  51863. /**
  51864. * Creates the DisplayPassPostProcess
  51865. * @param name The name of the effect.
  51866. * @param options The required width/height ratio to downsize to before computing the render pass.
  51867. * @param camera The camera to apply the render pass to.
  51868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51869. * @param engine The engine which the post process will be applied. (default: current engine)
  51870. * @param reusable If the post process can be reused on the same frame. (default: false)
  51871. */
  51872. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51873. }
  51874. }
  51875. declare module BABYLON {
  51876. /** @hidden */
  51877. export var filterPixelShader: {
  51878. name: string;
  51879. shader: string;
  51880. };
  51881. }
  51882. declare module BABYLON {
  51883. /**
  51884. * Applies a kernel filter to the image
  51885. */
  51886. export class FilterPostProcess extends PostProcess {
  51887. /** The matrix to be applied to the image */
  51888. kernelMatrix: Matrix;
  51889. /**
  51890. *
  51891. * @param name The name of the effect.
  51892. * @param kernelMatrix The matrix to be applied to the image
  51893. * @param options The required width/height ratio to downsize to before computing the render pass.
  51894. * @param camera The camera to apply the render pass to.
  51895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51896. * @param engine The engine which the post process will be applied. (default: current engine)
  51897. * @param reusable If the post process can be reused on the same frame. (default: false)
  51898. */
  51899. constructor(name: string,
  51900. /** The matrix to be applied to the image */
  51901. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51902. }
  51903. }
  51904. declare module BABYLON {
  51905. /** @hidden */
  51906. export var fxaaPixelShader: {
  51907. name: string;
  51908. shader: string;
  51909. };
  51910. }
  51911. declare module BABYLON {
  51912. /** @hidden */
  51913. export var fxaaVertexShader: {
  51914. name: string;
  51915. shader: string;
  51916. };
  51917. }
  51918. declare module BABYLON {
  51919. /**
  51920. * Fxaa post process
  51921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  51922. */
  51923. export class FxaaPostProcess extends PostProcess {
  51924. /** @hidden */
  51925. texelWidth: number;
  51926. /** @hidden */
  51927. texelHeight: number;
  51928. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51929. private _getDefines;
  51930. }
  51931. }
  51932. declare module BABYLON {
  51933. /** @hidden */
  51934. export var grainPixelShader: {
  51935. name: string;
  51936. shader: string;
  51937. };
  51938. }
  51939. declare module BABYLON {
  51940. /**
  51941. * The GrainPostProcess adds noise to the image at mid luminance levels
  51942. */
  51943. export class GrainPostProcess extends PostProcess {
  51944. /**
  51945. * The intensity of the grain added (default: 30)
  51946. */
  51947. intensity: number;
  51948. /**
  51949. * If the grain should be randomized on every frame
  51950. */
  51951. animated: boolean;
  51952. /**
  51953. * Creates a new instance of @see GrainPostProcess
  51954. * @param name The name of the effect.
  51955. * @param options The required width/height ratio to downsize to before computing the render pass.
  51956. * @param camera The camera to apply the render pass to.
  51957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51958. * @param engine The engine which the post process will be applied. (default: current engine)
  51959. * @param reusable If the post process can be reused on the same frame. (default: false)
  51960. * @param textureType Type of textures used when performing the post process. (default: 0)
  51961. * @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)
  51962. */
  51963. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51964. }
  51965. }
  51966. declare module BABYLON {
  51967. /** @hidden */
  51968. export var highlightsPixelShader: {
  51969. name: string;
  51970. shader: string;
  51971. };
  51972. }
  51973. declare module BABYLON {
  51974. /**
  51975. * Extracts highlights from the image
  51976. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51977. */
  51978. export class HighlightsPostProcess extends PostProcess {
  51979. /**
  51980. * Extracts highlights from the image
  51981. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51982. * @param name The name of the effect.
  51983. * @param options The required width/height ratio to downsize to before computing the render pass.
  51984. * @param camera The camera to apply the render pass to.
  51985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51986. * @param engine The engine which the post process will be applied. (default: current engine)
  51987. * @param reusable If the post process can be reused on the same frame. (default: false)
  51988. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  51989. */
  51990. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51991. }
  51992. }
  51993. declare module BABYLON {
  51994. /** @hidden */
  51995. export var mrtFragmentDeclaration: {
  51996. name: string;
  51997. shader: string;
  51998. };
  51999. }
  52000. declare module BABYLON {
  52001. /** @hidden */
  52002. export var geometryPixelShader: {
  52003. name: string;
  52004. shader: string;
  52005. };
  52006. }
  52007. declare module BABYLON {
  52008. /** @hidden */
  52009. export var geometryVertexShader: {
  52010. name: string;
  52011. shader: string;
  52012. };
  52013. }
  52014. declare module BABYLON {
  52015. /**
  52016. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52017. */
  52018. export class GeometryBufferRenderer {
  52019. /**
  52020. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52021. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52022. */
  52023. static readonly POSITION_TEXTURE_TYPE: number;
  52024. /**
  52025. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52026. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52027. */
  52028. static readonly VELOCITY_TEXTURE_TYPE: number;
  52029. /**
  52030. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52031. * in order to compute objects velocities when enableVelocity is set to "true"
  52032. * @hidden
  52033. */ previousTransformationMatrices: {
  52034. [index: number]: Matrix;
  52035. };
  52036. private _scene;
  52037. private _multiRenderTarget;
  52038. private _ratio;
  52039. private _enablePosition;
  52040. private _enableVelocity;
  52041. private _positionIndex;
  52042. private _velocityIndex;
  52043. protected _effect: Effect;
  52044. protected _cachedDefines: string;
  52045. /**
  52046. * Set the render list (meshes to be rendered) used in the G buffer.
  52047. */
  52048. renderList: Mesh[];
  52049. /**
  52050. * Gets wether or not G buffer are supported by the running hardware.
  52051. * This requires draw buffer supports
  52052. */
  52053. readonly isSupported: boolean;
  52054. /**
  52055. * Returns the index of the given texture type in the G-Buffer textures array
  52056. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52057. * @returns the index of the given texture type in the G-Buffer textures array
  52058. */
  52059. getTextureIndex(textureType: number): number;
  52060. /**
  52061. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52062. */
  52063. /**
  52064. * Sets whether or not objects positions are enabled for the G buffer.
  52065. */
  52066. enablePosition: boolean;
  52067. /**
  52068. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52069. */
  52070. /**
  52071. * Sets wether or not objects velocities are enabled for the G buffer.
  52072. */
  52073. enableVelocity: boolean;
  52074. /**
  52075. * Gets the scene associated with the buffer.
  52076. */
  52077. readonly scene: Scene;
  52078. /**
  52079. * Gets the ratio used by the buffer during its creation.
  52080. * How big is the buffer related to the main canvas.
  52081. */
  52082. readonly ratio: number;
  52083. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  52084. /**
  52085. * Creates a new G Buffer for the scene
  52086. * @param scene The scene the buffer belongs to
  52087. * @param ratio How big is the buffer related to the main canvas.
  52088. */
  52089. constructor(scene: Scene, ratio?: number);
  52090. /**
  52091. * Checks wether everything is ready to render a submesh to the G buffer.
  52092. * @param subMesh the submesh to check readiness for
  52093. * @param useInstances is the mesh drawn using instance or not
  52094. * @returns true if ready otherwise false
  52095. */
  52096. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52097. /**
  52098. * Gets the current underlying G Buffer.
  52099. * @returns the buffer
  52100. */
  52101. getGBuffer(): MultiRenderTarget;
  52102. /**
  52103. * Gets the number of samples used to render the buffer (anti aliasing).
  52104. */
  52105. /**
  52106. * Sets the number of samples used to render the buffer (anti aliasing).
  52107. */
  52108. samples: number;
  52109. /**
  52110. * Disposes the renderer and frees up associated resources.
  52111. */
  52112. dispose(): void;
  52113. protected _createRenderTargets(): void;
  52114. }
  52115. }
  52116. declare module BABYLON {
  52117. interface Scene {
  52118. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52119. /**
  52120. * Gets or Sets the current geometry buffer associated to the scene.
  52121. */
  52122. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52123. /**
  52124. * Enables a GeometryBufferRender and associates it with the scene
  52125. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52126. * @returns the GeometryBufferRenderer
  52127. */
  52128. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52129. /**
  52130. * Disables the GeometryBufferRender associated with the scene
  52131. */
  52132. disableGeometryBufferRenderer(): void;
  52133. }
  52134. /**
  52135. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52136. * in several rendering techniques.
  52137. */
  52138. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52139. /**
  52140. * The component name helpful to identify the component in the list of scene components.
  52141. */
  52142. readonly name: string;
  52143. /**
  52144. * The scene the component belongs to.
  52145. */
  52146. scene: Scene;
  52147. /**
  52148. * Creates a new instance of the component for the given scene
  52149. * @param scene Defines the scene to register the component in
  52150. */
  52151. constructor(scene: Scene);
  52152. /**
  52153. * Registers the component in a given scene
  52154. */
  52155. register(): void;
  52156. /**
  52157. * Rebuilds the elements related to this component in case of
  52158. * context lost for instance.
  52159. */
  52160. rebuild(): void;
  52161. /**
  52162. * Disposes the component and the associated ressources
  52163. */
  52164. dispose(): void;
  52165. private _gatherRenderTargets;
  52166. }
  52167. }
  52168. declare module BABYLON {
  52169. /** @hidden */
  52170. export var motionBlurPixelShader: {
  52171. name: string;
  52172. shader: string;
  52173. };
  52174. }
  52175. declare module BABYLON {
  52176. /**
  52177. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52178. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52179. * As an example, all you have to do is to create the post-process:
  52180. * var mb = new BABYLON.MotionBlurPostProcess(
  52181. * 'mb', // The name of the effect.
  52182. * scene, // The scene containing the objects to blur according to their velocity.
  52183. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52184. * camera // The camera to apply the render pass to.
  52185. * );
  52186. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52187. */
  52188. export class MotionBlurPostProcess extends PostProcess {
  52189. /**
  52190. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52191. */
  52192. motionStrength: number;
  52193. /**
  52194. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52195. */
  52196. /**
  52197. * Sets the number of iterations to be used for motion blur quality
  52198. */
  52199. motionBlurSamples: number;
  52200. private _motionBlurSamples;
  52201. private _geometryBufferRenderer;
  52202. /**
  52203. * Creates a new instance MotionBlurPostProcess
  52204. * @param name The name of the effect.
  52205. * @param scene The scene containing the objects to blur according to their velocity.
  52206. * @param options The required width/height ratio to downsize to before computing the render pass.
  52207. * @param camera The camera to apply the render pass to.
  52208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52209. * @param engine The engine which the post process will be applied. (default: current engine)
  52210. * @param reusable If the post process can be reused on the same frame. (default: false)
  52211. * @param textureType Type of textures used when performing the post process. (default: 0)
  52212. * @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)
  52213. */
  52214. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52215. /**
  52216. * Disposes the post process.
  52217. * @param camera The camera to dispose the post process on.
  52218. */
  52219. dispose(camera?: Camera): void;
  52220. }
  52221. }
  52222. declare module BABYLON {
  52223. /** @hidden */
  52224. export var refractionPixelShader: {
  52225. name: string;
  52226. shader: string;
  52227. };
  52228. }
  52229. declare module BABYLON {
  52230. /**
  52231. * Post process which applies a refractin texture
  52232. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52233. */
  52234. export class RefractionPostProcess extends PostProcess {
  52235. /** the base color of the refraction (used to taint the rendering) */
  52236. color: Color3;
  52237. /** simulated refraction depth */
  52238. depth: number;
  52239. /** the coefficient of the base color (0 to remove base color tainting) */
  52240. colorLevel: number;
  52241. private _refTexture;
  52242. private _ownRefractionTexture;
  52243. /**
  52244. * Gets or sets the refraction texture
  52245. * Please note that you are responsible for disposing the texture if you set it manually
  52246. */
  52247. refractionTexture: Texture;
  52248. /**
  52249. * Initializes the RefractionPostProcess
  52250. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52251. * @param name The name of the effect.
  52252. * @param refractionTextureUrl Url of the refraction texture to use
  52253. * @param color the base color of the refraction (used to taint the rendering)
  52254. * @param depth simulated refraction depth
  52255. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52256. * @param camera The camera to apply the render pass to.
  52257. * @param options The required width/height ratio to downsize to before computing the render pass.
  52258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52259. * @param engine The engine which the post process will be applied. (default: current engine)
  52260. * @param reusable If the post process can be reused on the same frame. (default: false)
  52261. */
  52262. constructor(name: string, refractionTextureUrl: string,
  52263. /** the base color of the refraction (used to taint the rendering) */
  52264. color: Color3,
  52265. /** simulated refraction depth */
  52266. depth: number,
  52267. /** the coefficient of the base color (0 to remove base color tainting) */
  52268. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52269. /**
  52270. * Disposes of the post process
  52271. * @param camera Camera to dispose post process on
  52272. */
  52273. dispose(camera: Camera): void;
  52274. }
  52275. }
  52276. declare module BABYLON {
  52277. /** @hidden */
  52278. export var sharpenPixelShader: {
  52279. name: string;
  52280. shader: string;
  52281. };
  52282. }
  52283. declare module BABYLON {
  52284. /**
  52285. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52286. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52287. */
  52288. export class SharpenPostProcess extends PostProcess {
  52289. /**
  52290. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52291. */
  52292. colorAmount: number;
  52293. /**
  52294. * How much sharpness should be applied (default: 0.3)
  52295. */
  52296. edgeAmount: number;
  52297. /**
  52298. * Creates a new instance ConvolutionPostProcess
  52299. * @param name The name of the effect.
  52300. * @param options The required width/height ratio to downsize to before computing the render pass.
  52301. * @param camera The camera to apply the render pass to.
  52302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52303. * @param engine The engine which the post process will be applied. (default: current engine)
  52304. * @param reusable If the post process can be reused on the same frame. (default: false)
  52305. * @param textureType Type of textures used when performing the post process. (default: 0)
  52306. * @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)
  52307. */
  52308. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52309. }
  52310. }
  52311. declare module BABYLON {
  52312. /**
  52313. * PostProcessRenderPipeline
  52314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52315. */
  52316. export class PostProcessRenderPipeline {
  52317. private engine;
  52318. private _renderEffects;
  52319. private _renderEffectsForIsolatedPass;
  52320. /**
  52321. * List of inspectable custom properties (used by the Inspector)
  52322. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52323. */
  52324. inspectableCustomProperties: IInspectable[];
  52325. /**
  52326. * @hidden
  52327. */
  52328. protected _cameras: Camera[];
  52329. /** @hidden */ name: string;
  52330. /**
  52331. * Gets pipeline name
  52332. */
  52333. readonly name: string;
  52334. /**
  52335. * Initializes a PostProcessRenderPipeline
  52336. * @param engine engine to add the pipeline to
  52337. * @param name name of the pipeline
  52338. */
  52339. constructor(engine: Engine, name: string);
  52340. /**
  52341. * Gets the class name
  52342. * @returns "PostProcessRenderPipeline"
  52343. */
  52344. getClassName(): string;
  52345. /**
  52346. * If all the render effects in the pipeline are supported
  52347. */
  52348. readonly isSupported: boolean;
  52349. /**
  52350. * Adds an effect to the pipeline
  52351. * @param renderEffect the effect to add
  52352. */
  52353. addEffect(renderEffect: PostProcessRenderEffect): void;
  52354. /** @hidden */ rebuild(): void;
  52355. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  52356. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52357. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52358. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52359. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  52360. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  52361. /** @hidden */ detachCameras(cameras: Camera): void;
  52362. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  52363. /** @hidden */ update(): void;
  52364. /** @hidden */ reset(): void;
  52365. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52366. /**
  52367. * Disposes of the pipeline
  52368. */
  52369. dispose(): void;
  52370. }
  52371. }
  52372. declare module BABYLON {
  52373. /**
  52374. * PostProcessRenderPipelineManager class
  52375. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52376. */
  52377. export class PostProcessRenderPipelineManager {
  52378. private _renderPipelines;
  52379. /**
  52380. * Initializes a PostProcessRenderPipelineManager
  52381. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52382. */
  52383. constructor();
  52384. /**
  52385. * Gets the list of supported render pipelines
  52386. */
  52387. readonly supportedPipelines: PostProcessRenderPipeline[];
  52388. /**
  52389. * Adds a pipeline to the manager
  52390. * @param renderPipeline The pipeline to add
  52391. */
  52392. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52393. /**
  52394. * Attaches a camera to the pipeline
  52395. * @param renderPipelineName The name of the pipeline to attach to
  52396. * @param cameras the camera to attach
  52397. * @param unique if the camera can be attached multiple times to the pipeline
  52398. */
  52399. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52400. /**
  52401. * Detaches a camera from the pipeline
  52402. * @param renderPipelineName The name of the pipeline to detach from
  52403. * @param cameras the camera to detach
  52404. */
  52405. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52406. /**
  52407. * Enables an effect by name on a pipeline
  52408. * @param renderPipelineName the name of the pipeline to enable the effect in
  52409. * @param renderEffectName the name of the effect to enable
  52410. * @param cameras the cameras that the effect should be enabled on
  52411. */
  52412. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52413. /**
  52414. * Disables an effect by name on a pipeline
  52415. * @param renderPipelineName the name of the pipeline to disable the effect in
  52416. * @param renderEffectName the name of the effect to disable
  52417. * @param cameras the cameras that the effect should be disabled on
  52418. */
  52419. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52420. /**
  52421. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52422. */
  52423. update(): void;
  52424. /** @hidden */ rebuild(): void;
  52425. /**
  52426. * Disposes of the manager and pipelines
  52427. */
  52428. dispose(): void;
  52429. }
  52430. }
  52431. declare module BABYLON {
  52432. interface Scene {
  52433. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52434. /**
  52435. * Gets the postprocess render pipeline manager
  52436. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52437. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52438. */
  52439. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52440. }
  52441. /**
  52442. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52443. */
  52444. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52445. /**
  52446. * The component name helpfull to identify the component in the list of scene components.
  52447. */
  52448. readonly name: string;
  52449. /**
  52450. * The scene the component belongs to.
  52451. */
  52452. scene: Scene;
  52453. /**
  52454. * Creates a new instance of the component for the given scene
  52455. * @param scene Defines the scene to register the component in
  52456. */
  52457. constructor(scene: Scene);
  52458. /**
  52459. * Registers the component in a given scene
  52460. */
  52461. register(): void;
  52462. /**
  52463. * Rebuilds the elements related to this component in case of
  52464. * context lost for instance.
  52465. */
  52466. rebuild(): void;
  52467. /**
  52468. * Disposes the component and the associated ressources
  52469. */
  52470. dispose(): void;
  52471. private _gatherRenderTargets;
  52472. }
  52473. }
  52474. declare module BABYLON {
  52475. /**
  52476. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52477. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52478. */
  52479. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52480. private _scene;
  52481. private _camerasToBeAttached;
  52482. /**
  52483. * ID of the sharpen post process,
  52484. */
  52485. private readonly SharpenPostProcessId;
  52486. /**
  52487. * @ignore
  52488. * ID of the image processing post process;
  52489. */
  52490. readonly ImageProcessingPostProcessId: string;
  52491. /**
  52492. * @ignore
  52493. * ID of the Fast Approximate Anti-Aliasing post process;
  52494. */
  52495. readonly FxaaPostProcessId: string;
  52496. /**
  52497. * ID of the chromatic aberration post process,
  52498. */
  52499. private readonly ChromaticAberrationPostProcessId;
  52500. /**
  52501. * ID of the grain post process
  52502. */
  52503. private readonly GrainPostProcessId;
  52504. /**
  52505. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52506. */
  52507. sharpen: SharpenPostProcess;
  52508. private _sharpenEffect;
  52509. private bloom;
  52510. /**
  52511. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52512. */
  52513. depthOfField: DepthOfFieldEffect;
  52514. /**
  52515. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52516. */
  52517. fxaa: FxaaPostProcess;
  52518. /**
  52519. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52520. */
  52521. imageProcessing: ImageProcessingPostProcess;
  52522. /**
  52523. * Chromatic aberration post process which will shift rgb colors in the image
  52524. */
  52525. chromaticAberration: ChromaticAberrationPostProcess;
  52526. private _chromaticAberrationEffect;
  52527. /**
  52528. * Grain post process which add noise to the image
  52529. */
  52530. grain: GrainPostProcess;
  52531. private _grainEffect;
  52532. /**
  52533. * Glow post process which adds a glow to emissive areas of the image
  52534. */
  52535. private _glowLayer;
  52536. /**
  52537. * Animations which can be used to tweak settings over a period of time
  52538. */
  52539. animations: Animation[];
  52540. private _imageProcessingConfigurationObserver;
  52541. private _sharpenEnabled;
  52542. private _bloomEnabled;
  52543. private _depthOfFieldEnabled;
  52544. private _depthOfFieldBlurLevel;
  52545. private _fxaaEnabled;
  52546. private _imageProcessingEnabled;
  52547. private _defaultPipelineTextureType;
  52548. private _bloomScale;
  52549. private _chromaticAberrationEnabled;
  52550. private _grainEnabled;
  52551. private _buildAllowed;
  52552. /**
  52553. * Gets active scene
  52554. */
  52555. readonly scene: Scene;
  52556. /**
  52557. * Enable or disable the sharpen process from the pipeline
  52558. */
  52559. sharpenEnabled: boolean;
  52560. private _resizeObserver;
  52561. private _hardwareScaleLevel;
  52562. private _bloomKernel;
  52563. /**
  52564. * Specifies the size of the bloom blur kernel, relative to the final output size
  52565. */
  52566. bloomKernel: number;
  52567. /**
  52568. * Specifies the weight of the bloom in the final rendering
  52569. */
  52570. private _bloomWeight;
  52571. /**
  52572. * Specifies the luma threshold for the area that will be blurred by the bloom
  52573. */
  52574. private _bloomThreshold;
  52575. private _hdr;
  52576. /**
  52577. * The strength of the bloom.
  52578. */
  52579. bloomWeight: number;
  52580. /**
  52581. * The strength of the bloom.
  52582. */
  52583. bloomThreshold: number;
  52584. /**
  52585. * The scale of the bloom, lower value will provide better performance.
  52586. */
  52587. bloomScale: number;
  52588. /**
  52589. * Enable or disable the bloom from the pipeline
  52590. */
  52591. bloomEnabled: boolean;
  52592. private _rebuildBloom;
  52593. /**
  52594. * If the depth of field is enabled.
  52595. */
  52596. depthOfFieldEnabled: boolean;
  52597. /**
  52598. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52599. */
  52600. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52601. /**
  52602. * If the anti aliasing is enabled.
  52603. */
  52604. fxaaEnabled: boolean;
  52605. private _samples;
  52606. /**
  52607. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52608. */
  52609. samples: number;
  52610. /**
  52611. * If image processing is enabled.
  52612. */
  52613. imageProcessingEnabled: boolean;
  52614. /**
  52615. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52616. */
  52617. glowLayerEnabled: boolean;
  52618. /**
  52619. * Enable or disable the chromaticAberration process from the pipeline
  52620. */
  52621. chromaticAberrationEnabled: boolean;
  52622. /**
  52623. * Enable or disable the grain process from the pipeline
  52624. */
  52625. grainEnabled: boolean;
  52626. /**
  52627. * @constructor
  52628. * @param name - The rendering pipeline name (default: "")
  52629. * @param hdr - If high dynamic range textures should be used (default: true)
  52630. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52631. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52632. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52633. */
  52634. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52635. /**
  52636. * Get the class name
  52637. * @returns "DefaultRenderingPipeline"
  52638. */
  52639. getClassName(): string;
  52640. /**
  52641. * Force the compilation of the entire pipeline.
  52642. */
  52643. prepare(): void;
  52644. private _hasCleared;
  52645. private _prevPostProcess;
  52646. private _prevPrevPostProcess;
  52647. private _setAutoClearAndTextureSharing;
  52648. private _depthOfFieldSceneObserver;
  52649. private _buildPipeline;
  52650. private _disposePostProcesses;
  52651. /**
  52652. * Adds a camera to the pipeline
  52653. * @param camera the camera to be added
  52654. */
  52655. addCamera(camera: Camera): void;
  52656. /**
  52657. * Removes a camera from the pipeline
  52658. * @param camera the camera to remove
  52659. */
  52660. removeCamera(camera: Camera): void;
  52661. /**
  52662. * Dispose of the pipeline and stop all post processes
  52663. */
  52664. dispose(): void;
  52665. /**
  52666. * Serialize the rendering pipeline (Used when exporting)
  52667. * @returns the serialized object
  52668. */
  52669. serialize(): any;
  52670. /**
  52671. * Parse the serialized pipeline
  52672. * @param source Source pipeline.
  52673. * @param scene The scene to load the pipeline to.
  52674. * @param rootUrl The URL of the serialized pipeline.
  52675. * @returns An instantiated pipeline from the serialized object.
  52676. */
  52677. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52678. }
  52679. }
  52680. declare module BABYLON {
  52681. /** @hidden */
  52682. export var lensHighlightsPixelShader: {
  52683. name: string;
  52684. shader: string;
  52685. };
  52686. }
  52687. declare module BABYLON {
  52688. /** @hidden */
  52689. export var depthOfFieldPixelShader: {
  52690. name: string;
  52691. shader: string;
  52692. };
  52693. }
  52694. declare module BABYLON {
  52695. /**
  52696. * BABYLON.JS Chromatic Aberration GLSL Shader
  52697. * Author: Olivier Guyot
  52698. * Separates very slightly R, G and B colors on the edges of the screen
  52699. * Inspired by Francois Tarlier & Martins Upitis
  52700. */
  52701. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52702. /**
  52703. * @ignore
  52704. * The chromatic aberration PostProcess id in the pipeline
  52705. */
  52706. LensChromaticAberrationEffect: string;
  52707. /**
  52708. * @ignore
  52709. * The highlights enhancing PostProcess id in the pipeline
  52710. */
  52711. HighlightsEnhancingEffect: string;
  52712. /**
  52713. * @ignore
  52714. * The depth-of-field PostProcess id in the pipeline
  52715. */
  52716. LensDepthOfFieldEffect: string;
  52717. private _scene;
  52718. private _depthTexture;
  52719. private _grainTexture;
  52720. private _chromaticAberrationPostProcess;
  52721. private _highlightsPostProcess;
  52722. private _depthOfFieldPostProcess;
  52723. private _edgeBlur;
  52724. private _grainAmount;
  52725. private _chromaticAberration;
  52726. private _distortion;
  52727. private _highlightsGain;
  52728. private _highlightsThreshold;
  52729. private _dofDistance;
  52730. private _dofAperture;
  52731. private _dofDarken;
  52732. private _dofPentagon;
  52733. private _blurNoise;
  52734. /**
  52735. * @constructor
  52736. *
  52737. * Effect parameters are as follow:
  52738. * {
  52739. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52740. * edge_blur: number; // from 0 to x (1 for realism)
  52741. * distortion: number; // from 0 to x (1 for realism)
  52742. * grain_amount: number; // from 0 to 1
  52743. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52744. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52745. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52746. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52747. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52748. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52749. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52750. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52751. * }
  52752. * Note: if an effect parameter is unset, effect is disabled
  52753. *
  52754. * @param name The rendering pipeline name
  52755. * @param parameters - An object containing all parameters (see above)
  52756. * @param scene The scene linked to this pipeline
  52757. * @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)
  52758. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52759. */
  52760. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52761. /**
  52762. * Get the class name
  52763. * @returns "LensRenderingPipeline"
  52764. */
  52765. getClassName(): string;
  52766. /**
  52767. * Gets associated scene
  52768. */
  52769. readonly scene: Scene;
  52770. /**
  52771. * Gets or sets the edge blur
  52772. */
  52773. edgeBlur: number;
  52774. /**
  52775. * Gets or sets the grain amount
  52776. */
  52777. grainAmount: number;
  52778. /**
  52779. * Gets or sets the chromatic aberration amount
  52780. */
  52781. chromaticAberration: number;
  52782. /**
  52783. * Gets or sets the depth of field aperture
  52784. */
  52785. dofAperture: number;
  52786. /**
  52787. * Gets or sets the edge distortion
  52788. */
  52789. edgeDistortion: number;
  52790. /**
  52791. * Gets or sets the depth of field distortion
  52792. */
  52793. dofDistortion: number;
  52794. /**
  52795. * Gets or sets the darken out of focus amount
  52796. */
  52797. darkenOutOfFocus: number;
  52798. /**
  52799. * Gets or sets a boolean indicating if blur noise is enabled
  52800. */
  52801. blurNoise: boolean;
  52802. /**
  52803. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  52804. */
  52805. pentagonBokeh: boolean;
  52806. /**
  52807. * Gets or sets the highlight grain amount
  52808. */
  52809. highlightsGain: number;
  52810. /**
  52811. * Gets or sets the highlight threshold
  52812. */
  52813. highlightsThreshold: number;
  52814. /**
  52815. * Sets the amount of blur at the edges
  52816. * @param amount blur amount
  52817. */
  52818. setEdgeBlur(amount: number): void;
  52819. /**
  52820. * Sets edge blur to 0
  52821. */
  52822. disableEdgeBlur(): void;
  52823. /**
  52824. * Sets the amout of grain
  52825. * @param amount Amount of grain
  52826. */
  52827. setGrainAmount(amount: number): void;
  52828. /**
  52829. * Set grain amount to 0
  52830. */
  52831. disableGrain(): void;
  52832. /**
  52833. * Sets the chromatic aberration amount
  52834. * @param amount amount of chromatic aberration
  52835. */
  52836. setChromaticAberration(amount: number): void;
  52837. /**
  52838. * Sets chromatic aberration amount to 0
  52839. */
  52840. disableChromaticAberration(): void;
  52841. /**
  52842. * Sets the EdgeDistortion amount
  52843. * @param amount amount of EdgeDistortion
  52844. */
  52845. setEdgeDistortion(amount: number): void;
  52846. /**
  52847. * Sets edge distortion to 0
  52848. */
  52849. disableEdgeDistortion(): void;
  52850. /**
  52851. * Sets the FocusDistance amount
  52852. * @param amount amount of FocusDistance
  52853. */
  52854. setFocusDistance(amount: number): void;
  52855. /**
  52856. * Disables depth of field
  52857. */
  52858. disableDepthOfField(): void;
  52859. /**
  52860. * Sets the Aperture amount
  52861. * @param amount amount of Aperture
  52862. */
  52863. setAperture(amount: number): void;
  52864. /**
  52865. * Sets the DarkenOutOfFocus amount
  52866. * @param amount amount of DarkenOutOfFocus
  52867. */
  52868. setDarkenOutOfFocus(amount: number): void;
  52869. private _pentagonBokehIsEnabled;
  52870. /**
  52871. * Creates a pentagon bokeh effect
  52872. */
  52873. enablePentagonBokeh(): void;
  52874. /**
  52875. * Disables the pentagon bokeh effect
  52876. */
  52877. disablePentagonBokeh(): void;
  52878. /**
  52879. * Enables noise blur
  52880. */
  52881. enableNoiseBlur(): void;
  52882. /**
  52883. * Disables noise blur
  52884. */
  52885. disableNoiseBlur(): void;
  52886. /**
  52887. * Sets the HighlightsGain amount
  52888. * @param amount amount of HighlightsGain
  52889. */
  52890. setHighlightsGain(amount: number): void;
  52891. /**
  52892. * Sets the HighlightsThreshold amount
  52893. * @param amount amount of HighlightsThreshold
  52894. */
  52895. setHighlightsThreshold(amount: number): void;
  52896. /**
  52897. * Disables highlights
  52898. */
  52899. disableHighlights(): void;
  52900. /**
  52901. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52902. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52903. */
  52904. dispose(disableDepthRender?: boolean): void;
  52905. private _createChromaticAberrationPostProcess;
  52906. private _createHighlightsPostProcess;
  52907. private _createDepthOfFieldPostProcess;
  52908. private _createGrainTexture;
  52909. }
  52910. }
  52911. declare module BABYLON {
  52912. /** @hidden */
  52913. export var ssao2PixelShader: {
  52914. name: string;
  52915. shader: string;
  52916. };
  52917. }
  52918. declare module BABYLON {
  52919. /** @hidden */
  52920. export var ssaoCombinePixelShader: {
  52921. name: string;
  52922. shader: string;
  52923. };
  52924. }
  52925. declare module BABYLON {
  52926. /**
  52927. * Render pipeline to produce ssao effect
  52928. */
  52929. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  52930. /**
  52931. * @ignore
  52932. * The PassPostProcess id in the pipeline that contains the original scene color
  52933. */
  52934. SSAOOriginalSceneColorEffect: string;
  52935. /**
  52936. * @ignore
  52937. * The SSAO PostProcess id in the pipeline
  52938. */
  52939. SSAORenderEffect: string;
  52940. /**
  52941. * @ignore
  52942. * The horizontal blur PostProcess id in the pipeline
  52943. */
  52944. SSAOBlurHRenderEffect: string;
  52945. /**
  52946. * @ignore
  52947. * The vertical blur PostProcess id in the pipeline
  52948. */
  52949. SSAOBlurVRenderEffect: string;
  52950. /**
  52951. * @ignore
  52952. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52953. */
  52954. SSAOCombineRenderEffect: string;
  52955. /**
  52956. * The output strength of the SSAO post-process. Default value is 1.0.
  52957. */
  52958. totalStrength: number;
  52959. /**
  52960. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  52961. */
  52962. maxZ: number;
  52963. /**
  52964. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  52965. */
  52966. minZAspect: number;
  52967. private _samples;
  52968. /**
  52969. * Number of samples used for the SSAO calculations. Default value is 8
  52970. */
  52971. samples: number;
  52972. private _textureSamples;
  52973. /**
  52974. * Number of samples to use for antialiasing
  52975. */
  52976. textureSamples: number;
  52977. /**
  52978. * Ratio object used for SSAO ratio and blur ratio
  52979. */
  52980. private _ratio;
  52981. /**
  52982. * Dynamically generated sphere sampler.
  52983. */
  52984. private _sampleSphere;
  52985. /**
  52986. * Blur filter offsets
  52987. */
  52988. private _samplerOffsets;
  52989. private _expensiveBlur;
  52990. /**
  52991. * If bilateral blur should be used
  52992. */
  52993. expensiveBlur: boolean;
  52994. /**
  52995. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  52996. */
  52997. radius: number;
  52998. /**
  52999. * The base color of the SSAO post-process
  53000. * The final result is "base + ssao" between [0, 1]
  53001. */
  53002. base: number;
  53003. /**
  53004. * Support test.
  53005. */
  53006. static readonly IsSupported: boolean;
  53007. private _scene;
  53008. private _depthTexture;
  53009. private _normalTexture;
  53010. private _randomTexture;
  53011. private _originalColorPostProcess;
  53012. private _ssaoPostProcess;
  53013. private _blurHPostProcess;
  53014. private _blurVPostProcess;
  53015. private _ssaoCombinePostProcess;
  53016. private _firstUpdate;
  53017. /**
  53018. * Gets active scene
  53019. */
  53020. readonly scene: Scene;
  53021. /**
  53022. * @constructor
  53023. * @param name The rendering pipeline name
  53024. * @param scene The scene linked to this pipeline
  53025. * @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 }
  53026. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53027. */
  53028. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53029. /**
  53030. * Get the class name
  53031. * @returns "SSAO2RenderingPipeline"
  53032. */
  53033. getClassName(): string;
  53034. /**
  53035. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53036. */
  53037. dispose(disableGeometryBufferRenderer?: boolean): void;
  53038. private _createBlurPostProcess;
  53039. /** @hidden */ rebuild(): void;
  53040. private _bits;
  53041. private _radicalInverse_VdC;
  53042. private _hammersley;
  53043. private _hemisphereSample_uniform;
  53044. private _generateHemisphere;
  53045. private _createSSAOPostProcess;
  53046. private _createSSAOCombinePostProcess;
  53047. private _createRandomTexture;
  53048. /**
  53049. * Serialize the rendering pipeline (Used when exporting)
  53050. * @returns the serialized object
  53051. */
  53052. serialize(): any;
  53053. /**
  53054. * Parse the serialized pipeline
  53055. * @param source Source pipeline.
  53056. * @param scene The scene to load the pipeline to.
  53057. * @param rootUrl The URL of the serialized pipeline.
  53058. * @returns An instantiated pipeline from the serialized object.
  53059. */
  53060. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53061. }
  53062. }
  53063. declare module BABYLON {
  53064. /** @hidden */
  53065. export var ssaoPixelShader: {
  53066. name: string;
  53067. shader: string;
  53068. };
  53069. }
  53070. declare module BABYLON {
  53071. /**
  53072. * Render pipeline to produce ssao effect
  53073. */
  53074. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53075. /**
  53076. * @ignore
  53077. * The PassPostProcess id in the pipeline that contains the original scene color
  53078. */
  53079. SSAOOriginalSceneColorEffect: string;
  53080. /**
  53081. * @ignore
  53082. * The SSAO PostProcess id in the pipeline
  53083. */
  53084. SSAORenderEffect: string;
  53085. /**
  53086. * @ignore
  53087. * The horizontal blur PostProcess id in the pipeline
  53088. */
  53089. SSAOBlurHRenderEffect: string;
  53090. /**
  53091. * @ignore
  53092. * The vertical blur PostProcess id in the pipeline
  53093. */
  53094. SSAOBlurVRenderEffect: string;
  53095. /**
  53096. * @ignore
  53097. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53098. */
  53099. SSAOCombineRenderEffect: string;
  53100. /**
  53101. * The output strength of the SSAO post-process. Default value is 1.0.
  53102. */
  53103. totalStrength: number;
  53104. /**
  53105. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53106. */
  53107. radius: number;
  53108. /**
  53109. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53110. * Must not be equal to fallOff and superior to fallOff.
  53111. * Default value is 0.0075
  53112. */
  53113. area: number;
  53114. /**
  53115. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53116. * Must not be equal to area and inferior to area.
  53117. * Default value is 0.000001
  53118. */
  53119. fallOff: number;
  53120. /**
  53121. * The base color of the SSAO post-process
  53122. * The final result is "base + ssao" between [0, 1]
  53123. */
  53124. base: number;
  53125. private _scene;
  53126. private _depthTexture;
  53127. private _randomTexture;
  53128. private _originalColorPostProcess;
  53129. private _ssaoPostProcess;
  53130. private _blurHPostProcess;
  53131. private _blurVPostProcess;
  53132. private _ssaoCombinePostProcess;
  53133. private _firstUpdate;
  53134. /**
  53135. * Gets active scene
  53136. */
  53137. readonly scene: Scene;
  53138. /**
  53139. * @constructor
  53140. * @param name - The rendering pipeline name
  53141. * @param scene - The scene linked to this pipeline
  53142. * @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 }
  53143. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53144. */
  53145. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53146. /**
  53147. * Get the class name
  53148. * @returns "SSAORenderingPipeline"
  53149. */
  53150. getClassName(): string;
  53151. /**
  53152. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53153. */
  53154. dispose(disableDepthRender?: boolean): void;
  53155. private _createBlurPostProcess;
  53156. /** @hidden */ rebuild(): void;
  53157. private _createSSAOPostProcess;
  53158. private _createSSAOCombinePostProcess;
  53159. private _createRandomTexture;
  53160. }
  53161. }
  53162. declare module BABYLON {
  53163. /** @hidden */
  53164. export var standardPixelShader: {
  53165. name: string;
  53166. shader: string;
  53167. };
  53168. }
  53169. declare module BABYLON {
  53170. /**
  53171. * Standard rendering pipeline
  53172. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53173. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53174. */
  53175. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53176. /**
  53177. * Public members
  53178. */
  53179. /**
  53180. * Post-process which contains the original scene color before the pipeline applies all the effects
  53181. */
  53182. originalPostProcess: Nullable<PostProcess>;
  53183. /**
  53184. * Post-process used to down scale an image x4
  53185. */
  53186. downSampleX4PostProcess: Nullable<PostProcess>;
  53187. /**
  53188. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53189. */
  53190. brightPassPostProcess: Nullable<PostProcess>;
  53191. /**
  53192. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53193. */
  53194. blurHPostProcesses: PostProcess[];
  53195. /**
  53196. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53197. */
  53198. blurVPostProcesses: PostProcess[];
  53199. /**
  53200. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53201. */
  53202. textureAdderPostProcess: Nullable<PostProcess>;
  53203. /**
  53204. * Post-process used to create volumetric lighting effect
  53205. */
  53206. volumetricLightPostProcess: Nullable<PostProcess>;
  53207. /**
  53208. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53209. */
  53210. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53211. /**
  53212. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53213. */
  53214. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53215. /**
  53216. * Post-process used to merge the volumetric light effect and the real scene color
  53217. */
  53218. volumetricLightMergePostProces: Nullable<PostProcess>;
  53219. /**
  53220. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53221. */
  53222. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53223. /**
  53224. * Base post-process used to calculate the average luminance of the final image for HDR
  53225. */
  53226. luminancePostProcess: Nullable<PostProcess>;
  53227. /**
  53228. * Post-processes used to create down sample post-processes in order to get
  53229. * the average luminance of the final image for HDR
  53230. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53231. */
  53232. luminanceDownSamplePostProcesses: PostProcess[];
  53233. /**
  53234. * Post-process used to create a HDR effect (light adaptation)
  53235. */
  53236. hdrPostProcess: Nullable<PostProcess>;
  53237. /**
  53238. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53239. */
  53240. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53241. /**
  53242. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53243. */
  53244. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53245. /**
  53246. * Post-process used to merge the final HDR post-process and the real scene color
  53247. */
  53248. hdrFinalPostProcess: Nullable<PostProcess>;
  53249. /**
  53250. * Post-process used to create a lens flare effect
  53251. */
  53252. lensFlarePostProcess: Nullable<PostProcess>;
  53253. /**
  53254. * Post-process that merges the result of the lens flare post-process and the real scene color
  53255. */
  53256. lensFlareComposePostProcess: Nullable<PostProcess>;
  53257. /**
  53258. * Post-process used to create a motion blur effect
  53259. */
  53260. motionBlurPostProcess: Nullable<PostProcess>;
  53261. /**
  53262. * Post-process used to create a depth of field effect
  53263. */
  53264. depthOfFieldPostProcess: Nullable<PostProcess>;
  53265. /**
  53266. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53267. */
  53268. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53269. /**
  53270. * Represents the brightness threshold in order to configure the illuminated surfaces
  53271. */
  53272. brightThreshold: number;
  53273. /**
  53274. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53275. */
  53276. blurWidth: number;
  53277. /**
  53278. * Sets if the blur for highlighted surfaces must be only horizontal
  53279. */
  53280. horizontalBlur: boolean;
  53281. /**
  53282. * Gets the overall exposure used by the pipeline
  53283. */
  53284. /**
  53285. * Sets the overall exposure used by the pipeline
  53286. */
  53287. exposure: number;
  53288. /**
  53289. * Texture used typically to simulate "dirty" on camera lens
  53290. */
  53291. lensTexture: Nullable<Texture>;
  53292. /**
  53293. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53294. */
  53295. volumetricLightCoefficient: number;
  53296. /**
  53297. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53298. */
  53299. volumetricLightPower: number;
  53300. /**
  53301. * Used the set the blur intensity to smooth the volumetric lights
  53302. */
  53303. volumetricLightBlurScale: number;
  53304. /**
  53305. * Light (spot or directional) used to generate the volumetric lights rays
  53306. * The source light must have a shadow generate so the pipeline can get its
  53307. * depth map
  53308. */
  53309. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53310. /**
  53311. * For eye adaptation, represents the minimum luminance the eye can see
  53312. */
  53313. hdrMinimumLuminance: number;
  53314. /**
  53315. * For eye adaptation, represents the decrease luminance speed
  53316. */
  53317. hdrDecreaseRate: number;
  53318. /**
  53319. * For eye adaptation, represents the increase luminance speed
  53320. */
  53321. hdrIncreaseRate: number;
  53322. /**
  53323. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53324. */
  53325. /**
  53326. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53327. */
  53328. hdrAutoExposure: boolean;
  53329. /**
  53330. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53331. */
  53332. lensColorTexture: Nullable<Texture>;
  53333. /**
  53334. * The overall strengh for the lens flare effect
  53335. */
  53336. lensFlareStrength: number;
  53337. /**
  53338. * Dispersion coefficient for lens flare ghosts
  53339. */
  53340. lensFlareGhostDispersal: number;
  53341. /**
  53342. * Main lens flare halo width
  53343. */
  53344. lensFlareHaloWidth: number;
  53345. /**
  53346. * Based on the lens distortion effect, defines how much the lens flare result
  53347. * is distorted
  53348. */
  53349. lensFlareDistortionStrength: number;
  53350. /**
  53351. * Lens star texture must be used to simulate rays on the flares and is available
  53352. * in the documentation
  53353. */
  53354. lensStarTexture: Nullable<Texture>;
  53355. /**
  53356. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53357. * flare effect by taking account of the dirt texture
  53358. */
  53359. lensFlareDirtTexture: Nullable<Texture>;
  53360. /**
  53361. * Represents the focal length for the depth of field effect
  53362. */
  53363. depthOfFieldDistance: number;
  53364. /**
  53365. * Represents the blur intensity for the blurred part of the depth of field effect
  53366. */
  53367. depthOfFieldBlurWidth: number;
  53368. /**
  53369. * For motion blur, defines how much the image is blurred by the movement
  53370. */
  53371. motionStrength: number;
  53372. /**
  53373. * List of animations for the pipeline (IAnimatable implementation)
  53374. */
  53375. animations: Animation[];
  53376. /**
  53377. * Private members
  53378. */
  53379. private _scene;
  53380. private _currentDepthOfFieldSource;
  53381. private _basePostProcess;
  53382. private _fixedExposure;
  53383. private _currentExposure;
  53384. private _hdrAutoExposure;
  53385. private _hdrCurrentLuminance;
  53386. private _floatTextureType;
  53387. private _ratio;
  53388. private _bloomEnabled;
  53389. private _depthOfFieldEnabled;
  53390. private _vlsEnabled;
  53391. private _lensFlareEnabled;
  53392. private _hdrEnabled;
  53393. private _motionBlurEnabled;
  53394. private _fxaaEnabled;
  53395. private _motionBlurSamples;
  53396. private _volumetricLightStepsCount;
  53397. private _samples;
  53398. /**
  53399. * @ignore
  53400. * Specifies if the bloom pipeline is enabled
  53401. */
  53402. BloomEnabled: boolean;
  53403. /**
  53404. * @ignore
  53405. * Specifies if the depth of field pipeline is enabed
  53406. */
  53407. DepthOfFieldEnabled: boolean;
  53408. /**
  53409. * @ignore
  53410. * Specifies if the lens flare pipeline is enabed
  53411. */
  53412. LensFlareEnabled: boolean;
  53413. /**
  53414. * @ignore
  53415. * Specifies if the HDR pipeline is enabled
  53416. */
  53417. HDREnabled: boolean;
  53418. /**
  53419. * @ignore
  53420. * Specifies if the volumetric lights scattering effect is enabled
  53421. */
  53422. VLSEnabled: boolean;
  53423. /**
  53424. * @ignore
  53425. * Specifies if the motion blur effect is enabled
  53426. */
  53427. MotionBlurEnabled: boolean;
  53428. /**
  53429. * Specifies if anti-aliasing is enabled
  53430. */
  53431. fxaaEnabled: boolean;
  53432. /**
  53433. * Specifies the number of steps used to calculate the volumetric lights
  53434. * Typically in interval [50, 200]
  53435. */
  53436. volumetricLightStepsCount: number;
  53437. /**
  53438. * Specifies the number of samples used for the motion blur effect
  53439. * Typically in interval [16, 64]
  53440. */
  53441. motionBlurSamples: number;
  53442. /**
  53443. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53444. */
  53445. samples: number;
  53446. /**
  53447. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53448. * @constructor
  53449. * @param name The rendering pipeline name
  53450. * @param scene The scene linked to this pipeline
  53451. * @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)
  53452. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53453. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53454. */
  53455. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53456. private _buildPipeline;
  53457. private _createDownSampleX4PostProcess;
  53458. private _createBrightPassPostProcess;
  53459. private _createBlurPostProcesses;
  53460. private _createTextureAdderPostProcess;
  53461. private _createVolumetricLightPostProcess;
  53462. private _createLuminancePostProcesses;
  53463. private _createHdrPostProcess;
  53464. private _createLensFlarePostProcess;
  53465. private _createDepthOfFieldPostProcess;
  53466. private _createMotionBlurPostProcess;
  53467. private _getDepthTexture;
  53468. private _disposePostProcesses;
  53469. /**
  53470. * Dispose of the pipeline and stop all post processes
  53471. */
  53472. dispose(): void;
  53473. /**
  53474. * Serialize the rendering pipeline (Used when exporting)
  53475. * @returns the serialized object
  53476. */
  53477. serialize(): any;
  53478. /**
  53479. * Parse the serialized pipeline
  53480. * @param source Source pipeline.
  53481. * @param scene The scene to load the pipeline to.
  53482. * @param rootUrl The URL of the serialized pipeline.
  53483. * @returns An instantiated pipeline from the serialized object.
  53484. */
  53485. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53486. /**
  53487. * Luminance steps
  53488. */
  53489. static LuminanceSteps: number;
  53490. }
  53491. }
  53492. declare module BABYLON {
  53493. /** @hidden */
  53494. export var tonemapPixelShader: {
  53495. name: string;
  53496. shader: string;
  53497. };
  53498. }
  53499. declare module BABYLON {
  53500. /** Defines operator used for tonemapping */
  53501. export enum TonemappingOperator {
  53502. /** Hable */
  53503. Hable = 0,
  53504. /** Reinhard */
  53505. Reinhard = 1,
  53506. /** HejiDawson */
  53507. HejiDawson = 2,
  53508. /** Photographic */
  53509. Photographic = 3
  53510. }
  53511. /**
  53512. * Defines a post process to apply tone mapping
  53513. */
  53514. export class TonemapPostProcess extends PostProcess {
  53515. private _operator;
  53516. /** Defines the required exposure adjustement */
  53517. exposureAdjustment: number;
  53518. /**
  53519. * Creates a new TonemapPostProcess
  53520. * @param name defines the name of the postprocess
  53521. * @param _operator defines the operator to use
  53522. * @param exposureAdjustment defines the required exposure adjustement
  53523. * @param camera defines the camera to use (can be null)
  53524. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53525. * @param engine defines the hosting engine (can be ignore if camera is set)
  53526. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53527. */
  53528. constructor(name: string, _operator: TonemappingOperator,
  53529. /** Defines the required exposure adjustement */
  53530. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53531. }
  53532. }
  53533. declare module BABYLON {
  53534. /** @hidden */
  53535. export var depthVertexShader: {
  53536. name: string;
  53537. shader: string;
  53538. };
  53539. }
  53540. declare module BABYLON {
  53541. /** @hidden */
  53542. export var volumetricLightScatteringPixelShader: {
  53543. name: string;
  53544. shader: string;
  53545. };
  53546. }
  53547. declare module BABYLON {
  53548. /** @hidden */
  53549. export var volumetricLightScatteringPassPixelShader: {
  53550. name: string;
  53551. shader: string;
  53552. };
  53553. }
  53554. declare module BABYLON {
  53555. /**
  53556. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53557. */
  53558. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53559. private _volumetricLightScatteringPass;
  53560. private _volumetricLightScatteringRTT;
  53561. private _viewPort;
  53562. private _screenCoordinates;
  53563. private _cachedDefines;
  53564. /**
  53565. * If not undefined, the mesh position is computed from the attached node position
  53566. */
  53567. attachedNode: {
  53568. position: Vector3;
  53569. };
  53570. /**
  53571. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53572. */
  53573. customMeshPosition: Vector3;
  53574. /**
  53575. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53576. */
  53577. useCustomMeshPosition: boolean;
  53578. /**
  53579. * If the post-process should inverse the light scattering direction
  53580. */
  53581. invert: boolean;
  53582. /**
  53583. * The internal mesh used by the post-process
  53584. */
  53585. mesh: Mesh;
  53586. /**
  53587. * @hidden
  53588. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53589. */
  53590. useDiffuseColor: boolean;
  53591. /**
  53592. * Array containing the excluded meshes not rendered in the internal pass
  53593. */
  53594. excludedMeshes: AbstractMesh[];
  53595. /**
  53596. * Controls the overall intensity of the post-process
  53597. */
  53598. exposure: number;
  53599. /**
  53600. * Dissipates each sample's contribution in range [0, 1]
  53601. */
  53602. decay: number;
  53603. /**
  53604. * Controls the overall intensity of each sample
  53605. */
  53606. weight: number;
  53607. /**
  53608. * Controls the density of each sample
  53609. */
  53610. density: number;
  53611. /**
  53612. * @constructor
  53613. * @param name The post-process name
  53614. * @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)
  53615. * @param camera The camera that the post-process will be attached to
  53616. * @param mesh The mesh used to create the light scattering
  53617. * @param samples The post-process quality, default 100
  53618. * @param samplingModeThe post-process filtering mode
  53619. * @param engine The babylon engine
  53620. * @param reusable If the post-process is reusable
  53621. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53622. */
  53623. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53624. /**
  53625. * Returns the string "VolumetricLightScatteringPostProcess"
  53626. * @returns "VolumetricLightScatteringPostProcess"
  53627. */
  53628. getClassName(): string;
  53629. private _isReady;
  53630. /**
  53631. * Sets the new light position for light scattering effect
  53632. * @param position The new custom light position
  53633. */
  53634. setCustomMeshPosition(position: Vector3): void;
  53635. /**
  53636. * Returns the light position for light scattering effect
  53637. * @return Vector3 The custom light position
  53638. */
  53639. getCustomMeshPosition(): Vector3;
  53640. /**
  53641. * Disposes the internal assets and detaches the post-process from the camera
  53642. */
  53643. dispose(camera: Camera): void;
  53644. /**
  53645. * Returns the render target texture used by the post-process
  53646. * @return the render target texture used by the post-process
  53647. */
  53648. getPass(): RenderTargetTexture;
  53649. private _meshExcluded;
  53650. private _createPass;
  53651. private _updateMeshScreenCoordinates;
  53652. /**
  53653. * Creates a default mesh for the Volumeric Light Scattering post-process
  53654. * @param name The mesh name
  53655. * @param scene The scene where to create the mesh
  53656. * @return the default mesh
  53657. */
  53658. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53659. }
  53660. }
  53661. declare module BABYLON {
  53662. interface Scene {
  53663. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  53664. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  53665. /**
  53666. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53667. */
  53668. forceShowBoundingBoxes: boolean;
  53669. /**
  53670. * Gets the bounding box renderer associated with the scene
  53671. * @returns a BoundingBoxRenderer
  53672. */
  53673. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53674. }
  53675. interface AbstractMesh {
  53676. /** @hidden (Backing field) */ showBoundingBox: boolean;
  53677. /**
  53678. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53679. */
  53680. showBoundingBox: boolean;
  53681. }
  53682. /**
  53683. * Component responsible of rendering the bounding box of the meshes in a scene.
  53684. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53685. */
  53686. export class BoundingBoxRenderer implements ISceneComponent {
  53687. /**
  53688. * The component name helpfull to identify the component in the list of scene components.
  53689. */
  53690. readonly name: string;
  53691. /**
  53692. * The scene the component belongs to.
  53693. */
  53694. scene: Scene;
  53695. /**
  53696. * Color of the bounding box lines placed in front of an object
  53697. */
  53698. frontColor: Color3;
  53699. /**
  53700. * Color of the bounding box lines placed behind an object
  53701. */
  53702. backColor: Color3;
  53703. /**
  53704. * Defines if the renderer should show the back lines or not
  53705. */
  53706. showBackLines: boolean;
  53707. /**
  53708. * @hidden
  53709. */
  53710. renderList: SmartArray<BoundingBox>;
  53711. private _colorShader;
  53712. private _vertexBuffers;
  53713. private _indexBuffer;
  53714. /**
  53715. * Instantiates a new bounding box renderer in a scene.
  53716. * @param scene the scene the renderer renders in
  53717. */
  53718. constructor(scene: Scene);
  53719. /**
  53720. * Registers the component in a given scene
  53721. */
  53722. register(): void;
  53723. private _evaluateSubMesh;
  53724. private _activeMesh;
  53725. private _prepareRessources;
  53726. private _createIndexBuffer;
  53727. /**
  53728. * Rebuilds the elements related to this component in case of
  53729. * context lost for instance.
  53730. */
  53731. rebuild(): void;
  53732. /**
  53733. * @hidden
  53734. */
  53735. reset(): void;
  53736. /**
  53737. * Render the bounding boxes of a specific rendering group
  53738. * @param renderingGroupId defines the rendering group to render
  53739. */
  53740. render(renderingGroupId: number): void;
  53741. /**
  53742. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53743. * @param mesh Define the mesh to render the occlusion bounding box for
  53744. */
  53745. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53746. /**
  53747. * Dispose and release the resources attached to this renderer.
  53748. */
  53749. dispose(): void;
  53750. }
  53751. }
  53752. declare module BABYLON {
  53753. /** @hidden */
  53754. export var depthPixelShader: {
  53755. name: string;
  53756. shader: string;
  53757. };
  53758. }
  53759. declare module BABYLON {
  53760. /**
  53761. * This represents a depth renderer in Babylon.
  53762. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53763. */
  53764. export class DepthRenderer {
  53765. private _scene;
  53766. private _depthMap;
  53767. private _effect;
  53768. private _cachedDefines;
  53769. private _camera;
  53770. /**
  53771. * Specifiess that the depth renderer will only be used within
  53772. * the camera it is created for.
  53773. * This can help forcing its rendering during the camera processing.
  53774. */
  53775. useOnlyInActiveCamera: boolean;
  53776. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  53777. /**
  53778. * Instantiates a depth renderer
  53779. * @param scene The scene the renderer belongs to
  53780. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53781. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53782. */
  53783. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53784. /**
  53785. * Creates the depth rendering effect and checks if the effect is ready.
  53786. * @param subMesh The submesh to be used to render the depth map of
  53787. * @param useInstances If multiple world instances should be used
  53788. * @returns if the depth renderer is ready to render the depth map
  53789. */
  53790. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53791. /**
  53792. * Gets the texture which the depth map will be written to.
  53793. * @returns The depth map texture
  53794. */
  53795. getDepthMap(): RenderTargetTexture;
  53796. /**
  53797. * Disposes of the depth renderer.
  53798. */
  53799. dispose(): void;
  53800. }
  53801. }
  53802. declare module BABYLON {
  53803. interface Scene {
  53804. /** @hidden (Backing field) */ depthRenderer: {
  53805. [id: string]: DepthRenderer;
  53806. };
  53807. /**
  53808. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53809. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53810. * @returns the created depth renderer
  53811. */
  53812. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53813. /**
  53814. * Disables a depth renderer for a given camera
  53815. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53816. */
  53817. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53818. }
  53819. /**
  53820. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  53821. * in several rendering techniques.
  53822. */
  53823. export class DepthRendererSceneComponent implements ISceneComponent {
  53824. /**
  53825. * The component name helpfull to identify the component in the list of scene components.
  53826. */
  53827. readonly name: string;
  53828. /**
  53829. * The scene the component belongs to.
  53830. */
  53831. scene: Scene;
  53832. /**
  53833. * Creates a new instance of the component for the given scene
  53834. * @param scene Defines the scene to register the component in
  53835. */
  53836. constructor(scene: Scene);
  53837. /**
  53838. * Registers the component in a given scene
  53839. */
  53840. register(): void;
  53841. /**
  53842. * Rebuilds the elements related to this component in case of
  53843. * context lost for instance.
  53844. */
  53845. rebuild(): void;
  53846. /**
  53847. * Disposes the component and the associated ressources
  53848. */
  53849. dispose(): void;
  53850. private _gatherRenderTargets;
  53851. private _gatherActiveCameraRenderTargets;
  53852. }
  53853. }
  53854. declare module BABYLON {
  53855. /** @hidden */
  53856. export var outlinePixelShader: {
  53857. name: string;
  53858. shader: string;
  53859. };
  53860. }
  53861. declare module BABYLON {
  53862. /** @hidden */
  53863. export var outlineVertexShader: {
  53864. name: string;
  53865. shader: string;
  53866. };
  53867. }
  53868. declare module BABYLON {
  53869. interface Scene {
  53870. /** @hidden */ outlineRenderer: OutlineRenderer;
  53871. /**
  53872. * Gets the outline renderer associated with the scene
  53873. * @returns a OutlineRenderer
  53874. */
  53875. getOutlineRenderer(): OutlineRenderer;
  53876. }
  53877. interface AbstractMesh {
  53878. /** @hidden (Backing field) */ renderOutline: boolean;
  53879. /**
  53880. * Gets or sets a boolean indicating if the outline must be rendered as well
  53881. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  53882. */
  53883. renderOutline: boolean;
  53884. /** @hidden (Backing field) */ renderOverlay: boolean;
  53885. /**
  53886. * Gets or sets a boolean indicating if the overlay must be rendered as well
  53887. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  53888. */
  53889. renderOverlay: boolean;
  53890. }
  53891. /**
  53892. * This class is responsible to draw bothe outline/overlay of meshes.
  53893. * It should not be used directly but through the available method on mesh.
  53894. */
  53895. export class OutlineRenderer implements ISceneComponent {
  53896. /**
  53897. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  53898. */
  53899. private static _StencilReference;
  53900. /**
  53901. * The name of the component. Each component must have a unique name.
  53902. */
  53903. name: string;
  53904. /**
  53905. * The scene the component belongs to.
  53906. */
  53907. scene: Scene;
  53908. /**
  53909. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  53910. */
  53911. zOffset: number;
  53912. private _engine;
  53913. private _effect;
  53914. private _cachedDefines;
  53915. private _savedDepthWrite;
  53916. /**
  53917. * Instantiates a new outline renderer. (There could be only one per scene).
  53918. * @param scene Defines the scene it belongs to
  53919. */
  53920. constructor(scene: Scene);
  53921. /**
  53922. * Register the component to one instance of a scene.
  53923. */
  53924. register(): void;
  53925. /**
  53926. * Rebuilds the elements related to this component in case of
  53927. * context lost for instance.
  53928. */
  53929. rebuild(): void;
  53930. /**
  53931. * Disposes the component and the associated ressources.
  53932. */
  53933. dispose(): void;
  53934. /**
  53935. * Renders the outline in the canvas.
  53936. * @param subMesh Defines the sumesh to render
  53937. * @param batch Defines the batch of meshes in case of instances
  53938. * @param useOverlay Defines if the rendering is for the overlay or the outline
  53939. */
  53940. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  53941. /**
  53942. * Returns whether or not the outline renderer is ready for a given submesh.
  53943. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  53944. * @param subMesh Defines the submesh to check readyness for
  53945. * @param useInstances Defines wheter wee are trying to render instances or not
  53946. * @returns true if ready otherwise false
  53947. */
  53948. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53949. private _beforeRenderingMesh;
  53950. private _afterRenderingMesh;
  53951. }
  53952. }
  53953. declare module BABYLON {
  53954. /**
  53955. * Defines the list of states available for a task inside a AssetsManager
  53956. */
  53957. export enum AssetTaskState {
  53958. /**
  53959. * Initialization
  53960. */
  53961. INIT = 0,
  53962. /**
  53963. * Running
  53964. */
  53965. RUNNING = 1,
  53966. /**
  53967. * Done
  53968. */
  53969. DONE = 2,
  53970. /**
  53971. * Error
  53972. */
  53973. ERROR = 3
  53974. }
  53975. /**
  53976. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  53977. */
  53978. export abstract class AbstractAssetTask {
  53979. /**
  53980. * Task name
  53981. */ name: string;
  53982. /**
  53983. * Callback called when the task is successful
  53984. */
  53985. onSuccess: (task: any) => void;
  53986. /**
  53987. * Callback called when the task is not successful
  53988. */
  53989. onError: (task: any, message?: string, exception?: any) => void;
  53990. /**
  53991. * Creates a new AssetsManager
  53992. * @param name defines the name of the task
  53993. */
  53994. constructor(
  53995. /**
  53996. * Task name
  53997. */ name: string);
  53998. private _isCompleted;
  53999. private _taskState;
  54000. private _errorObject;
  54001. /**
  54002. * Get if the task is completed
  54003. */
  54004. readonly isCompleted: boolean;
  54005. /**
  54006. * Gets the current state of the task
  54007. */
  54008. readonly taskState: AssetTaskState;
  54009. /**
  54010. * Gets the current error object (if task is in error)
  54011. */
  54012. readonly errorObject: {
  54013. message?: string;
  54014. exception?: any;
  54015. };
  54016. /**
  54017. * Internal only
  54018. * @hidden
  54019. */ setErrorObject(message?: string, exception?: any): void;
  54020. /**
  54021. * Execute the current task
  54022. * @param scene defines the scene where you want your assets to be loaded
  54023. * @param onSuccess is a callback called when the task is successfully executed
  54024. * @param onError is a callback called if an error occurs
  54025. */
  54026. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54027. /**
  54028. * Execute the current task
  54029. * @param scene defines the scene where you want your assets to be loaded
  54030. * @param onSuccess is a callback called when the task is successfully executed
  54031. * @param onError is a callback called if an error occurs
  54032. */
  54033. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54034. /**
  54035. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54036. * This can be used with failed tasks that have the reason for failure fixed.
  54037. */
  54038. reset(): void;
  54039. private onErrorCallback;
  54040. private onDoneCallback;
  54041. }
  54042. /**
  54043. * Define the interface used by progress events raised during assets loading
  54044. */
  54045. export interface IAssetsProgressEvent {
  54046. /**
  54047. * Defines the number of remaining tasks to process
  54048. */
  54049. remainingCount: number;
  54050. /**
  54051. * Defines the total number of tasks
  54052. */
  54053. totalCount: number;
  54054. /**
  54055. * Defines the task that was just processed
  54056. */
  54057. task: AbstractAssetTask;
  54058. }
  54059. /**
  54060. * Class used to share progress information about assets loading
  54061. */
  54062. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54063. /**
  54064. * Defines the number of remaining tasks to process
  54065. */
  54066. remainingCount: number;
  54067. /**
  54068. * Defines the total number of tasks
  54069. */
  54070. totalCount: number;
  54071. /**
  54072. * Defines the task that was just processed
  54073. */
  54074. task: AbstractAssetTask;
  54075. /**
  54076. * Creates a AssetsProgressEvent
  54077. * @param remainingCount defines the number of remaining tasks to process
  54078. * @param totalCount defines the total number of tasks
  54079. * @param task defines the task that was just processed
  54080. */
  54081. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54082. }
  54083. /**
  54084. * Define a task used by AssetsManager to load meshes
  54085. */
  54086. export class MeshAssetTask extends AbstractAssetTask {
  54087. /**
  54088. * Defines the name of the task
  54089. */
  54090. name: string;
  54091. /**
  54092. * Defines the list of mesh's names you want to load
  54093. */
  54094. meshesNames: any;
  54095. /**
  54096. * Defines the root url to use as a base to load your meshes and associated resources
  54097. */
  54098. rootUrl: string;
  54099. /**
  54100. * Defines the filename of the scene to load from
  54101. */
  54102. sceneFilename: string;
  54103. /**
  54104. * Gets the list of loaded meshes
  54105. */
  54106. loadedMeshes: Array<AbstractMesh>;
  54107. /**
  54108. * Gets the list of loaded particle systems
  54109. */
  54110. loadedParticleSystems: Array<IParticleSystem>;
  54111. /**
  54112. * Gets the list of loaded skeletons
  54113. */
  54114. loadedSkeletons: Array<Skeleton>;
  54115. /**
  54116. * Gets the list of loaded animation groups
  54117. */
  54118. loadedAnimationGroups: Array<AnimationGroup>;
  54119. /**
  54120. * Callback called when the task is successful
  54121. */
  54122. onSuccess: (task: MeshAssetTask) => void;
  54123. /**
  54124. * Callback called when the task is successful
  54125. */
  54126. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54127. /**
  54128. * Creates a new MeshAssetTask
  54129. * @param name defines the name of the task
  54130. * @param meshesNames defines the list of mesh's names you want to load
  54131. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54132. * @param sceneFilename defines the filename of the scene to load from
  54133. */
  54134. constructor(
  54135. /**
  54136. * Defines the name of the task
  54137. */
  54138. name: string,
  54139. /**
  54140. * Defines the list of mesh's names you want to load
  54141. */
  54142. meshesNames: any,
  54143. /**
  54144. * Defines the root url to use as a base to load your meshes and associated resources
  54145. */
  54146. rootUrl: string,
  54147. /**
  54148. * Defines the filename of the scene to load from
  54149. */
  54150. sceneFilename: string);
  54151. /**
  54152. * Execute the current task
  54153. * @param scene defines the scene where you want your assets to be loaded
  54154. * @param onSuccess is a callback called when the task is successfully executed
  54155. * @param onError is a callback called if an error occurs
  54156. */
  54157. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54158. }
  54159. /**
  54160. * Define a task used by AssetsManager to load text content
  54161. */
  54162. export class TextFileAssetTask extends AbstractAssetTask {
  54163. /**
  54164. * Defines the name of the task
  54165. */
  54166. name: string;
  54167. /**
  54168. * Defines the location of the file to load
  54169. */
  54170. url: string;
  54171. /**
  54172. * Gets the loaded text string
  54173. */
  54174. text: string;
  54175. /**
  54176. * Callback called when the task is successful
  54177. */
  54178. onSuccess: (task: TextFileAssetTask) => void;
  54179. /**
  54180. * Callback called when the task is successful
  54181. */
  54182. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54183. /**
  54184. * Creates a new TextFileAssetTask object
  54185. * @param name defines the name of the task
  54186. * @param url defines the location of the file to load
  54187. */
  54188. constructor(
  54189. /**
  54190. * Defines the name of the task
  54191. */
  54192. name: string,
  54193. /**
  54194. * Defines the location of the file to load
  54195. */
  54196. url: string);
  54197. /**
  54198. * Execute the current task
  54199. * @param scene defines the scene where you want your assets to be loaded
  54200. * @param onSuccess is a callback called when the task is successfully executed
  54201. * @param onError is a callback called if an error occurs
  54202. */
  54203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54204. }
  54205. /**
  54206. * Define a task used by AssetsManager to load binary data
  54207. */
  54208. export class BinaryFileAssetTask extends AbstractAssetTask {
  54209. /**
  54210. * Defines the name of the task
  54211. */
  54212. name: string;
  54213. /**
  54214. * Defines the location of the file to load
  54215. */
  54216. url: string;
  54217. /**
  54218. * Gets the lodaded data (as an array buffer)
  54219. */
  54220. data: ArrayBuffer;
  54221. /**
  54222. * Callback called when the task is successful
  54223. */
  54224. onSuccess: (task: BinaryFileAssetTask) => void;
  54225. /**
  54226. * Callback called when the task is successful
  54227. */
  54228. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54229. /**
  54230. * Creates a new BinaryFileAssetTask object
  54231. * @param name defines the name of the new task
  54232. * @param url defines the location of the file to load
  54233. */
  54234. constructor(
  54235. /**
  54236. * Defines the name of the task
  54237. */
  54238. name: string,
  54239. /**
  54240. * Defines the location of the file to load
  54241. */
  54242. url: string);
  54243. /**
  54244. * Execute the current task
  54245. * @param scene defines the scene where you want your assets to be loaded
  54246. * @param onSuccess is a callback called when the task is successfully executed
  54247. * @param onError is a callback called if an error occurs
  54248. */
  54249. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54250. }
  54251. /**
  54252. * Define a task used by AssetsManager to load images
  54253. */
  54254. export class ImageAssetTask extends AbstractAssetTask {
  54255. /**
  54256. * Defines the name of the task
  54257. */
  54258. name: string;
  54259. /**
  54260. * Defines the location of the image to load
  54261. */
  54262. url: string;
  54263. /**
  54264. * Gets the loaded images
  54265. */
  54266. image: HTMLImageElement;
  54267. /**
  54268. * Callback called when the task is successful
  54269. */
  54270. onSuccess: (task: ImageAssetTask) => void;
  54271. /**
  54272. * Callback called when the task is successful
  54273. */
  54274. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54275. /**
  54276. * Creates a new ImageAssetTask
  54277. * @param name defines the name of the task
  54278. * @param url defines the location of the image to load
  54279. */
  54280. constructor(
  54281. /**
  54282. * Defines the name of the task
  54283. */
  54284. name: string,
  54285. /**
  54286. * Defines the location of the image to load
  54287. */
  54288. url: string);
  54289. /**
  54290. * Execute the current task
  54291. * @param scene defines the scene where you want your assets to be loaded
  54292. * @param onSuccess is a callback called when the task is successfully executed
  54293. * @param onError is a callback called if an error occurs
  54294. */
  54295. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54296. }
  54297. /**
  54298. * Defines the interface used by texture loading tasks
  54299. */
  54300. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54301. /**
  54302. * Gets the loaded texture
  54303. */
  54304. texture: TEX;
  54305. }
  54306. /**
  54307. * Define a task used by AssetsManager to load 2D textures
  54308. */
  54309. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54310. /**
  54311. * Defines the name of the task
  54312. */
  54313. name: string;
  54314. /**
  54315. * Defines the location of the file to load
  54316. */
  54317. url: string;
  54318. /**
  54319. * Defines if mipmap should not be generated (default is false)
  54320. */
  54321. noMipmap?: boolean | undefined;
  54322. /**
  54323. * Defines if texture must be inverted on Y axis (default is false)
  54324. */
  54325. invertY?: boolean | undefined;
  54326. /**
  54327. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54328. */
  54329. samplingMode: number;
  54330. /**
  54331. * Gets the loaded texture
  54332. */
  54333. texture: Texture;
  54334. /**
  54335. * Callback called when the task is successful
  54336. */
  54337. onSuccess: (task: TextureAssetTask) => void;
  54338. /**
  54339. * Callback called when the task is successful
  54340. */
  54341. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54342. /**
  54343. * Creates a new TextureAssetTask object
  54344. * @param name defines the name of the task
  54345. * @param url defines the location of the file to load
  54346. * @param noMipmap defines if mipmap should not be generated (default is false)
  54347. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54348. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54349. */
  54350. constructor(
  54351. /**
  54352. * Defines the name of the task
  54353. */
  54354. name: string,
  54355. /**
  54356. * Defines the location of the file to load
  54357. */
  54358. url: string,
  54359. /**
  54360. * Defines if mipmap should not be generated (default is false)
  54361. */
  54362. noMipmap?: boolean | undefined,
  54363. /**
  54364. * Defines if texture must be inverted on Y axis (default is false)
  54365. */
  54366. invertY?: boolean | undefined,
  54367. /**
  54368. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54369. */
  54370. samplingMode?: number);
  54371. /**
  54372. * Execute the current task
  54373. * @param scene defines the scene where you want your assets to be loaded
  54374. * @param onSuccess is a callback called when the task is successfully executed
  54375. * @param onError is a callback called if an error occurs
  54376. */
  54377. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54378. }
  54379. /**
  54380. * Define a task used by AssetsManager to load cube textures
  54381. */
  54382. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54383. /**
  54384. * Defines the name of the task
  54385. */
  54386. name: string;
  54387. /**
  54388. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54389. */
  54390. url: string;
  54391. /**
  54392. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54393. */
  54394. extensions?: string[] | undefined;
  54395. /**
  54396. * Defines if mipmaps should not be generated (default is false)
  54397. */
  54398. noMipmap?: boolean | undefined;
  54399. /**
  54400. * Defines the explicit list of files (undefined by default)
  54401. */
  54402. files?: string[] | undefined;
  54403. /**
  54404. * Gets the loaded texture
  54405. */
  54406. texture: CubeTexture;
  54407. /**
  54408. * Callback called when the task is successful
  54409. */
  54410. onSuccess: (task: CubeTextureAssetTask) => void;
  54411. /**
  54412. * Callback called when the task is successful
  54413. */
  54414. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54415. /**
  54416. * Creates a new CubeTextureAssetTask
  54417. * @param name defines the name of the task
  54418. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54419. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54420. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54421. * @param files defines the explicit list of files (undefined by default)
  54422. */
  54423. constructor(
  54424. /**
  54425. * Defines the name of the task
  54426. */
  54427. name: string,
  54428. /**
  54429. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54430. */
  54431. url: string,
  54432. /**
  54433. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54434. */
  54435. extensions?: string[] | undefined,
  54436. /**
  54437. * Defines if mipmaps should not be generated (default is false)
  54438. */
  54439. noMipmap?: boolean | undefined,
  54440. /**
  54441. * Defines the explicit list of files (undefined by default)
  54442. */
  54443. files?: string[] | undefined);
  54444. /**
  54445. * Execute the current task
  54446. * @param scene defines the scene where you want your assets to be loaded
  54447. * @param onSuccess is a callback called when the task is successfully executed
  54448. * @param onError is a callback called if an error occurs
  54449. */
  54450. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54451. }
  54452. /**
  54453. * Define a task used by AssetsManager to load HDR cube textures
  54454. */
  54455. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54456. /**
  54457. * Defines the name of the task
  54458. */
  54459. name: string;
  54460. /**
  54461. * Defines the location of the file to load
  54462. */
  54463. url: string;
  54464. /**
  54465. * Defines the desired size (the more it increases the longer the generation will be)
  54466. */
  54467. size: number;
  54468. /**
  54469. * Defines if mipmaps should not be generated (default is false)
  54470. */
  54471. noMipmap: boolean;
  54472. /**
  54473. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54474. */
  54475. generateHarmonics: boolean;
  54476. /**
  54477. * 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)
  54478. */
  54479. gammaSpace: boolean;
  54480. /**
  54481. * Internal Use Only
  54482. */
  54483. reserved: boolean;
  54484. /**
  54485. * Gets the loaded texture
  54486. */
  54487. texture: HDRCubeTexture;
  54488. /**
  54489. * Callback called when the task is successful
  54490. */
  54491. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54492. /**
  54493. * Callback called when the task is successful
  54494. */
  54495. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54496. /**
  54497. * Creates a new HDRCubeTextureAssetTask object
  54498. * @param name defines the name of the task
  54499. * @param url defines the location of the file to load
  54500. * @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.
  54501. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54502. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54503. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  54504. * @param reserved Internal use only
  54505. */
  54506. constructor(
  54507. /**
  54508. * Defines the name of the task
  54509. */
  54510. name: string,
  54511. /**
  54512. * Defines the location of the file to load
  54513. */
  54514. url: string,
  54515. /**
  54516. * Defines the desired size (the more it increases the longer the generation will be)
  54517. */
  54518. size: number,
  54519. /**
  54520. * Defines if mipmaps should not be generated (default is false)
  54521. */
  54522. noMipmap?: boolean,
  54523. /**
  54524. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54525. */
  54526. generateHarmonics?: boolean,
  54527. /**
  54528. * 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)
  54529. */
  54530. gammaSpace?: boolean,
  54531. /**
  54532. * Internal Use Only
  54533. */
  54534. reserved?: boolean);
  54535. /**
  54536. * Execute the current task
  54537. * @param scene defines the scene where you want your assets to be loaded
  54538. * @param onSuccess is a callback called when the task is successfully executed
  54539. * @param onError is a callback called if an error occurs
  54540. */
  54541. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54542. }
  54543. /**
  54544. * Define a task used by AssetsManager to load Equirectangular cube textures
  54545. */
  54546. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  54547. /**
  54548. * Defines the name of the task
  54549. */
  54550. name: string;
  54551. /**
  54552. * Defines the location of the file to load
  54553. */
  54554. url: string;
  54555. /**
  54556. * Defines the desired size (the more it increases the longer the generation will be)
  54557. */
  54558. size: number;
  54559. /**
  54560. * Defines if mipmaps should not be generated (default is false)
  54561. */
  54562. noMipmap: boolean;
  54563. /**
  54564. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54565. * but the standard material would require them in Gamma space) (default is true)
  54566. */
  54567. gammaSpace: boolean;
  54568. /**
  54569. * Gets the loaded texture
  54570. */
  54571. texture: EquiRectangularCubeTexture;
  54572. /**
  54573. * Callback called when the task is successful
  54574. */
  54575. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  54576. /**
  54577. * Callback called when the task is successful
  54578. */
  54579. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  54580. /**
  54581. * Creates a new EquiRectangularCubeTextureAssetTask object
  54582. * @param name defines the name of the task
  54583. * @param url defines the location of the file to load
  54584. * @param size defines the desired size (the more it increases the longer the generation will be)
  54585. * If the size is omitted this implies you are using a preprocessed cubemap.
  54586. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54587. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  54588. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54589. * (default is true)
  54590. */
  54591. constructor(
  54592. /**
  54593. * Defines the name of the task
  54594. */
  54595. name: string,
  54596. /**
  54597. * Defines the location of the file to load
  54598. */
  54599. url: string,
  54600. /**
  54601. * Defines the desired size (the more it increases the longer the generation will be)
  54602. */
  54603. size: number,
  54604. /**
  54605. * Defines if mipmaps should not be generated (default is false)
  54606. */
  54607. noMipmap?: boolean,
  54608. /**
  54609. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54610. * but the standard material would require them in Gamma space) (default is true)
  54611. */
  54612. gammaSpace?: boolean);
  54613. /**
  54614. * Execute the current task
  54615. * @param scene defines the scene where you want your assets to be loaded
  54616. * @param onSuccess is a callback called when the task is successfully executed
  54617. * @param onError is a callback called if an error occurs
  54618. */
  54619. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54620. }
  54621. /**
  54622. * This class can be used to easily import assets into a scene
  54623. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54624. */
  54625. export class AssetsManager {
  54626. private _scene;
  54627. private _isLoading;
  54628. protected _tasks: AbstractAssetTask[];
  54629. protected _waitingTasksCount: number;
  54630. protected _totalTasksCount: number;
  54631. /**
  54632. * Callback called when all tasks are processed
  54633. */
  54634. onFinish: (tasks: AbstractAssetTask[]) => void;
  54635. /**
  54636. * Callback called when a task is successful
  54637. */
  54638. onTaskSuccess: (task: AbstractAssetTask) => void;
  54639. /**
  54640. * Callback called when a task had an error
  54641. */
  54642. onTaskError: (task: AbstractAssetTask) => void;
  54643. /**
  54644. * Callback called when a task is done (whatever the result is)
  54645. */
  54646. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54647. /**
  54648. * Observable called when all tasks are processed
  54649. */
  54650. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54651. /**
  54652. * Observable called when a task had an error
  54653. */
  54654. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54655. /**
  54656. * Observable called when all tasks were executed
  54657. */
  54658. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54659. /**
  54660. * Observable called when a task is done (whatever the result is)
  54661. */
  54662. onProgressObservable: Observable<IAssetsProgressEvent>;
  54663. /**
  54664. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54665. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54666. */
  54667. useDefaultLoadingScreen: boolean;
  54668. /**
  54669. * Creates a new AssetsManager
  54670. * @param scene defines the scene to work on
  54671. */
  54672. constructor(scene: Scene);
  54673. /**
  54674. * Add a MeshAssetTask to the list of active tasks
  54675. * @param taskName defines the name of the new task
  54676. * @param meshesNames defines the name of meshes to load
  54677. * @param rootUrl defines the root url to use to locate files
  54678. * @param sceneFilename defines the filename of the scene file
  54679. * @returns a new MeshAssetTask object
  54680. */
  54681. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54682. /**
  54683. * Add a TextFileAssetTask to the list of active tasks
  54684. * @param taskName defines the name of the new task
  54685. * @param url defines the url of the file to load
  54686. * @returns a new TextFileAssetTask object
  54687. */
  54688. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54689. /**
  54690. * Add a BinaryFileAssetTask to the list of active tasks
  54691. * @param taskName defines the name of the new task
  54692. * @param url defines the url of the file to load
  54693. * @returns a new BinaryFileAssetTask object
  54694. */
  54695. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54696. /**
  54697. * Add a ImageAssetTask to the list of active tasks
  54698. * @param taskName defines the name of the new task
  54699. * @param url defines the url of the file to load
  54700. * @returns a new ImageAssetTask object
  54701. */
  54702. addImageTask(taskName: string, url: string): ImageAssetTask;
  54703. /**
  54704. * Add a TextureAssetTask to the list of active tasks
  54705. * @param taskName defines the name of the new task
  54706. * @param url defines the url of the file to load
  54707. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54708. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54709. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54710. * @returns a new TextureAssetTask object
  54711. */
  54712. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54713. /**
  54714. * Add a CubeTextureAssetTask to the list of active tasks
  54715. * @param taskName defines the name of the new task
  54716. * @param url defines the url of the file to load
  54717. * @param extensions defines the extension to use to load the cube map (can be null)
  54718. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54719. * @param files defines the list of files to load (can be null)
  54720. * @returns a new CubeTextureAssetTask object
  54721. */
  54722. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54723. /**
  54724. *
  54725. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54726. * @param taskName defines the name of the new task
  54727. * @param url defines the url of the file to load
  54728. * @param size defines the size you want for the cubemap (can be null)
  54729. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54730. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54731. * @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)
  54732. * @param reserved Internal use only
  54733. * @returns a new HDRCubeTextureAssetTask object
  54734. */
  54735. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54736. /**
  54737. *
  54738. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  54739. * @param taskName defines the name of the new task
  54740. * @param url defines the url of the file to load
  54741. * @param size defines the size you want for the cubemap (can be null)
  54742. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54743. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54744. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54745. * @returns a new EquiRectangularCubeTextureAssetTask object
  54746. */
  54747. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  54748. /**
  54749. * Remove a task from the assets manager.
  54750. * @param task the task to remove
  54751. */
  54752. removeTask(task: AbstractAssetTask): void;
  54753. private _decreaseWaitingTasksCount;
  54754. private _runTask;
  54755. /**
  54756. * Reset the AssetsManager and remove all tasks
  54757. * @return the current instance of the AssetsManager
  54758. */
  54759. reset(): AssetsManager;
  54760. /**
  54761. * Start the loading process
  54762. * @return the current instance of the AssetsManager
  54763. */
  54764. load(): AssetsManager;
  54765. /**
  54766. * Start the loading process as an async operation
  54767. * @return a promise returning the list of failed tasks
  54768. */
  54769. loadAsync(): Promise<void>;
  54770. }
  54771. }
  54772. declare module BABYLON {
  54773. /**
  54774. * Wrapper class for promise with external resolve and reject.
  54775. */
  54776. export class Deferred<T> {
  54777. /**
  54778. * The promise associated with this deferred object.
  54779. */
  54780. readonly promise: Promise<T>;
  54781. private _resolve;
  54782. private _reject;
  54783. /**
  54784. * The resolve method of the promise associated with this deferred object.
  54785. */
  54786. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54787. /**
  54788. * The reject method of the promise associated with this deferred object.
  54789. */
  54790. readonly reject: (reason?: any) => void;
  54791. /**
  54792. * Constructor for this deferred object.
  54793. */
  54794. constructor();
  54795. }
  54796. }
  54797. declare module BABYLON {
  54798. /**
  54799. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  54800. */
  54801. export class MeshExploder {
  54802. private _centerMesh;
  54803. private _meshes;
  54804. private _meshesOrigins;
  54805. private _toCenterVectors;
  54806. private _scaledDirection;
  54807. private _newPosition;
  54808. private _centerPosition;
  54809. /**
  54810. * Explodes meshes from a center mesh.
  54811. * @param meshes The meshes to explode.
  54812. * @param centerMesh The mesh to be center of explosion.
  54813. */
  54814. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  54815. private _setCenterMesh;
  54816. /**
  54817. * Get class name
  54818. * @returns "MeshExploder"
  54819. */
  54820. getClassName(): string;
  54821. /**
  54822. * "Exploded meshes"
  54823. * @returns Array of meshes with the centerMesh at index 0.
  54824. */
  54825. getMeshes(): Array<Mesh>;
  54826. /**
  54827. * Explodes meshes giving a specific direction
  54828. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  54829. */
  54830. explode(direction?: number): void;
  54831. }
  54832. }
  54833. declare module BABYLON {
  54834. /**
  54835. * Class used to help managing file picking and drag'n'drop
  54836. */
  54837. export class FilesInput {
  54838. /**
  54839. * List of files ready to be loaded
  54840. */
  54841. static readonly FilesToLoad: {
  54842. [key: string]: File;
  54843. };
  54844. /**
  54845. * Callback called when a file is processed
  54846. */
  54847. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  54848. private _engine;
  54849. private _currentScene;
  54850. private _sceneLoadedCallback;
  54851. private _progressCallback;
  54852. private _additionalRenderLoopLogicCallback;
  54853. private _textureLoadingCallback;
  54854. private _startingProcessingFilesCallback;
  54855. private _onReloadCallback;
  54856. private _errorCallback;
  54857. private _elementToMonitor;
  54858. private _sceneFileToLoad;
  54859. private _filesToLoad;
  54860. /**
  54861. * Creates a new FilesInput
  54862. * @param engine defines the rendering engine
  54863. * @param scene defines the hosting scene
  54864. * @param sceneLoadedCallback callback called when scene is loaded
  54865. * @param progressCallback callback called to track progress
  54866. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  54867. * @param textureLoadingCallback callback called when a texture is loading
  54868. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  54869. * @param onReloadCallback callback called when a reload is requested
  54870. * @param errorCallback callback call if an error occurs
  54871. */
  54872. 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);
  54873. private _dragEnterHandler;
  54874. private _dragOverHandler;
  54875. private _dropHandler;
  54876. /**
  54877. * Calls this function to listen to drag'n'drop events on a specific DOM element
  54878. * @param elementToMonitor defines the DOM element to track
  54879. */
  54880. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  54881. /**
  54882. * Release all associated resources
  54883. */
  54884. dispose(): void;
  54885. private renderFunction;
  54886. private drag;
  54887. private drop;
  54888. private _traverseFolder;
  54889. private _processFiles;
  54890. /**
  54891. * Load files from a drop event
  54892. * @param event defines the drop event to use as source
  54893. */
  54894. loadFiles(event: any): void;
  54895. private _processReload;
  54896. /**
  54897. * Reload the current scene from the loaded files
  54898. */
  54899. reload(): void;
  54900. }
  54901. }
  54902. declare module BABYLON {
  54903. /**
  54904. * Defines the root class used to create scene optimization to use with SceneOptimizer
  54905. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54906. */
  54907. export class SceneOptimization {
  54908. /**
  54909. * Defines the priority of this optimization (0 by default which means first in the list)
  54910. */
  54911. priority: number;
  54912. /**
  54913. * Gets a string describing the action executed by the current optimization
  54914. * @returns description string
  54915. */
  54916. getDescription(): string;
  54917. /**
  54918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54919. * @param scene defines the current scene where to apply this optimization
  54920. * @param optimizer defines the current optimizer
  54921. * @returns true if everything that can be done was applied
  54922. */
  54923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54924. /**
  54925. * Creates the SceneOptimization object
  54926. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54927. * @param desc defines the description associated with the optimization
  54928. */
  54929. constructor(
  54930. /**
  54931. * Defines the priority of this optimization (0 by default which means first in the list)
  54932. */
  54933. priority?: number);
  54934. }
  54935. /**
  54936. * Defines an optimization used to reduce the size of render target textures
  54937. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54938. */
  54939. export class TextureOptimization extends SceneOptimization {
  54940. /**
  54941. * Defines the priority of this optimization (0 by default which means first in the list)
  54942. */
  54943. priority: number;
  54944. /**
  54945. * 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
  54946. */
  54947. maximumSize: number;
  54948. /**
  54949. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54950. */
  54951. step: number;
  54952. /**
  54953. * Gets a string describing the action executed by the current optimization
  54954. * @returns description string
  54955. */
  54956. getDescription(): string;
  54957. /**
  54958. * Creates the TextureOptimization object
  54959. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54960. * @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
  54961. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54962. */
  54963. constructor(
  54964. /**
  54965. * Defines the priority of this optimization (0 by default which means first in the list)
  54966. */
  54967. priority?: number,
  54968. /**
  54969. * 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
  54970. */
  54971. maximumSize?: number,
  54972. /**
  54973. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54974. */
  54975. step?: number);
  54976. /**
  54977. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54978. * @param scene defines the current scene where to apply this optimization
  54979. * @param optimizer defines the current optimizer
  54980. * @returns true if everything that can be done was applied
  54981. */
  54982. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54983. }
  54984. /**
  54985. * Defines an optimization used to increase or decrease the rendering resolution
  54986. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54987. */
  54988. export class HardwareScalingOptimization extends SceneOptimization {
  54989. /**
  54990. * Defines the priority of this optimization (0 by default which means first in the list)
  54991. */
  54992. priority: number;
  54993. /**
  54994. * Defines the maximum scale to use (2 by default)
  54995. */
  54996. maximumScale: number;
  54997. /**
  54998. * Defines the step to use between two passes (0.5 by default)
  54999. */
  55000. step: number;
  55001. private _currentScale;
  55002. private _directionOffset;
  55003. /**
  55004. * Gets a string describing the action executed by the current optimization
  55005. * @return description string
  55006. */
  55007. getDescription(): string;
  55008. /**
  55009. * Creates the HardwareScalingOptimization object
  55010. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55011. * @param maximumScale defines the maximum scale to use (2 by default)
  55012. * @param step defines the step to use between two passes (0.5 by default)
  55013. */
  55014. constructor(
  55015. /**
  55016. * Defines the priority of this optimization (0 by default which means first in the list)
  55017. */
  55018. priority?: number,
  55019. /**
  55020. * Defines the maximum scale to use (2 by default)
  55021. */
  55022. maximumScale?: number,
  55023. /**
  55024. * Defines the step to use between two passes (0.5 by default)
  55025. */
  55026. step?: number);
  55027. /**
  55028. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55029. * @param scene defines the current scene where to apply this optimization
  55030. * @param optimizer defines the current optimizer
  55031. * @returns true if everything that can be done was applied
  55032. */
  55033. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55034. }
  55035. /**
  55036. * Defines an optimization used to remove shadows
  55037. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55038. */
  55039. export class ShadowsOptimization extends SceneOptimization {
  55040. /**
  55041. * Gets a string describing the action executed by the current optimization
  55042. * @return description string
  55043. */
  55044. getDescription(): string;
  55045. /**
  55046. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55047. * @param scene defines the current scene where to apply this optimization
  55048. * @param optimizer defines the current optimizer
  55049. * @returns true if everything that can be done was applied
  55050. */
  55051. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55052. }
  55053. /**
  55054. * Defines an optimization used to turn post-processes off
  55055. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55056. */
  55057. export class PostProcessesOptimization extends SceneOptimization {
  55058. /**
  55059. * Gets a string describing the action executed by the current optimization
  55060. * @return description string
  55061. */
  55062. getDescription(): string;
  55063. /**
  55064. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55065. * @param scene defines the current scene where to apply this optimization
  55066. * @param optimizer defines the current optimizer
  55067. * @returns true if everything that can be done was applied
  55068. */
  55069. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55070. }
  55071. /**
  55072. * Defines an optimization used to turn lens flares off
  55073. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55074. */
  55075. export class LensFlaresOptimization extends SceneOptimization {
  55076. /**
  55077. * Gets a string describing the action executed by the current optimization
  55078. * @return description string
  55079. */
  55080. getDescription(): string;
  55081. /**
  55082. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55083. * @param scene defines the current scene where to apply this optimization
  55084. * @param optimizer defines the current optimizer
  55085. * @returns true if everything that can be done was applied
  55086. */
  55087. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55088. }
  55089. /**
  55090. * Defines an optimization based on user defined callback.
  55091. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55092. */
  55093. export class CustomOptimization extends SceneOptimization {
  55094. /**
  55095. * Callback called to apply the custom optimization.
  55096. */
  55097. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55098. /**
  55099. * Callback called to get custom description
  55100. */
  55101. onGetDescription: () => string;
  55102. /**
  55103. * Gets a string describing the action executed by the current optimization
  55104. * @returns description string
  55105. */
  55106. getDescription(): string;
  55107. /**
  55108. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55109. * @param scene defines the current scene where to apply this optimization
  55110. * @param optimizer defines the current optimizer
  55111. * @returns true if everything that can be done was applied
  55112. */
  55113. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55114. }
  55115. /**
  55116. * Defines an optimization used to turn particles off
  55117. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55118. */
  55119. export class ParticlesOptimization extends SceneOptimization {
  55120. /**
  55121. * Gets a string describing the action executed by the current optimization
  55122. * @return description string
  55123. */
  55124. getDescription(): string;
  55125. /**
  55126. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55127. * @param scene defines the current scene where to apply this optimization
  55128. * @param optimizer defines the current optimizer
  55129. * @returns true if everything that can be done was applied
  55130. */
  55131. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55132. }
  55133. /**
  55134. * Defines an optimization used to turn render targets off
  55135. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55136. */
  55137. export class RenderTargetsOptimization extends SceneOptimization {
  55138. /**
  55139. * Gets a string describing the action executed by the current optimization
  55140. * @return description string
  55141. */
  55142. getDescription(): string;
  55143. /**
  55144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55145. * @param scene defines the current scene where to apply this optimization
  55146. * @param optimizer defines the current optimizer
  55147. * @returns true if everything that can be done was applied
  55148. */
  55149. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55150. }
  55151. /**
  55152. * Defines an optimization used to merge meshes with compatible materials
  55153. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55154. */
  55155. export class MergeMeshesOptimization extends SceneOptimization {
  55156. private static _UpdateSelectionTree;
  55157. /**
  55158. * Gets or sets a boolean which defines if optimization octree has to be updated
  55159. */
  55160. /**
  55161. * Gets or sets a boolean which defines if optimization octree has to be updated
  55162. */
  55163. static UpdateSelectionTree: boolean;
  55164. /**
  55165. * Gets a string describing the action executed by the current optimization
  55166. * @return description string
  55167. */
  55168. getDescription(): string;
  55169. private _canBeMerged;
  55170. /**
  55171. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55172. * @param scene defines the current scene where to apply this optimization
  55173. * @param optimizer defines the current optimizer
  55174. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55175. * @returns true if everything that can be done was applied
  55176. */
  55177. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55178. }
  55179. /**
  55180. * Defines a list of options used by SceneOptimizer
  55181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55182. */
  55183. export class SceneOptimizerOptions {
  55184. /**
  55185. * Defines the target frame rate to reach (60 by default)
  55186. */
  55187. targetFrameRate: number;
  55188. /**
  55189. * Defines the interval between two checkes (2000ms by default)
  55190. */
  55191. trackerDuration: number;
  55192. /**
  55193. * Gets the list of optimizations to apply
  55194. */
  55195. optimizations: SceneOptimization[];
  55196. /**
  55197. * Creates a new list of options used by SceneOptimizer
  55198. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55199. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55200. */
  55201. constructor(
  55202. /**
  55203. * Defines the target frame rate to reach (60 by default)
  55204. */
  55205. targetFrameRate?: number,
  55206. /**
  55207. * Defines the interval between two checkes (2000ms by default)
  55208. */
  55209. trackerDuration?: number);
  55210. /**
  55211. * Add a new optimization
  55212. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55213. * @returns the current SceneOptimizerOptions
  55214. */
  55215. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55216. /**
  55217. * Add a new custom optimization
  55218. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55219. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55220. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55221. * @returns the current SceneOptimizerOptions
  55222. */
  55223. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55224. /**
  55225. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55226. * @param targetFrameRate defines the target frame rate (60 by default)
  55227. * @returns a SceneOptimizerOptions object
  55228. */
  55229. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55230. /**
  55231. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55232. * @param targetFrameRate defines the target frame rate (60 by default)
  55233. * @returns a SceneOptimizerOptions object
  55234. */
  55235. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55236. /**
  55237. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55238. * @param targetFrameRate defines the target frame rate (60 by default)
  55239. * @returns a SceneOptimizerOptions object
  55240. */
  55241. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55242. }
  55243. /**
  55244. * Class used to run optimizations in order to reach a target frame rate
  55245. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55246. */
  55247. export class SceneOptimizer implements IDisposable {
  55248. private _isRunning;
  55249. private _options;
  55250. private _scene;
  55251. private _currentPriorityLevel;
  55252. private _targetFrameRate;
  55253. private _trackerDuration;
  55254. private _currentFrameRate;
  55255. private _sceneDisposeObserver;
  55256. private _improvementMode;
  55257. /**
  55258. * Defines an observable called when the optimizer reaches the target frame rate
  55259. */
  55260. onSuccessObservable: Observable<SceneOptimizer>;
  55261. /**
  55262. * Defines an observable called when the optimizer enables an optimization
  55263. */
  55264. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55265. /**
  55266. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55267. */
  55268. onFailureObservable: Observable<SceneOptimizer>;
  55269. /**
  55270. * Gets a boolean indicating if the optimizer is in improvement mode
  55271. */
  55272. readonly isInImprovementMode: boolean;
  55273. /**
  55274. * Gets the current priority level (0 at start)
  55275. */
  55276. readonly currentPriorityLevel: number;
  55277. /**
  55278. * Gets the current frame rate checked by the SceneOptimizer
  55279. */
  55280. readonly currentFrameRate: number;
  55281. /**
  55282. * Gets or sets the current target frame rate (60 by default)
  55283. */
  55284. /**
  55285. * Gets or sets the current target frame rate (60 by default)
  55286. */
  55287. targetFrameRate: number;
  55288. /**
  55289. * Gets or sets the current interval between two checks (every 2000ms by default)
  55290. */
  55291. /**
  55292. * Gets or sets the current interval between two checks (every 2000ms by default)
  55293. */
  55294. trackerDuration: number;
  55295. /**
  55296. * Gets the list of active optimizations
  55297. */
  55298. readonly optimizations: SceneOptimization[];
  55299. /**
  55300. * Creates a new SceneOptimizer
  55301. * @param scene defines the scene to work on
  55302. * @param options defines the options to use with the SceneOptimizer
  55303. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55304. * @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)
  55305. */
  55306. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55307. /**
  55308. * Stops the current optimizer
  55309. */
  55310. stop(): void;
  55311. /**
  55312. * Reset the optimizer to initial step (current priority level = 0)
  55313. */
  55314. reset(): void;
  55315. /**
  55316. * Start the optimizer. By default it will try to reach a specific framerate
  55317. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55318. */
  55319. start(): void;
  55320. private _checkCurrentState;
  55321. /**
  55322. * Release all resources
  55323. */
  55324. dispose(): void;
  55325. /**
  55326. * Helper function to create a SceneOptimizer with one single line of code
  55327. * @param scene defines the scene to work on
  55328. * @param options defines the options to use with the SceneOptimizer
  55329. * @param onSuccess defines a callback to call on success
  55330. * @param onFailure defines a callback to call on failure
  55331. * @returns the new SceneOptimizer object
  55332. */
  55333. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55334. }
  55335. }
  55336. declare module BABYLON {
  55337. /**
  55338. * Class used to serialize a scene into a string
  55339. */
  55340. export class SceneSerializer {
  55341. /**
  55342. * Clear cache used by a previous serialization
  55343. */
  55344. static ClearCache(): void;
  55345. /**
  55346. * Serialize a scene into a JSON compatible object
  55347. * @param scene defines the scene to serialize
  55348. * @returns a JSON compatible object
  55349. */
  55350. static Serialize(scene: Scene): any;
  55351. /**
  55352. * Serialize a mesh into a JSON compatible object
  55353. * @param toSerialize defines the mesh to serialize
  55354. * @param withParents defines if parents must be serialized as well
  55355. * @param withChildren defines if children must be serialized as well
  55356. * @returns a JSON compatible object
  55357. */
  55358. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55359. }
  55360. }
  55361. declare module BABYLON {
  55362. /**
  55363. * Class used to host texture specific utilities
  55364. */
  55365. export class TextureTools {
  55366. /**
  55367. * Uses the GPU to create a copy texture rescaled at a given size
  55368. * @param texture Texture to copy from
  55369. * @param width defines the desired width
  55370. * @param height defines the desired height
  55371. * @param useBilinearMode defines if bilinear mode has to be used
  55372. * @return the generated texture
  55373. */
  55374. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55375. }
  55376. }
  55377. declare module BABYLON {
  55378. /**
  55379. * This represents the different options avilable for the video capture.
  55380. */
  55381. export interface VideoRecorderOptions {
  55382. /** Defines the mime type of the video */
  55383. mimeType: string;
  55384. /** Defines the video the video should be recorded at */
  55385. fps: number;
  55386. /** Defines the chunk size for the recording data */
  55387. recordChunckSize: number;
  55388. /** The audio tracks to attach to the record */
  55389. audioTracks?: MediaStreamTrack[];
  55390. }
  55391. /**
  55392. * This can helps recording videos from BabylonJS.
  55393. * This is based on the available WebRTC functionalities of the browser.
  55394. *
  55395. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55396. */
  55397. export class VideoRecorder {
  55398. private static readonly _defaultOptions;
  55399. /**
  55400. * Returns wehther or not the VideoRecorder is available in your browser.
  55401. * @param engine Defines the Babylon Engine to check the support for
  55402. * @returns true if supported otherwise false
  55403. */
  55404. static IsSupported(engine: Engine): boolean;
  55405. private readonly _options;
  55406. private _canvas;
  55407. private _mediaRecorder;
  55408. private _recordedChunks;
  55409. private _fileName;
  55410. private _resolve;
  55411. private _reject;
  55412. /**
  55413. * True wether a recording is already in progress.
  55414. */
  55415. readonly isRecording: boolean;
  55416. /**
  55417. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55418. * a video file.
  55419. * @param engine Defines the BabylonJS Engine you wish to record
  55420. * @param options Defines options that can be used to customized the capture
  55421. */
  55422. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55423. /**
  55424. * Stops the current recording before the default capture timeout passed in the startRecording
  55425. * functions.
  55426. */
  55427. stopRecording(): void;
  55428. /**
  55429. * Starts recording the canvas for a max duration specified in parameters.
  55430. * @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.
  55431. * @param maxDuration Defines the maximum recording time in seconds.
  55432. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55433. * @return a promise callback at the end of the recording with the video data in Blob.
  55434. */
  55435. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55436. /**
  55437. * Releases internal resources used during the recording.
  55438. */
  55439. dispose(): void;
  55440. private _handleDataAvailable;
  55441. private _handleError;
  55442. private _handleStop;
  55443. }
  55444. }
  55445. declare module BABYLON {
  55446. /**
  55447. * Class containing a set of static utilities functions for screenshots
  55448. */
  55449. export class ScreenshotTools {
  55450. /**
  55451. * Captures a screenshot of the current rendering
  55452. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55453. * @param engine defines the rendering engine
  55454. * @param camera defines the source camera
  55455. * @param size This parameter can be set to a single number or to an object with the
  55456. * following (optional) properties: precision, width, height. If a single number is passed,
  55457. * it will be used for both width and height. If an object is passed, the screenshot size
  55458. * will be derived from the parameters. The precision property is a multiplier allowing
  55459. * rendering at a higher or lower resolution
  55460. * @param successCallback defines the callback receives a single parameter which contains the
  55461. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55462. * src parameter of an <img> to display it
  55463. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55464. * Check your browser for supported MIME types
  55465. */
  55466. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55467. /**
  55468. * Generates an image screenshot from the specified camera.
  55469. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55470. * @param engine The engine to use for rendering
  55471. * @param camera The camera to use for rendering
  55472. * @param size This parameter can be set to a single number or to an object with the
  55473. * following (optional) properties: precision, width, height. If a single number is passed,
  55474. * it will be used for both width and height. If an object is passed, the screenshot size
  55475. * will be derived from the parameters. The precision property is a multiplier allowing
  55476. * rendering at a higher or lower resolution
  55477. * @param successCallback The callback receives a single parameter which contains the
  55478. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55479. * src parameter of an <img> to display it
  55480. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55481. * Check your browser for supported MIME types
  55482. * @param samples Texture samples (default: 1)
  55483. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55484. * @param fileName A name for for the downloaded file.
  55485. */
  55486. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55487. }
  55488. }
  55489. declare module BABYLON {
  55490. /**
  55491. * A cursor which tracks a point on a path
  55492. */
  55493. export class PathCursor {
  55494. private path;
  55495. /**
  55496. * Stores path cursor callbacks for when an onchange event is triggered
  55497. */
  55498. private _onchange;
  55499. /**
  55500. * The value of the path cursor
  55501. */
  55502. value: number;
  55503. /**
  55504. * The animation array of the path cursor
  55505. */
  55506. animations: Animation[];
  55507. /**
  55508. * Initializes the path cursor
  55509. * @param path The path to track
  55510. */
  55511. constructor(path: Path2);
  55512. /**
  55513. * Gets the cursor point on the path
  55514. * @returns A point on the path cursor at the cursor location
  55515. */
  55516. getPoint(): Vector3;
  55517. /**
  55518. * Moves the cursor ahead by the step amount
  55519. * @param step The amount to move the cursor forward
  55520. * @returns This path cursor
  55521. */
  55522. moveAhead(step?: number): PathCursor;
  55523. /**
  55524. * Moves the cursor behind by the step amount
  55525. * @param step The amount to move the cursor back
  55526. * @returns This path cursor
  55527. */
  55528. moveBack(step?: number): PathCursor;
  55529. /**
  55530. * Moves the cursor by the step amount
  55531. * If the step amount is greater than one, an exception is thrown
  55532. * @param step The amount to move the cursor
  55533. * @returns This path cursor
  55534. */
  55535. move(step: number): PathCursor;
  55536. /**
  55537. * Ensures that the value is limited between zero and one
  55538. * @returns This path cursor
  55539. */
  55540. private ensureLimits;
  55541. /**
  55542. * Runs onchange callbacks on change (used by the animation engine)
  55543. * @returns This path cursor
  55544. */
  55545. private raiseOnChange;
  55546. /**
  55547. * Executes a function on change
  55548. * @param f A path cursor onchange callback
  55549. * @returns This path cursor
  55550. */
  55551. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55552. }
  55553. }
  55554. declare module BABYLON {
  55555. /** @hidden */
  55556. export var blurPixelShader: {
  55557. name: string;
  55558. shader: string;
  55559. };
  55560. }
  55561. declare module BABYLON {
  55562. /** @hidden */
  55563. export var bones300Declaration: {
  55564. name: string;
  55565. shader: string;
  55566. };
  55567. }
  55568. declare module BABYLON {
  55569. /** @hidden */
  55570. export var instances300Declaration: {
  55571. name: string;
  55572. shader: string;
  55573. };
  55574. }
  55575. declare module BABYLON {
  55576. /** @hidden */
  55577. export var pointCloudVertexDeclaration: {
  55578. name: string;
  55579. shader: string;
  55580. };
  55581. }
  55582. // Mixins
  55583. interface Window {
  55584. mozIndexedDB: IDBFactory;
  55585. webkitIndexedDB: IDBFactory;
  55586. msIndexedDB: IDBFactory;
  55587. webkitURL: typeof URL;
  55588. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55589. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55590. WebGLRenderingContext: WebGLRenderingContext;
  55591. MSGesture: MSGesture;
  55592. CANNON: any;
  55593. AudioContext: AudioContext;
  55594. webkitAudioContext: AudioContext;
  55595. PointerEvent: any;
  55596. Math: Math;
  55597. Uint8Array: Uint8ArrayConstructor;
  55598. Float32Array: Float32ArrayConstructor;
  55599. mozURL: typeof URL;
  55600. msURL: typeof URL;
  55601. VRFrameData: any; // WebVR, from specs 1.1
  55602. DracoDecoderModule: any;
  55603. setImmediate(handler: (...args: any[]) => void): number;
  55604. }
  55605. interface HTMLCanvasElement {
  55606. requestPointerLock(): void;
  55607. msRequestPointerLock?(): void;
  55608. mozRequestPointerLock?(): void;
  55609. webkitRequestPointerLock?(): void;
  55610. /** Track wether a record is in progress */
  55611. isRecording: boolean;
  55612. /** Capture Stream method defined by some browsers */
  55613. captureStream(fps?: number): MediaStream;
  55614. }
  55615. interface CanvasRenderingContext2D {
  55616. msImageSmoothingEnabled: boolean;
  55617. }
  55618. interface MouseEvent {
  55619. mozMovementX: number;
  55620. mozMovementY: number;
  55621. webkitMovementX: number;
  55622. webkitMovementY: number;
  55623. msMovementX: number;
  55624. msMovementY: number;
  55625. }
  55626. interface Navigator {
  55627. mozGetVRDevices: (any: any) => any;
  55628. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55629. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55630. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55631. webkitGetGamepads(): Gamepad[];
  55632. msGetGamepads(): Gamepad[];
  55633. webkitGamepads(): Gamepad[];
  55634. }
  55635. interface HTMLVideoElement {
  55636. mozSrcObject: any;
  55637. }
  55638. interface Math {
  55639. fround(x: number): number;
  55640. imul(a: number, b: number): number;
  55641. }
  55642. interface WebGLProgram {
  55643. context?: WebGLRenderingContext;
  55644. vertexShader?: WebGLShader;
  55645. fragmentShader?: WebGLShader;
  55646. isParallelCompiled: boolean;
  55647. onCompiled?: () => void;
  55648. }
  55649. interface WebGLRenderingContext {
  55650. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55651. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55652. vertexAttribDivisor(index: number, divisor: number): void;
  55653. createVertexArray(): any;
  55654. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55655. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55656. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55657. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55658. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55659. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55660. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55661. // Queries
  55662. createQuery(): WebGLQuery;
  55663. deleteQuery(query: WebGLQuery): void;
  55664. beginQuery(target: number, query: WebGLQuery): void;
  55665. endQuery(target: number): void;
  55666. getQueryParameter(query: WebGLQuery, pname: number): any;
  55667. getQuery(target: number, pname: number): any;
  55668. MAX_SAMPLES: number;
  55669. RGBA8: number;
  55670. READ_FRAMEBUFFER: number;
  55671. DRAW_FRAMEBUFFER: number;
  55672. UNIFORM_BUFFER: number;
  55673. HALF_FLOAT_OES: number;
  55674. RGBA16F: number;
  55675. RGBA32F: number;
  55676. R32F: number;
  55677. RG32F: number;
  55678. RGB32F: number;
  55679. R16F: number;
  55680. RG16F: number;
  55681. RGB16F: number;
  55682. RED: number;
  55683. RG: number;
  55684. R8: number;
  55685. RG8: number;
  55686. UNSIGNED_INT_24_8: number;
  55687. DEPTH24_STENCIL8: number;
  55688. /* Multiple Render Targets */
  55689. drawBuffers(buffers: number[]): void;
  55690. readBuffer(src: number): void;
  55691. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55692. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55693. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55694. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55695. // Occlusion Query
  55696. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55697. ANY_SAMPLES_PASSED: number;
  55698. QUERY_RESULT_AVAILABLE: number;
  55699. QUERY_RESULT: number;
  55700. }
  55701. interface WebGLBuffer {
  55702. references: number;
  55703. capacity: number;
  55704. is32Bits: boolean;
  55705. }
  55706. interface WebGLProgram {
  55707. transformFeedback?: WebGLTransformFeedback | null; private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55708. }
  55709. interface EXT_disjoint_timer_query {
  55710. QUERY_COUNTER_BITS_EXT: number;
  55711. TIME_ELAPSED_EXT: number;
  55712. TIMESTAMP_EXT: number;
  55713. GPU_DISJOINT_EXT: number;
  55714. QUERY_RESULT_EXT: number;
  55715. QUERY_RESULT_AVAILABLE_EXT: number;
  55716. queryCounterEXT(query: WebGLQuery, target: number): void;
  55717. createQueryEXT(): WebGLQuery;
  55718. beginQueryEXT(target: number, query: WebGLQuery): void;
  55719. endQueryEXT(target: number): void;
  55720. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55721. deleteQueryEXT(query: WebGLQuery): void;
  55722. }
  55723. interface WebGLUniformLocation { currentState: any;
  55724. }
  55725. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55726. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55727. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55728. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55729. interface WebGLRenderingContext {
  55730. readonly RASTERIZER_DISCARD: number;
  55731. readonly DEPTH_COMPONENT24: number;
  55732. readonly TEXTURE_3D: number;
  55733. readonly TEXTURE_2D_ARRAY: number;
  55734. readonly TEXTURE_COMPARE_FUNC: number;
  55735. readonly TEXTURE_COMPARE_MODE: number;
  55736. readonly COMPARE_REF_TO_TEXTURE: number;
  55737. readonly TEXTURE_WRAP_R: number;
  55738. readonly HALF_FLOAT: number;
  55739. readonly RGB8: number;
  55740. readonly RED_INTEGER: number;
  55741. readonly RG_INTEGER: number;
  55742. readonly RGB_INTEGER: number;
  55743. readonly RGBA_INTEGER: number;
  55744. readonly R8_SNORM: number;
  55745. readonly RG8_SNORM: number;
  55746. readonly RGB8_SNORM: number;
  55747. readonly RGBA8_SNORM: number;
  55748. readonly R8I: number;
  55749. readonly RG8I: number;
  55750. readonly RGB8I: number;
  55751. readonly RGBA8I: number;
  55752. readonly R8UI: number;
  55753. readonly RG8UI: number;
  55754. readonly RGB8UI: number;
  55755. readonly RGBA8UI: number;
  55756. readonly R16I: number;
  55757. readonly RG16I: number;
  55758. readonly RGB16I: number;
  55759. readonly RGBA16I: number;
  55760. readonly R16UI: number;
  55761. readonly RG16UI: number;
  55762. readonly RGB16UI: number;
  55763. readonly RGBA16UI: number;
  55764. readonly R32I: number;
  55765. readonly RG32I: number;
  55766. readonly RGB32I: number;
  55767. readonly RGBA32I: number;
  55768. readonly R32UI: number;
  55769. readonly RG32UI: number;
  55770. readonly RGB32UI: number;
  55771. readonly RGBA32UI: number;
  55772. readonly RGB10_A2UI: number;
  55773. readonly R11F_G11F_B10F: number;
  55774. readonly RGB9_E5: number;
  55775. readonly RGB10_A2: number;
  55776. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55777. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55778. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55779. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55780. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55781. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55782. 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;
  55783. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55784. readonly TRANSFORM_FEEDBACK: number;
  55785. readonly INTERLEAVED_ATTRIBS: number;
  55786. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55787. createTransformFeedback(): WebGLTransformFeedback;
  55788. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55789. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55790. beginTransformFeedback(primitiveMode: number): void;
  55791. endTransformFeedback(): void;
  55792. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55793. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55794. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55795. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55796. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55797. }
  55798. interface ImageBitmap {
  55799. readonly width: number;
  55800. readonly height: number;
  55801. close(): void;
  55802. }
  55803. interface WebGLQuery extends WebGLObject {
  55804. }
  55805. declare var WebGLQuery: {
  55806. prototype: WebGLQuery;
  55807. new(): WebGLQuery;
  55808. };
  55809. interface WebGLSampler extends WebGLObject {
  55810. }
  55811. declare var WebGLSampler: {
  55812. prototype: WebGLSampler;
  55813. new(): WebGLSampler;
  55814. };
  55815. interface WebGLSync extends WebGLObject {
  55816. }
  55817. declare var WebGLSync: {
  55818. prototype: WebGLSync;
  55819. new(): WebGLSync;
  55820. };
  55821. interface WebGLTransformFeedback extends WebGLObject {
  55822. }
  55823. declare var WebGLTransformFeedback: {
  55824. prototype: WebGLTransformFeedback;
  55825. new(): WebGLTransformFeedback;
  55826. };
  55827. interface WebGLVertexArrayObject extends WebGLObject {
  55828. }
  55829. declare var WebGLVertexArrayObject: {
  55830. prototype: WebGLVertexArrayObject;
  55831. new(): WebGLVertexArrayObject;
  55832. };
  55833. // Type definitions for WebVR API
  55834. // Project: https://w3c.github.io/webvr/
  55835. // Definitions by: six a <https://github.com/lostfictions>
  55836. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55837. interface VRDisplay extends EventTarget {
  55838. /**
  55839. * Dictionary of capabilities describing the VRDisplay.
  55840. */
  55841. readonly capabilities: VRDisplayCapabilities;
  55842. /**
  55843. * z-depth defining the far plane of the eye view frustum
  55844. * enables mapping of values in the render target depth
  55845. * attachment to scene coordinates. Initially set to 10000.0.
  55846. */
  55847. depthFar: number;
  55848. /**
  55849. * z-depth defining the near plane of the eye view frustum
  55850. * enables mapping of values in the render target depth
  55851. * attachment to scene coordinates. Initially set to 0.01.
  55852. */
  55853. depthNear: number;
  55854. /**
  55855. * An identifier for this distinct VRDisplay. Used as an
  55856. * association point in the Gamepad API.
  55857. */
  55858. readonly displayId: number;
  55859. /**
  55860. * A display name, a user-readable name identifying it.
  55861. */
  55862. readonly displayName: string;
  55863. readonly isConnected: boolean;
  55864. readonly isPresenting: boolean;
  55865. /**
  55866. * If this VRDisplay supports room-scale experiences, the optional
  55867. * stage attribute contains details on the room-scale parameters.
  55868. */
  55869. readonly stageParameters: VRStageParameters | null;
  55870. /**
  55871. * Passing the value returned by `requestAnimationFrame` to
  55872. * `cancelAnimationFrame` will unregister the callback.
  55873. * @param handle Define the hanle of the request to cancel
  55874. */
  55875. cancelAnimationFrame(handle: number): void;
  55876. /**
  55877. * Stops presenting to the VRDisplay.
  55878. * @returns a promise to know when it stopped
  55879. */
  55880. exitPresent(): Promise<void>;
  55881. /**
  55882. * Return the current VREyeParameters for the given eye.
  55883. * @param whichEye Define the eye we want the parameter for
  55884. * @returns the eye parameters
  55885. */
  55886. getEyeParameters(whichEye: string): VREyeParameters;
  55887. /**
  55888. * Populates the passed VRFrameData with the information required to render
  55889. * the current frame.
  55890. * @param frameData Define the data structure to populate
  55891. * @returns true if ok otherwise false
  55892. */
  55893. getFrameData(frameData: VRFrameData): boolean;
  55894. /**
  55895. * Get the layers currently being presented.
  55896. * @returns the list of VR layers
  55897. */
  55898. getLayers(): VRLayer[];
  55899. /**
  55900. * Return a VRPose containing the future predicted pose of the VRDisplay
  55901. * when the current frame will be presented. The value returned will not
  55902. * change until JavaScript has returned control to the browser.
  55903. *
  55904. * The VRPose will contain the position, orientation, velocity,
  55905. * and acceleration of each of these properties.
  55906. * @returns the pose object
  55907. */
  55908. getPose(): VRPose;
  55909. /**
  55910. * Return the current instantaneous pose of the VRDisplay, with no
  55911. * prediction applied.
  55912. * @returns the current instantaneous pose
  55913. */
  55914. getImmediatePose(): VRPose;
  55915. /**
  55916. * The callback passed to `requestAnimationFrame` will be called
  55917. * any time a new frame should be rendered. When the VRDisplay is
  55918. * presenting the callback will be called at the native refresh
  55919. * rate of the HMD. When not presenting this function acts
  55920. * identically to how window.requestAnimationFrame acts. Content should
  55921. * make no assumptions of frame rate or vsync behavior as the HMD runs
  55922. * asynchronously from other displays and at differing refresh rates.
  55923. * @param callback Define the eaction to run next frame
  55924. * @returns the request handle it
  55925. */
  55926. requestAnimationFrame(callback: FrameRequestCallback): number;
  55927. /**
  55928. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  55929. * Repeat calls while already presenting will update the VRLayers being displayed.
  55930. * @param layers Define the list of layer to present
  55931. * @returns a promise to know when the request has been fulfilled
  55932. */
  55933. requestPresent(layers: VRLayer[]): Promise<void>;
  55934. /**
  55935. * Reset the pose for this display, treating its current position and
  55936. * orientation as the "origin/zero" values. VRPose.position,
  55937. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  55938. * updated when calling resetPose(). This should be called in only
  55939. * sitting-space experiences.
  55940. */
  55941. resetPose(): void;
  55942. /**
  55943. * The VRLayer provided to the VRDisplay will be captured and presented
  55944. * in the HMD. Calling this function has the same effect on the source
  55945. * canvas as any other operation that uses its source image, and canvases
  55946. * created without preserveDrawingBuffer set to true will be cleared.
  55947. * @param pose Define the pose to submit
  55948. */
  55949. submitFrame(pose?: VRPose): void;
  55950. }
  55951. declare var VRDisplay: {
  55952. prototype: VRDisplay;
  55953. new(): VRDisplay;
  55954. };
  55955. interface VRLayer {
  55956. leftBounds?: number[] | Float32Array | null;
  55957. rightBounds?: number[] | Float32Array | null;
  55958. source?: HTMLCanvasElement | null;
  55959. }
  55960. interface VRDisplayCapabilities {
  55961. readonly canPresent: boolean;
  55962. readonly hasExternalDisplay: boolean;
  55963. readonly hasOrientation: boolean;
  55964. readonly hasPosition: boolean;
  55965. readonly maxLayers: number;
  55966. }
  55967. interface VREyeParameters {
  55968. /** @deprecated */
  55969. readonly fieldOfView: VRFieldOfView;
  55970. readonly offset: Float32Array;
  55971. readonly renderHeight: number;
  55972. readonly renderWidth: number;
  55973. }
  55974. interface VRFieldOfView {
  55975. readonly downDegrees: number;
  55976. readonly leftDegrees: number;
  55977. readonly rightDegrees: number;
  55978. readonly upDegrees: number;
  55979. }
  55980. interface VRFrameData {
  55981. readonly leftProjectionMatrix: Float32Array;
  55982. readonly leftViewMatrix: Float32Array;
  55983. readonly pose: VRPose;
  55984. readonly rightProjectionMatrix: Float32Array;
  55985. readonly rightViewMatrix: Float32Array;
  55986. readonly timestamp: number;
  55987. }
  55988. interface VRPose {
  55989. readonly angularAcceleration: Float32Array | null;
  55990. readonly angularVelocity: Float32Array | null;
  55991. readonly linearAcceleration: Float32Array | null;
  55992. readonly linearVelocity: Float32Array | null;
  55993. readonly orientation: Float32Array | null;
  55994. readonly position: Float32Array | null;
  55995. readonly timestamp: number;
  55996. }
  55997. interface VRStageParameters {
  55998. sittingToStandingTransform?: Float32Array;
  55999. sizeX?: number;
  56000. sizeY?: number;
  56001. }
  56002. interface Navigator {
  56003. getVRDisplays(): Promise<VRDisplay[]>;
  56004. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56005. }
  56006. interface Window {
  56007. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56008. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56009. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56010. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56011. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56012. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56013. }
  56014. interface Gamepad {
  56015. readonly displayId: number;
  56016. }
  56017. interface XRDevice {
  56018. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56019. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56020. }
  56021. interface XRSession {
  56022. getInputSources(): Array<any>;
  56023. baseLayer: XRWebGLLayer;
  56024. requestFrameOfReference(type: string): Promise<void>;
  56025. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56026. end(): Promise<void>;
  56027. requestAnimationFrame: Function;
  56028. addEventListener: Function;
  56029. }
  56030. interface XRSessionCreationOptions {
  56031. outputContext?: WebGLRenderingContext | null;
  56032. immersive?: boolean;
  56033. environmentIntegration?: boolean;
  56034. }
  56035. interface XRLayer {
  56036. getViewport: Function;
  56037. framebufferWidth: number;
  56038. framebufferHeight: number;
  56039. }
  56040. interface XRView {
  56041. projectionMatrix: Float32Array;
  56042. }
  56043. interface XRFrame {
  56044. getDevicePose: Function;
  56045. getInputPose: Function;
  56046. views: Array<XRView>;
  56047. baseLayer: XRLayer;
  56048. }
  56049. interface XRFrameOfReference {
  56050. }
  56051. interface XRWebGLLayer extends XRLayer {
  56052. framebuffer: WebGLFramebuffer;
  56053. }
  56054. declare var XRWebGLLayer: {
  56055. prototype: XRWebGLLayer;
  56056. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56057. };
  56058. declare module BABYLON.GUI {
  56059. /**
  56060. * Class used to specific a value and its associated unit
  56061. */
  56062. export class ValueAndUnit {
  56063. /** defines the unit to store */
  56064. unit: number;
  56065. /** defines a boolean indicating if the value can be negative */
  56066. negativeValueAllowed: boolean;
  56067. private _value;
  56068. private _originalUnit;
  56069. /**
  56070. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  56071. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56072. */
  56073. ignoreAdaptiveScaling: boolean;
  56074. /**
  56075. * Creates a new ValueAndUnit
  56076. * @param value defines the value to store
  56077. * @param unit defines the unit to store
  56078. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  56079. */
  56080. constructor(value: number,
  56081. /** defines the unit to store */
  56082. unit?: number,
  56083. /** defines a boolean indicating if the value can be negative */
  56084. negativeValueAllowed?: boolean);
  56085. /** Gets a boolean indicating if the value is a percentage */
  56086. readonly isPercentage: boolean;
  56087. /** Gets a boolean indicating if the value is store as pixel */
  56088. readonly isPixel: boolean;
  56089. /** Gets direct internal value */
  56090. readonly internalValue: number;
  56091. /**
  56092. * Gets value as pixel
  56093. * @param host defines the root host
  56094. * @param refValue defines the reference value for percentages
  56095. * @returns the value as pixel
  56096. */
  56097. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  56098. /**
  56099. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  56100. * @param value defines the value to store
  56101. * @param unit defines the unit to store
  56102. * @returns the current ValueAndUnit
  56103. */
  56104. updateInPlace(value: number, unit?: number): ValueAndUnit;
  56105. /**
  56106. * Gets the value accordingly to its unit
  56107. * @param host defines the root host
  56108. * @returns the value
  56109. */
  56110. getValue(host: AdvancedDynamicTexture): number;
  56111. /**
  56112. * Gets a string representation of the value
  56113. * @param host defines the root host
  56114. * @param decimals defines an optional number of decimals to display
  56115. * @returns a string
  56116. */
  56117. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  56118. /**
  56119. * Store a value parsed from a string
  56120. * @param source defines the source string
  56121. * @returns true if the value was successfully parsed
  56122. */
  56123. fromString(source: string | number): boolean;
  56124. private static _Regex;
  56125. private static _UNITMODE_PERCENTAGE;
  56126. private static _UNITMODE_PIXEL;
  56127. /** UNITMODE_PERCENTAGE */
  56128. static readonly UNITMODE_PERCENTAGE: number;
  56129. /** UNITMODE_PIXEL */
  56130. static readonly UNITMODE_PIXEL: number;
  56131. }
  56132. }
  56133. declare module BABYLON.GUI {
  56134. /**
  56135. * Define a style used by control to automatically setup properties based on a template.
  56136. * Only support font related properties so far
  56137. */
  56138. export class Style implements BABYLON.IDisposable {
  56139. private _fontFamily;
  56140. private _fontStyle;
  56141. private _fontWeight;
  56142. /** @hidden */ host: AdvancedDynamicTexture;
  56143. /** @hidden */ fontSize: ValueAndUnit;
  56144. /**
  56145. * BABYLON.Observable raised when the style values are changed
  56146. */
  56147. onChangedObservable: BABYLON.Observable<Style>;
  56148. /**
  56149. * Creates a new style object
  56150. * @param host defines the AdvancedDynamicTexture which hosts this style
  56151. */
  56152. constructor(host: AdvancedDynamicTexture);
  56153. /**
  56154. * Gets or sets the font size
  56155. */
  56156. fontSize: string | number;
  56157. /**
  56158. * Gets or sets the font family
  56159. */
  56160. fontFamily: string;
  56161. /**
  56162. * Gets or sets the font style
  56163. */
  56164. fontStyle: string;
  56165. /** Gets or sets font weight */
  56166. fontWeight: string;
  56167. /** Dispose all associated resources */
  56168. dispose(): void;
  56169. }
  56170. }
  56171. declare module BABYLON.GUI {
  56172. /**
  56173. * Class used to transport BABYLON.Vector2 information for pointer events
  56174. */
  56175. export class Vector2WithInfo extends BABYLON.Vector2 {
  56176. /** defines the current mouse button index */
  56177. buttonIndex: number;
  56178. /**
  56179. * Creates a new Vector2WithInfo
  56180. * @param source defines the vector2 data to transport
  56181. * @param buttonIndex defines the current mouse button index
  56182. */
  56183. constructor(source: BABYLON.Vector2,
  56184. /** defines the current mouse button index */
  56185. buttonIndex?: number);
  56186. }
  56187. /** Class used to provide 2D matrix features */
  56188. export class Matrix2D {
  56189. /** Gets the internal array of 6 floats used to store matrix data */
  56190. m: Float32Array;
  56191. /**
  56192. * Creates a new matrix
  56193. * @param m00 defines value for (0, 0)
  56194. * @param m01 defines value for (0, 1)
  56195. * @param m10 defines value for (1, 0)
  56196. * @param m11 defines value for (1, 1)
  56197. * @param m20 defines value for (2, 0)
  56198. * @param m21 defines value for (2, 1)
  56199. */
  56200. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  56201. /**
  56202. * Fills the matrix from direct values
  56203. * @param m00 defines value for (0, 0)
  56204. * @param m01 defines value for (0, 1)
  56205. * @param m10 defines value for (1, 0)
  56206. * @param m11 defines value for (1, 1)
  56207. * @param m20 defines value for (2, 0)
  56208. * @param m21 defines value for (2, 1)
  56209. * @returns the current modified matrix
  56210. */
  56211. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  56212. /**
  56213. * Gets matrix determinant
  56214. * @returns the determinant
  56215. */
  56216. determinant(): number;
  56217. /**
  56218. * Inverses the matrix and stores it in a target matrix
  56219. * @param result defines the target matrix
  56220. * @returns the current matrix
  56221. */
  56222. invertToRef(result: Matrix2D): Matrix2D;
  56223. /**
  56224. * Multiplies the current matrix with another one
  56225. * @param other defines the second operand
  56226. * @param result defines the target matrix
  56227. * @returns the current matrix
  56228. */
  56229. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  56230. /**
  56231. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  56232. * @param x defines the x coordinate to transform
  56233. * @param y defines the x coordinate to transform
  56234. * @param result defines the target vector2
  56235. * @returns the current matrix
  56236. */
  56237. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  56238. /**
  56239. * Creates an identity matrix
  56240. * @returns a new matrix
  56241. */
  56242. static Identity(): Matrix2D;
  56243. /**
  56244. * Creates a translation matrix and stores it in a target matrix
  56245. * @param x defines the x coordinate of the translation
  56246. * @param y defines the y coordinate of the translation
  56247. * @param result defines the target matrix
  56248. */
  56249. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  56250. /**
  56251. * Creates a scaling matrix and stores it in a target matrix
  56252. * @param x defines the x coordinate of the scaling
  56253. * @param y defines the y coordinate of the scaling
  56254. * @param result defines the target matrix
  56255. */
  56256. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  56257. /**
  56258. * Creates a rotation matrix and stores it in a target matrix
  56259. * @param angle defines the rotation angle
  56260. * @param result defines the target matrix
  56261. */
  56262. static RotationToRef(angle: number, result: Matrix2D): void;
  56263. private static _TempPreTranslationMatrix;
  56264. private static _TempPostTranslationMatrix;
  56265. private static _TempRotationMatrix;
  56266. private static _TempScalingMatrix;
  56267. private static _TempCompose0;
  56268. private static _TempCompose1;
  56269. private static _TempCompose2;
  56270. /**
  56271. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  56272. * @param tx defines the x coordinate of the translation
  56273. * @param ty defines the y coordinate of the translation
  56274. * @param angle defines the rotation angle
  56275. * @param scaleX defines the x coordinate of the scaling
  56276. * @param scaleY defines the y coordinate of the scaling
  56277. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  56278. * @param result defines the target matrix
  56279. */
  56280. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  56281. }
  56282. }
  56283. declare module BABYLON.GUI {
  56284. /**
  56285. * Class used to store 2D control sizes
  56286. */
  56287. export class Measure {
  56288. /** defines left coordinate */
  56289. left: number;
  56290. /** defines top coordinate */
  56291. top: number;
  56292. /** defines width dimension */
  56293. width: number;
  56294. /** defines height dimension */
  56295. height: number;
  56296. /**
  56297. * Creates a new measure
  56298. * @param left defines left coordinate
  56299. * @param top defines top coordinate
  56300. * @param width defines width dimension
  56301. * @param height defines height dimension
  56302. */
  56303. constructor(
  56304. /** defines left coordinate */
  56305. left: number,
  56306. /** defines top coordinate */
  56307. top: number,
  56308. /** defines width dimension */
  56309. width: number,
  56310. /** defines height dimension */
  56311. height: number);
  56312. /**
  56313. * Copy from another measure
  56314. * @param other defines the other measure to copy from
  56315. */
  56316. copyFrom(other: Measure): void;
  56317. /**
  56318. * Copy from a group of 4 floats
  56319. * @param left defines left coordinate
  56320. * @param top defines top coordinate
  56321. * @param width defines width dimension
  56322. * @param height defines height dimension
  56323. */
  56324. copyFromFloats(left: number, top: number, width: number, height: number): void;
  56325. /**
  56326. * Computes the axis aligned bounding box measure for two given measures
  56327. * @param a Input measure
  56328. * @param b Input measure
  56329. * @param result the resulting bounding measure
  56330. */
  56331. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  56332. /**
  56333. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  56334. * @param transform the matrix to transform the measure before computing the AABB
  56335. * @param result the resulting AABB
  56336. */
  56337. transformToRef(transform: Matrix2D, result: Measure): void;
  56338. /**
  56339. * Check equality between this measure and another one
  56340. * @param other defines the other measures
  56341. * @returns true if both measures are equals
  56342. */
  56343. isEqualsTo(other: Measure): boolean;
  56344. /**
  56345. * Creates an empty measure
  56346. * @returns a new measure
  56347. */
  56348. static Empty(): Measure;
  56349. }
  56350. }
  56351. declare module BABYLON.GUI {
  56352. /**
  56353. * Interface used to define a control that can receive focus
  56354. */
  56355. export interface IFocusableControl {
  56356. /**
  56357. * Function called when the control receives the focus
  56358. */
  56359. onFocus(): void;
  56360. /**
  56361. * Function called when the control loses the focus
  56362. */
  56363. onBlur(): void;
  56364. /**
  56365. * Function called to let the control handle keyboard events
  56366. * @param evt defines the current keyboard event
  56367. */
  56368. processKeyboard(evt: KeyboardEvent): void;
  56369. /**
  56370. * Function called to get the list of controls that should not steal the focus from this control
  56371. * @returns an array of controls
  56372. */
  56373. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  56374. }
  56375. /**
  56376. * Class used to create texture to support 2D GUI elements
  56377. * @see http://doc.babylonjs.com/how_to/gui
  56378. */
  56379. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  56380. private _isDirty;
  56381. private _renderObserver;
  56382. private _resizeObserver;
  56383. private _preKeyboardObserver;
  56384. private _pointerMoveObserver;
  56385. private _pointerObserver;
  56386. private _canvasPointerOutObserver;
  56387. private _background;
  56388. /** @hidden */ rootContainer: Container;
  56389. /** @hidden */ lastPickedControl: Control;
  56390. /** @hidden */ lastControlOver: {
  56391. [pointerId: number]: Control;
  56392. };
  56393. /** @hidden */ lastControlDown: {
  56394. [pointerId: number]: Control;
  56395. };
  56396. /** @hidden */ capturingControl: {
  56397. [pointerId: number]: Control;
  56398. };
  56399. /** @hidden */ shouldBlockPointer: boolean;
  56400. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  56401. /** @hidden */ linkedControls: Control[];
  56402. private _isFullscreen;
  56403. private _fullscreenViewport;
  56404. private _idealWidth;
  56405. private _idealHeight;
  56406. private _useSmallestIdeal;
  56407. private _renderAtIdealSize;
  56408. private _focusedControl;
  56409. private _blockNextFocusCheck;
  56410. private _renderScale;
  56411. private _rootCanvas;
  56412. private _cursorChanged;
  56413. /**
  56414. * Define type to string to ensure compatibility across browsers
  56415. * Safari doesn't support DataTransfer constructor
  56416. */
  56417. private _clipboardData;
  56418. /**
  56419. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  56420. */
  56421. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  56422. /**
  56423. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  56424. */
  56425. onControlPickedObservable: BABYLON.Observable<Control>;
  56426. /**
  56427. * BABYLON.Observable event triggered before layout is evaluated
  56428. */
  56429. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56430. /**
  56431. * BABYLON.Observable event triggered after the layout was evaluated
  56432. */
  56433. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56434. /**
  56435. * BABYLON.Observable event triggered before the texture is rendered
  56436. */
  56437. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56438. /**
  56439. * BABYLON.Observable event triggered after the texture was rendered
  56440. */
  56441. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56442. /**
  56443. * Gets or sets a boolean defining if alpha is stored as premultiplied
  56444. */
  56445. premulAlpha: boolean;
  56446. /**
  56447. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  56448. * Useful when you want more antialiasing
  56449. */
  56450. renderScale: number;
  56451. /** Gets or sets the background color */
  56452. background: string;
  56453. /**
  56454. * Gets or sets the ideal width used to design controls.
  56455. * The GUI will then rescale everything accordingly
  56456. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56457. */
  56458. idealWidth: number;
  56459. /**
  56460. * Gets or sets the ideal height used to design controls.
  56461. * The GUI will then rescale everything accordingly
  56462. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56463. */
  56464. idealHeight: number;
  56465. /**
  56466. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  56467. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56468. */
  56469. useSmallestIdeal: boolean;
  56470. /**
  56471. * Gets or sets a boolean indicating if adaptive scaling must be used
  56472. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56473. */
  56474. renderAtIdealSize: boolean;
  56475. /**
  56476. * Gets the underlying layer used to render the texture when in fullscreen mode
  56477. */
  56478. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  56479. /**
  56480. * Gets the root container control
  56481. */
  56482. readonly rootContainer: Container;
  56483. /**
  56484. * Returns an array containing the root container.
  56485. * This is mostly used to let the Inspector introspects the ADT
  56486. * @returns an array containing the rootContainer
  56487. */
  56488. getChildren(): Array<Container>;
  56489. /**
  56490. * Will return all controls that are inside this texture
  56491. * @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
  56492. * @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
  56493. * @return all child controls
  56494. */
  56495. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56496. /**
  56497. * Gets or sets the current focused control
  56498. */
  56499. focusedControl: BABYLON.Nullable<IFocusableControl>;
  56500. /**
  56501. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  56502. */
  56503. isForeground: boolean;
  56504. /**
  56505. * Gets or set information about clipboardData
  56506. */
  56507. clipboardData: string;
  56508. /**
  56509. * Creates a new AdvancedDynamicTexture
  56510. * @param name defines the name of the texture
  56511. * @param width defines the width of the texture
  56512. * @param height defines the height of the texture
  56513. * @param scene defines the hosting scene
  56514. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  56515. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  56516. */
  56517. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  56518. /**
  56519. * Get the current class name of the texture useful for serialization or dynamic coding.
  56520. * @returns "AdvancedDynamicTexture"
  56521. */
  56522. getClassName(): string;
  56523. /**
  56524. * Function used to execute a function on all controls
  56525. * @param func defines the function to execute
  56526. * @param container defines the container where controls belong. If null the root container will be used
  56527. */
  56528. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  56529. private _useInvalidateRectOptimization;
  56530. /**
  56531. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  56532. */
  56533. useInvalidateRectOptimization: boolean;
  56534. private _invalidatedRectangle;
  56535. /**
  56536. * Invalidates a rectangle area on the gui texture
  56537. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  56538. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  56539. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  56540. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  56541. */
  56542. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  56543. /**
  56544. * Marks the texture as dirty forcing a complete update
  56545. */
  56546. markAsDirty(): void;
  56547. /**
  56548. * Helper function used to create a new style
  56549. * @returns a new style
  56550. * @see http://doc.babylonjs.com/how_to/gui#styles
  56551. */
  56552. createStyle(): Style;
  56553. /**
  56554. * Adds a new control to the root container
  56555. * @param control defines the control to add
  56556. * @returns the current texture
  56557. */
  56558. addControl(control: Control): AdvancedDynamicTexture;
  56559. /**
  56560. * Removes a control from the root container
  56561. * @param control defines the control to remove
  56562. * @returns the current texture
  56563. */
  56564. removeControl(control: Control): AdvancedDynamicTexture;
  56565. /**
  56566. * Release all resources
  56567. */
  56568. dispose(): void;
  56569. private _onResize;
  56570. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  56571. /**
  56572. * Get screen coordinates for a vector3
  56573. * @param position defines the position to project
  56574. * @param worldMatrix defines the world matrix to use
  56575. * @returns the projected position
  56576. */
  56577. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  56578. private _checkUpdate;
  56579. private _clearMeasure;
  56580. private _render;
  56581. /** @hidden */ changeCursor(cursor: string): void;
  56582. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  56583. private _doPicking;
  56584. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  56585. [pointerId: number]: Control;
  56586. }, control: Control): void;
  56587. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  56588. /** Attach to all scene events required to support pointer events */
  56589. attach(): void;
  56590. /** @hidden */
  56591. private onClipboardCopy;
  56592. /** @hidden */
  56593. private onClipboardCut;
  56594. /** @hidden */
  56595. private onClipboardPaste;
  56596. /**
  56597. * Register the clipboard Events onto the canvas
  56598. */
  56599. registerClipboardEvents(): void;
  56600. /**
  56601. * Unregister the clipboard Events from the canvas
  56602. */
  56603. unRegisterClipboardEvents(): void;
  56604. /**
  56605. * Connect the texture to a hosting mesh to enable interactions
  56606. * @param mesh defines the mesh to attach to
  56607. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  56608. */
  56609. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  56610. /**
  56611. * Move the focus to a specific control
  56612. * @param control defines the control which will receive the focus
  56613. */
  56614. moveFocusToControl(control: IFocusableControl): void;
  56615. private _manageFocus;
  56616. private _attachToOnPointerOut;
  56617. /**
  56618. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  56619. * @param mesh defines the mesh which will receive the texture
  56620. * @param width defines the texture width (1024 by default)
  56621. * @param height defines the texture height (1024 by default)
  56622. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  56623. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  56624. * @returns a new AdvancedDynamicTexture
  56625. */
  56626. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  56627. /**
  56628. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  56629. * In this mode the texture will rely on a layer for its rendering.
  56630. * This allows it to be treated like any other layer.
  56631. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  56632. * LayerMask is set through advancedTexture.layer.layerMask
  56633. * @param name defines name for the texture
  56634. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  56635. * @param scene defines the hsoting scene
  56636. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  56637. * @returns a new AdvancedDynamicTexture
  56638. */
  56639. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  56640. }
  56641. }
  56642. declare module BABYLON.GUI {
  56643. /**
  56644. * Root class used for all 2D controls
  56645. * @see http://doc.babylonjs.com/how_to/gui#controls
  56646. */
  56647. export class Control {
  56648. /** defines the name of the control */
  56649. name?: string | undefined;
  56650. /**
  56651. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  56652. */
  56653. static AllowAlphaInheritance: boolean;
  56654. private _alpha;
  56655. private _alphaSet;
  56656. private _zIndex;
  56657. /** @hidden */ host: AdvancedDynamicTexture;
  56658. /** Gets or sets the control parent */
  56659. parent: BABYLON.Nullable<Container>;
  56660. /** @hidden */ currentMeasure: Measure;
  56661. private _fontFamily;
  56662. private _fontStyle;
  56663. private _fontWeight;
  56664. private _fontSize;
  56665. private _font;
  56666. /** @hidden */ width: ValueAndUnit;
  56667. /** @hidden */ height: ValueAndUnit;
  56668. /** @hidden */
  56669. protected _fontOffset: {
  56670. ascent: number;
  56671. height: number;
  56672. descent: number;
  56673. };
  56674. private _color;
  56675. private _style;
  56676. private _styleObserver;
  56677. /** @hidden */
  56678. protected _horizontalAlignment: number;
  56679. /** @hidden */
  56680. protected _verticalAlignment: number;
  56681. /** @hidden */
  56682. protected _isDirty: boolean;
  56683. /** @hidden */
  56684. protected _wasDirty: boolean;
  56685. /** @hidden */ tempParentMeasure: Measure;
  56686. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  56687. /** @hidden */
  56688. protected _cachedParentMeasure: Measure;
  56689. private _paddingLeft;
  56690. private _paddingRight;
  56691. private _paddingTop;
  56692. private _paddingBottom;
  56693. /** @hidden */ left: ValueAndUnit;
  56694. /** @hidden */ top: ValueAndUnit;
  56695. private _scaleX;
  56696. private _scaleY;
  56697. private _rotation;
  56698. private _transformCenterX;
  56699. private _transformCenterY;
  56700. /** @hidden */ transformMatrix: Matrix2D;
  56701. /** @hidden */
  56702. protected _invertTransformMatrix: Matrix2D;
  56703. /** @hidden */
  56704. protected _transformedPosition: BABYLON.Vector2;
  56705. private _isMatrixDirty;
  56706. private _cachedOffsetX;
  56707. private _cachedOffsetY;
  56708. private _isVisible;
  56709. private _isHighlighted;
  56710. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56711. private _fontSet;
  56712. private _dummyVector2;
  56713. private _downCount;
  56714. private _enterCount;
  56715. private _doNotRender;
  56716. private _downPointerIds;
  56717. protected _isEnabled: boolean;
  56718. protected _disabledColor: string;
  56719. /** @hidden */
  56720. protected _rebuildLayout: boolean;
  56721. /** @hidden */ isClipped: boolean;
  56722. /** @hidden */ tag: any;
  56723. /**
  56724. * 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
  56725. */
  56726. uniqueId: number;
  56727. /**
  56728. * Gets or sets an object used to store user defined information for the node
  56729. */
  56730. metadata: any;
  56731. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  56732. isHitTestVisible: boolean;
  56733. /** Gets or sets a boolean indicating if the control can block pointer events */
  56734. isPointerBlocker: boolean;
  56735. /** Gets or sets a boolean indicating if the control can be focusable */
  56736. isFocusInvisible: boolean;
  56737. /**
  56738. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  56739. * 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
  56740. */
  56741. clipChildren: boolean;
  56742. /**
  56743. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  56744. */
  56745. useBitmapCache: boolean;
  56746. private _cacheData;
  56747. private _shadowOffsetX;
  56748. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  56749. shadowOffsetX: number;
  56750. private _shadowOffsetY;
  56751. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  56752. shadowOffsetY: number;
  56753. private _shadowBlur;
  56754. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  56755. shadowBlur: number;
  56756. private _shadowColor;
  56757. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  56758. shadowColor: string;
  56759. /** Gets or sets the cursor to use when the control is hovered */
  56760. hoverCursor: string;
  56761. /** @hidden */
  56762. protected _linkOffsetX: ValueAndUnit;
  56763. /** @hidden */
  56764. protected _linkOffsetY: ValueAndUnit;
  56765. /** Gets the control type name */
  56766. readonly typeName: string;
  56767. /**
  56768. * Get the current class name of the control.
  56769. * @returns current class name
  56770. */
  56771. getClassName(): string;
  56772. /**
  56773. * An event triggered when the pointer move over the control.
  56774. */
  56775. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  56776. /**
  56777. * An event triggered when the pointer move out of the control.
  56778. */
  56779. onPointerOutObservable: BABYLON.Observable<Control>;
  56780. /**
  56781. * An event triggered when the pointer taps the control
  56782. */
  56783. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  56784. /**
  56785. * An event triggered when pointer up
  56786. */
  56787. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  56788. /**
  56789. * An event triggered when a control is clicked on
  56790. */
  56791. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  56792. /**
  56793. * An event triggered when pointer enters the control
  56794. */
  56795. onPointerEnterObservable: BABYLON.Observable<Control>;
  56796. /**
  56797. * An event triggered when the control is marked as dirty
  56798. */
  56799. onDirtyObservable: BABYLON.Observable<Control>;
  56800. /**
  56801. * An event triggered before drawing the control
  56802. */
  56803. onBeforeDrawObservable: BABYLON.Observable<Control>;
  56804. /**
  56805. * An event triggered after the control was drawn
  56806. */
  56807. onAfterDrawObservable: BABYLON.Observable<Control>;
  56808. /**
  56809. * Get the hosting AdvancedDynamicTexture
  56810. */
  56811. readonly host: AdvancedDynamicTexture;
  56812. /** Gets or set information about font offsets (used to render and align text) */
  56813. fontOffset: {
  56814. ascent: number;
  56815. height: number;
  56816. descent: number;
  56817. };
  56818. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  56819. alpha: number;
  56820. /**
  56821. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  56822. */
  56823. isHighlighted: boolean;
  56824. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  56825. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56826. */
  56827. scaleX: number;
  56828. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  56829. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56830. */
  56831. scaleY: number;
  56832. /** Gets or sets the rotation angle (0 by default)
  56833. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56834. */
  56835. rotation: number;
  56836. /** Gets or sets the transformation center on Y axis (0 by default)
  56837. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56838. */
  56839. transformCenterY: number;
  56840. /** Gets or sets the transformation center on X axis (0 by default)
  56841. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56842. */
  56843. transformCenterX: number;
  56844. /**
  56845. * Gets or sets the horizontal alignment
  56846. * @see http://doc.babylonjs.com/how_to/gui#alignments
  56847. */
  56848. horizontalAlignment: number;
  56849. /**
  56850. * Gets or sets the vertical alignment
  56851. * @see http://doc.babylonjs.com/how_to/gui#alignments
  56852. */
  56853. verticalAlignment: number;
  56854. /**
  56855. * Gets or sets control width
  56856. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56857. */
  56858. width: string | number;
  56859. /**
  56860. * Gets control width in pixel
  56861. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56862. */
  56863. readonly widthInPixels: number;
  56864. /**
  56865. * Gets or sets control height
  56866. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56867. */
  56868. height: string | number;
  56869. /**
  56870. * Gets control height in pixel
  56871. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56872. */
  56873. readonly heightInPixels: number;
  56874. /** Gets or set font family */
  56875. fontFamily: string;
  56876. /** Gets or sets font style */
  56877. fontStyle: string;
  56878. /** Gets or sets font weight */
  56879. fontWeight: string;
  56880. /**
  56881. * Gets or sets style
  56882. * @see http://doc.babylonjs.com/how_to/gui#styles
  56883. */
  56884. style: BABYLON.Nullable<Style>;
  56885. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  56886. /** Gets font size in pixels */
  56887. readonly fontSizeInPixels: number;
  56888. /** Gets or sets font size */
  56889. fontSize: string | number;
  56890. /** Gets or sets foreground color */
  56891. color: string;
  56892. /** Gets or sets z index which is used to reorder controls on the z axis */
  56893. zIndex: number;
  56894. /** Gets or sets a boolean indicating if the control can be rendered */
  56895. notRenderable: boolean;
  56896. /** Gets or sets a boolean indicating if the control is visible */
  56897. isVisible: boolean;
  56898. /** Gets a boolean indicating that the control needs to update its rendering */
  56899. readonly isDirty: boolean;
  56900. /**
  56901. * Gets the current linked mesh (or null if none)
  56902. */
  56903. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56904. /**
  56905. * Gets or sets a value indicating the padding to use on the left of the control
  56906. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56907. */
  56908. paddingLeft: string | number;
  56909. /**
  56910. * Gets a value indicating the padding in pixels to use on the left of the control
  56911. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56912. */
  56913. readonly paddingLeftInPixels: number;
  56914. /**
  56915. * Gets or sets a value indicating the padding to use on the right of the control
  56916. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56917. */
  56918. paddingRight: string | number;
  56919. /**
  56920. * Gets a value indicating the padding in pixels to use on the right of the control
  56921. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56922. */
  56923. readonly paddingRightInPixels: number;
  56924. /**
  56925. * Gets or sets a value indicating the padding to use on the top of the control
  56926. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56927. */
  56928. paddingTop: string | number;
  56929. /**
  56930. * Gets a value indicating the padding in pixels to use on the top of the control
  56931. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56932. */
  56933. readonly paddingTopInPixels: number;
  56934. /**
  56935. * Gets or sets a value indicating the padding to use on the bottom of the control
  56936. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56937. */
  56938. paddingBottom: string | number;
  56939. /**
  56940. * Gets a value indicating the padding in pixels to use on the bottom of the control
  56941. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56942. */
  56943. readonly paddingBottomInPixels: number;
  56944. /**
  56945. * Gets or sets a value indicating the left coordinate of the control
  56946. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56947. */
  56948. left: string | number;
  56949. /**
  56950. * Gets a value indicating the left coordinate in pixels of the control
  56951. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56952. */
  56953. readonly leftInPixels: number;
  56954. /**
  56955. * Gets or sets a value indicating the top coordinate of the control
  56956. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56957. */
  56958. top: string | number;
  56959. /**
  56960. * Gets a value indicating the top coordinate in pixels of the control
  56961. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56962. */
  56963. readonly topInPixels: number;
  56964. /**
  56965. * Gets or sets a value indicating the offset on X axis to the linked mesh
  56966. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56967. */
  56968. linkOffsetX: string | number;
  56969. /**
  56970. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  56971. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56972. */
  56973. readonly linkOffsetXInPixels: number;
  56974. /**
  56975. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  56976. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56977. */
  56978. linkOffsetY: string | number;
  56979. /**
  56980. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  56981. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56982. */
  56983. readonly linkOffsetYInPixels: number;
  56984. /** Gets the center coordinate on X axis */
  56985. readonly centerX: number;
  56986. /** Gets the center coordinate on Y axis */
  56987. readonly centerY: number;
  56988. /** Gets or sets if control is Enabled*/
  56989. isEnabled: boolean;
  56990. /** Gets or sets background color of control if it's disabled*/
  56991. disabledColor: string;
  56992. /**
  56993. * Creates a new control
  56994. * @param name defines the name of the control
  56995. */
  56996. constructor(
  56997. /** defines the name of the control */
  56998. name?: string | undefined);
  56999. /** @hidden */
  57000. protected _getTypeName(): string;
  57001. /**
  57002. * Gets the first ascendant in the hierarchy of the given type
  57003. * @param className defines the required type
  57004. * @returns the ascendant or null if not found
  57005. */
  57006. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  57007. /** @hidden */ resetFontCache(): void;
  57008. /**
  57009. * Determines if a container is an ascendant of the current control
  57010. * @param container defines the container to look for
  57011. * @returns true if the container is one of the ascendant of the control
  57012. */
  57013. isAscendant(container: Control): boolean;
  57014. /**
  57015. * Gets coordinates in local control space
  57016. * @param globalCoordinates defines the coordinates to transform
  57017. * @returns the new coordinates in local space
  57018. */
  57019. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57020. /**
  57021. * Gets coordinates in local control space
  57022. * @param globalCoordinates defines the coordinates to transform
  57023. * @param result defines the target vector2 where to store the result
  57024. * @returns the current control
  57025. */
  57026. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  57027. /**
  57028. * Gets coordinates in parent local control space
  57029. * @param globalCoordinates defines the coordinates to transform
  57030. * @returns the new coordinates in parent local space
  57031. */
  57032. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57033. /**
  57034. * Move the current control to a vector3 position projected onto the screen.
  57035. * @param position defines the target position
  57036. * @param scene defines the hosting scene
  57037. */
  57038. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  57039. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57040. /**
  57041. * Will return all controls that have this control as ascendant
  57042. * @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
  57043. * @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
  57044. * @return all child controls
  57045. */
  57046. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  57047. /**
  57048. * Link current control with a target mesh
  57049. * @param mesh defines the mesh to link with
  57050. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57051. */
  57052. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  57053. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  57054. /** @hidden */ offsetLeft(offset: number): void;
  57055. /** @hidden */ offsetTop(offset: number): void;
  57056. /** @hidden */ markMatrixAsDirty(): void;
  57057. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  57058. /** @hidden */ intersectsRect(rect: Measure): boolean;
  57059. /** @hidden */
  57060. protected invalidateRect(): void;
  57061. /** @hidden */ markAsDirty(force?: boolean): void;
  57062. /** @hidden */ markAllAsDirty(): void;
  57063. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57064. /** @hidden */
  57065. protected _transform(context?: CanvasRenderingContext2D): void;
  57066. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  57067. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  57068. /** @hidden */
  57069. protected _applyStates(context: CanvasRenderingContext2D): void;
  57070. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57071. /** @hidden */
  57072. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57073. protected _evaluateClippingState(parentMeasure: Measure): void;
  57074. /** @hidden */ measure(): void;
  57075. /** @hidden */
  57076. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57077. /** @hidden */
  57078. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57079. /** @hidden */
  57080. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57081. /** @hidden */
  57082. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57083. private static _ClipMeasure;
  57084. private _tmpMeasureA;
  57085. private _clip;
  57086. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  57087. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  57088. /**
  57089. * Tests if a given coordinates belong to the current control
  57090. * @param x defines x coordinate to test
  57091. * @param y defines y coordinate to test
  57092. * @returns true if the coordinates are inside the control
  57093. */
  57094. contains(x: number, y: number): boolean;
  57095. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57096. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  57097. /** @hidden */ onPointerEnter(target: Control): boolean;
  57098. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57099. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57100. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57101. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  57102. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  57103. private _prepareFont;
  57104. /** Releases associated resources */
  57105. dispose(): void;
  57106. private static _HORIZONTAL_ALIGNMENT_LEFT;
  57107. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  57108. private static _HORIZONTAL_ALIGNMENT_CENTER;
  57109. private static _VERTICAL_ALIGNMENT_TOP;
  57110. private static _VERTICAL_ALIGNMENT_BOTTOM;
  57111. private static _VERTICAL_ALIGNMENT_CENTER;
  57112. /** HORIZONTAL_ALIGNMENT_LEFT */
  57113. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  57114. /** HORIZONTAL_ALIGNMENT_RIGHT */
  57115. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  57116. /** HORIZONTAL_ALIGNMENT_CENTER */
  57117. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  57118. /** VERTICAL_ALIGNMENT_TOP */
  57119. static readonly VERTICAL_ALIGNMENT_TOP: number;
  57120. /** VERTICAL_ALIGNMENT_BOTTOM */
  57121. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  57122. /** VERTICAL_ALIGNMENT_CENTER */
  57123. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  57124. private static _FontHeightSizes;
  57125. /** @hidden */ private static _GetFontOffset(font: string): {
  57126. ascent: number;
  57127. height: number;
  57128. descent: number;
  57129. };
  57130. /**
  57131. * Creates a stack panel that can be used to render headers
  57132. * @param control defines the control to associate with the header
  57133. * @param text defines the text of the header
  57134. * @param size defines the size of the header
  57135. * @param options defines options used to configure the header
  57136. * @returns a new StackPanel
  57137. * @ignore
  57138. * @hidden
  57139. */
  57140. static AddHeader: (control: Control, text: string, size: string | number, options: {
  57141. isHorizontal: boolean;
  57142. controlFirst: boolean;
  57143. }) => any;
  57144. /** @hidden */
  57145. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  57146. }
  57147. }
  57148. declare module BABYLON.GUI {
  57149. /**
  57150. * Root class for 2D containers
  57151. * @see http://doc.babylonjs.com/how_to/gui#containers
  57152. */
  57153. export class Container extends Control {
  57154. name?: string | undefined;
  57155. /** @hidden */
  57156. protected _children: Control[];
  57157. /** @hidden */
  57158. protected _measureForChildren: Measure;
  57159. /** @hidden */
  57160. protected _background: string;
  57161. /** @hidden */
  57162. protected _adaptWidthToChildren: boolean;
  57163. /** @hidden */
  57164. protected _adaptHeightToChildren: boolean;
  57165. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  57166. adaptHeightToChildren: boolean;
  57167. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  57168. adaptWidthToChildren: boolean;
  57169. /** Gets or sets background color */
  57170. background: string;
  57171. /** Gets the list of children */
  57172. readonly children: Control[];
  57173. /**
  57174. * Creates a new Container
  57175. * @param name defines the name of the container
  57176. */
  57177. constructor(name?: string | undefined);
  57178. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  57179. /**
  57180. * Gets a child using its name
  57181. * @param name defines the child name to look for
  57182. * @returns the child control if found
  57183. */
  57184. getChildByName(name: string): BABYLON.Nullable<Control>;
  57185. /**
  57186. * Gets a child using its type and its name
  57187. * @param name defines the child name to look for
  57188. * @param type defines the child type to look for
  57189. * @returns the child control if found
  57190. */
  57191. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  57192. /**
  57193. * Search for a specific control in children
  57194. * @param control defines the control to look for
  57195. * @returns true if the control is in child list
  57196. */
  57197. containsControl(control: Control): boolean;
  57198. /**
  57199. * Adds a new control to the current container
  57200. * @param control defines the control to add
  57201. * @returns the current container
  57202. */
  57203. addControl(control: BABYLON.Nullable<Control>): Container;
  57204. /**
  57205. * Removes all controls from the current container
  57206. * @returns the current container
  57207. */
  57208. clearControls(): Container;
  57209. /**
  57210. * Removes a control from the current container
  57211. * @param control defines the control to remove
  57212. * @returns the current container
  57213. */
  57214. removeControl(control: Control): Container;
  57215. /** @hidden */ reOrderControl(control: Control): void;
  57216. /** @hidden */ offsetLeft(offset: number): void;
  57217. /** @hidden */ offsetTop(offset: number): void;
  57218. /** @hidden */ markAllAsDirty(): void;
  57219. /** @hidden */
  57220. protected _localDraw(context: CanvasRenderingContext2D): void;
  57221. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57222. /** @hidden */
  57223. protected _beforeLayout(): void;
  57224. /** @hidden */
  57225. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57226. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57227. protected _postMeasure(): void;
  57228. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  57229. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57230. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57231. /** @hidden */
  57232. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57233. /** Releases associated resources */
  57234. dispose(): void;
  57235. }
  57236. }
  57237. declare module BABYLON.GUI {
  57238. /** Class used to create rectangle container */
  57239. export class Rectangle extends Container {
  57240. name?: string | undefined;
  57241. private _thickness;
  57242. private _cornerRadius;
  57243. /** Gets or sets border thickness */
  57244. thickness: number;
  57245. /** Gets or sets the corner radius angle */
  57246. cornerRadius: number;
  57247. /**
  57248. * Creates a new Rectangle
  57249. * @param name defines the control name
  57250. */
  57251. constructor(name?: string | undefined);
  57252. protected _getTypeName(): string;
  57253. protected _localDraw(context: CanvasRenderingContext2D): void;
  57254. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57255. private _drawRoundedRect;
  57256. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57257. }
  57258. }
  57259. declare module BABYLON.GUI {
  57260. /**
  57261. * Enum that determines the text-wrapping mode to use.
  57262. */
  57263. export enum TextWrapping {
  57264. /**
  57265. * Clip the text when it's larger than Control.width; this is the default mode.
  57266. */
  57267. Clip = 0,
  57268. /**
  57269. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  57270. */
  57271. WordWrap = 1,
  57272. /**
  57273. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  57274. */
  57275. Ellipsis = 2
  57276. }
  57277. /**
  57278. * Class used to create text block control
  57279. */
  57280. export class TextBlock extends Control {
  57281. /**
  57282. * Defines the name of the control
  57283. */
  57284. name?: string | undefined;
  57285. private _text;
  57286. private _textWrapping;
  57287. private _textHorizontalAlignment;
  57288. private _textVerticalAlignment;
  57289. private _lines;
  57290. private _resizeToFit;
  57291. private _lineSpacing;
  57292. private _outlineWidth;
  57293. private _outlineColor;
  57294. /**
  57295. * An event triggered after the text is changed
  57296. */
  57297. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  57298. /**
  57299. * An event triggered after the text was broken up into lines
  57300. */
  57301. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  57302. /**
  57303. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  57304. */
  57305. readonly lines: any[];
  57306. /**
  57307. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57308. */
  57309. /**
  57310. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57311. */
  57312. resizeToFit: boolean;
  57313. /**
  57314. * Gets or sets a boolean indicating if text must be wrapped
  57315. */
  57316. /**
  57317. * Gets or sets a boolean indicating if text must be wrapped
  57318. */
  57319. textWrapping: TextWrapping | boolean;
  57320. /**
  57321. * Gets or sets text to display
  57322. */
  57323. /**
  57324. * Gets or sets text to display
  57325. */
  57326. text: string;
  57327. /**
  57328. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57329. */
  57330. /**
  57331. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57332. */
  57333. textHorizontalAlignment: number;
  57334. /**
  57335. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57336. */
  57337. /**
  57338. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57339. */
  57340. textVerticalAlignment: number;
  57341. /**
  57342. * Gets or sets line spacing value
  57343. */
  57344. /**
  57345. * Gets or sets line spacing value
  57346. */
  57347. lineSpacing: string | number;
  57348. /**
  57349. * Gets or sets outlineWidth of the text to display
  57350. */
  57351. /**
  57352. * Gets or sets outlineWidth of the text to display
  57353. */
  57354. outlineWidth: number;
  57355. /**
  57356. * Gets or sets outlineColor of the text to display
  57357. */
  57358. /**
  57359. * Gets or sets outlineColor of the text to display
  57360. */
  57361. outlineColor: string;
  57362. /**
  57363. * Creates a new TextBlock object
  57364. * @param name defines the name of the control
  57365. * @param text defines the text to display (emptry string by default)
  57366. */
  57367. constructor(
  57368. /**
  57369. * Defines the name of the control
  57370. */
  57371. name?: string | undefined, text?: string);
  57372. protected _getTypeName(): string;
  57373. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57374. private _drawText;
  57375. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57376. protected _applyStates(context: CanvasRenderingContext2D): void;
  57377. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  57378. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  57379. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  57380. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  57381. protected _renderLines(context: CanvasRenderingContext2D): void;
  57382. /**
  57383. * Given a width constraint applied on the text block, find the expected height
  57384. * @returns expected height
  57385. */
  57386. computeExpectedHeight(): number;
  57387. dispose(): void;
  57388. }
  57389. }
  57390. declare module BABYLON.GUI {
  57391. /**
  57392. * Class used to create 2D images
  57393. */
  57394. export class Image extends Control {
  57395. name?: string | undefined;
  57396. private static _WorkingCanvas;
  57397. private _domImage;
  57398. private _imageWidth;
  57399. private _imageHeight;
  57400. private _loaded;
  57401. private _stretch;
  57402. private _source;
  57403. private _autoScale;
  57404. private _sourceLeft;
  57405. private _sourceTop;
  57406. private _sourceWidth;
  57407. private _sourceHeight;
  57408. private _cellWidth;
  57409. private _cellHeight;
  57410. private _cellId;
  57411. private _populateNinePatchSlicesFromImage;
  57412. private _sliceLeft;
  57413. private _sliceRight;
  57414. private _sliceTop;
  57415. private _sliceBottom;
  57416. private _detectPointerOnOpaqueOnly;
  57417. /**
  57418. * BABYLON.Observable notified when the content is loaded
  57419. */
  57420. onImageLoadedObservable: BABYLON.Observable<Image>;
  57421. /**
  57422. * Gets a boolean indicating that the content is loaded
  57423. */
  57424. readonly isLoaded: boolean;
  57425. /**
  57426. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  57427. */
  57428. populateNinePatchSlicesFromImage: boolean;
  57429. /**
  57430. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  57431. * Beware using this as this will comsume more memory as the image has to be stored twice
  57432. */
  57433. detectPointerOnOpaqueOnly: boolean;
  57434. /**
  57435. * Gets or sets the left value for slicing (9-patch)
  57436. */
  57437. sliceLeft: number;
  57438. /**
  57439. * Gets or sets the right value for slicing (9-patch)
  57440. */
  57441. sliceRight: number;
  57442. /**
  57443. * Gets or sets the top value for slicing (9-patch)
  57444. */
  57445. sliceTop: number;
  57446. /**
  57447. * Gets or sets the bottom value for slicing (9-patch)
  57448. */
  57449. sliceBottom: number;
  57450. /**
  57451. * Gets or sets the left coordinate in the source image
  57452. */
  57453. sourceLeft: number;
  57454. /**
  57455. * Gets or sets the top coordinate in the source image
  57456. */
  57457. sourceTop: number;
  57458. /**
  57459. * Gets or sets the width to capture in the source image
  57460. */
  57461. sourceWidth: number;
  57462. /**
  57463. * Gets or sets the height to capture in the source image
  57464. */
  57465. sourceHeight: number;
  57466. /**
  57467. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  57468. * @see http://doc.babylonjs.com/how_to/gui#image
  57469. */
  57470. autoScale: boolean;
  57471. /** Gets or sets the streching mode used by the image */
  57472. stretch: number;
  57473. /**
  57474. * Gets or sets the internal DOM image used to render the control
  57475. */
  57476. domImage: HTMLImageElement;
  57477. private _onImageLoaded;
  57478. private _extractNinePatchSliceDataFromImage;
  57479. /**
  57480. * Gets or sets image source url
  57481. */
  57482. source: BABYLON.Nullable<string>;
  57483. /**
  57484. * Gets or sets the cell width to use when animation sheet is enabled
  57485. * @see http://doc.babylonjs.com/how_to/gui#image
  57486. */
  57487. cellWidth: number;
  57488. /**
  57489. * Gets or sets the cell height to use when animation sheet is enabled
  57490. * @see http://doc.babylonjs.com/how_to/gui#image
  57491. */
  57492. cellHeight: number;
  57493. /**
  57494. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  57495. * @see http://doc.babylonjs.com/how_to/gui#image
  57496. */
  57497. cellId: number;
  57498. /**
  57499. * Creates a new Image
  57500. * @param name defines the control name
  57501. * @param url defines the image url
  57502. */
  57503. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  57504. /**
  57505. * Tests if a given coordinates belong to the current control
  57506. * @param x defines x coordinate to test
  57507. * @param y defines y coordinate to test
  57508. * @returns true if the coordinates are inside the control
  57509. */
  57510. contains(x: number, y: number): boolean;
  57511. protected _getTypeName(): string;
  57512. /** Force the control to synchronize with its content */
  57513. synchronizeSizeWithContent(): void;
  57514. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57515. private _prepareWorkingCanvasForOpaqueDetection;
  57516. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  57517. private _renderCornerPatch;
  57518. private _renderNinePatch;
  57519. dispose(): void;
  57520. /** STRETCH_NONE */
  57521. static readonly STRETCH_NONE: number;
  57522. /** STRETCH_FILL */
  57523. static readonly STRETCH_FILL: number;
  57524. /** STRETCH_UNIFORM */
  57525. static readonly STRETCH_UNIFORM: number;
  57526. /** STRETCH_EXTEND */
  57527. static readonly STRETCH_EXTEND: number;
  57528. /** NINE_PATCH */
  57529. static readonly STRETCH_NINE_PATCH: number;
  57530. }
  57531. }
  57532. declare module BABYLON.GUI {
  57533. /**
  57534. * Class used to create 2D buttons
  57535. */
  57536. export class Button extends Rectangle {
  57537. name?: string | undefined;
  57538. /**
  57539. * Function called to generate a pointer enter animation
  57540. */
  57541. pointerEnterAnimation: () => void;
  57542. /**
  57543. * Function called to generate a pointer out animation
  57544. */
  57545. pointerOutAnimation: () => void;
  57546. /**
  57547. * Function called to generate a pointer down animation
  57548. */
  57549. pointerDownAnimation: () => void;
  57550. /**
  57551. * Function called to generate a pointer up animation
  57552. */
  57553. pointerUpAnimation: () => void;
  57554. private _image;
  57555. /**
  57556. * Returns the image part of the button (if any)
  57557. */
  57558. readonly image: BABYLON.Nullable<Image>;
  57559. private _textBlock;
  57560. /**
  57561. * Returns the image part of the button (if any)
  57562. */
  57563. readonly textBlock: BABYLON.Nullable<TextBlock>;
  57564. /**
  57565. * Creates a new Button
  57566. * @param name defines the name of the button
  57567. */
  57568. constructor(name?: string | undefined);
  57569. protected _getTypeName(): string;
  57570. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57571. /** @hidden */ onPointerEnter(target: Control): boolean;
  57572. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57573. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57574. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57575. /**
  57576. * Creates a new button made with an image and a text
  57577. * @param name defines the name of the button
  57578. * @param text defines the text of the button
  57579. * @param imageUrl defines the url of the image
  57580. * @returns a new Button
  57581. */
  57582. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  57583. /**
  57584. * Creates a new button made with an image
  57585. * @param name defines the name of the button
  57586. * @param imageUrl defines the url of the image
  57587. * @returns a new Button
  57588. */
  57589. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  57590. /**
  57591. * Creates a new button made with a text
  57592. * @param name defines the name of the button
  57593. * @param text defines the text of the button
  57594. * @returns a new Button
  57595. */
  57596. static CreateSimpleButton(name: string, text: string): Button;
  57597. /**
  57598. * Creates a new button made with an image and a centered text
  57599. * @param name defines the name of the button
  57600. * @param text defines the text of the button
  57601. * @param imageUrl defines the url of the image
  57602. * @returns a new Button
  57603. */
  57604. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  57605. }
  57606. }
  57607. declare module BABYLON.GUI {
  57608. /**
  57609. * Class used to create a 2D stack panel container
  57610. */
  57611. export class StackPanel extends Container {
  57612. name?: string | undefined;
  57613. private _isVertical;
  57614. private _manualWidth;
  57615. private _manualHeight;
  57616. private _doNotTrackManualChanges;
  57617. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  57618. isVertical: boolean;
  57619. /**
  57620. * Gets or sets panel width.
  57621. * This value should not be set when in horizontal mode as it will be computed automatically
  57622. */
  57623. width: string | number;
  57624. /**
  57625. * Gets or sets panel height.
  57626. * This value should not be set when in vertical mode as it will be computed automatically
  57627. */
  57628. height: string | number;
  57629. /**
  57630. * Creates a new StackPanel
  57631. * @param name defines control name
  57632. */
  57633. constructor(name?: string | undefined);
  57634. protected _getTypeName(): string;
  57635. /** @hidden */
  57636. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57637. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57638. protected _postMeasure(): void;
  57639. }
  57640. }
  57641. declare module BABYLON.GUI {
  57642. /**
  57643. * Class used to represent a 2D checkbox
  57644. */
  57645. export class Checkbox extends Control {
  57646. name?: string | undefined;
  57647. private _isChecked;
  57648. private _background;
  57649. private _checkSizeRatio;
  57650. private _thickness;
  57651. /** Gets or sets border thickness */
  57652. thickness: number;
  57653. /**
  57654. * BABYLON.Observable raised when isChecked property changes
  57655. */
  57656. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  57657. /** Gets or sets a value indicating the ratio between overall size and check size */
  57658. checkSizeRatio: number;
  57659. /** Gets or sets background color */
  57660. background: string;
  57661. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  57662. isChecked: boolean;
  57663. /**
  57664. * Creates a new CheckBox
  57665. * @param name defines the control name
  57666. */
  57667. constructor(name?: string | undefined);
  57668. protected _getTypeName(): string;
  57669. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57670. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57671. /**
  57672. * Utility function to easily create a checkbox with a header
  57673. * @param title defines the label to use for the header
  57674. * @param onValueChanged defines the callback to call when value changes
  57675. * @returns a StackPanel containing the checkbox and a textBlock
  57676. */
  57677. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  57678. }
  57679. }
  57680. declare module BABYLON.GUI {
  57681. /**
  57682. * Class used to store key control properties
  57683. */
  57684. export class KeyPropertySet {
  57685. /** Width */
  57686. width?: string;
  57687. /** Height */
  57688. height?: string;
  57689. /** Left padding */
  57690. paddingLeft?: string;
  57691. /** Right padding */
  57692. paddingRight?: string;
  57693. /** Top padding */
  57694. paddingTop?: string;
  57695. /** Bottom padding */
  57696. paddingBottom?: string;
  57697. /** Foreground color */
  57698. color?: string;
  57699. /** Background color */
  57700. background?: string;
  57701. }
  57702. /**
  57703. * Class used to create virtual keyboard
  57704. */
  57705. export class VirtualKeyboard extends StackPanel {
  57706. /** BABYLON.Observable raised when a key is pressed */
  57707. onKeyPressObservable: BABYLON.Observable<string>;
  57708. /** Gets or sets default key button width */
  57709. defaultButtonWidth: string;
  57710. /** Gets or sets default key button height */
  57711. defaultButtonHeight: string;
  57712. /** Gets or sets default key button left padding */
  57713. defaultButtonPaddingLeft: string;
  57714. /** Gets or sets default key button right padding */
  57715. defaultButtonPaddingRight: string;
  57716. /** Gets or sets default key button top padding */
  57717. defaultButtonPaddingTop: string;
  57718. /** Gets or sets default key button bottom padding */
  57719. defaultButtonPaddingBottom: string;
  57720. /** Gets or sets default key button foreground color */
  57721. defaultButtonColor: string;
  57722. /** Gets or sets default key button background color */
  57723. defaultButtonBackground: string;
  57724. /** Gets or sets shift button foreground color */
  57725. shiftButtonColor: string;
  57726. /** Gets or sets shift button thickness*/
  57727. selectedShiftThickness: number;
  57728. /** Gets shift key state */
  57729. shiftState: number;
  57730. protected _getTypeName(): string;
  57731. private _createKey;
  57732. /**
  57733. * Adds a new row of keys
  57734. * @param keys defines the list of keys to add
  57735. * @param propertySets defines the associated property sets
  57736. */
  57737. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  57738. /**
  57739. * Set the shift key to a specific state
  57740. * @param shiftState defines the new shift state
  57741. */
  57742. applyShiftState(shiftState: number): void;
  57743. private _currentlyConnectedInputText;
  57744. private _connectedInputTexts;
  57745. private _onKeyPressObserver;
  57746. /** Gets the input text control currently attached to the keyboard */
  57747. readonly connectedInputText: BABYLON.Nullable<InputText>;
  57748. /**
  57749. * Connects the keyboard with an input text control
  57750. *
  57751. * @param input defines the target control
  57752. */
  57753. connect(input: InputText): void;
  57754. /**
  57755. * Disconnects the keyboard from connected InputText controls
  57756. *
  57757. * @param input optionally defines a target control, otherwise all are disconnected
  57758. */
  57759. disconnect(input?: InputText): void;
  57760. private _removeConnectedInputObservables;
  57761. /**
  57762. * Release all resources
  57763. */
  57764. dispose(): void;
  57765. /**
  57766. * Creates a new keyboard using a default layout
  57767. *
  57768. * @param name defines control name
  57769. * @returns a new VirtualKeyboard
  57770. */
  57771. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  57772. }
  57773. }
  57774. declare module BABYLON.GUI {
  57775. /**
  57776. * Class used to create input text control
  57777. */
  57778. export class InputText extends Control implements IFocusableControl {
  57779. name?: string | undefined;
  57780. private _text;
  57781. private _placeholderText;
  57782. private _background;
  57783. private _focusedBackground;
  57784. private _focusedColor;
  57785. private _placeholderColor;
  57786. private _thickness;
  57787. private _margin;
  57788. private _autoStretchWidth;
  57789. private _maxWidth;
  57790. private _isFocused;
  57791. private _blinkTimeout;
  57792. private _blinkIsEven;
  57793. private _cursorOffset;
  57794. private _scrollLeft;
  57795. private _textWidth;
  57796. private _clickedCoordinate;
  57797. private _deadKey;
  57798. private _addKey;
  57799. private _currentKey;
  57800. private _isTextHighlightOn;
  57801. private _textHighlightColor;
  57802. private _highligherOpacity;
  57803. private _highlightedText;
  57804. private _startHighlightIndex;
  57805. private _endHighlightIndex;
  57806. private _cursorIndex;
  57807. private _onFocusSelectAll;
  57808. private _isPointerDown;
  57809. private _onClipboardObserver;
  57810. private _onPointerDblTapObserver;
  57811. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  57812. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  57813. promptMessage: string;
  57814. /** BABYLON.Observable raised when the text changes */
  57815. onTextChangedObservable: BABYLON.Observable<InputText>;
  57816. /** BABYLON.Observable raised just before an entered character is to be added */
  57817. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  57818. /** BABYLON.Observable raised when the control gets the focus */
  57819. onFocusObservable: BABYLON.Observable<InputText>;
  57820. /** BABYLON.Observable raised when the control loses the focus */
  57821. onBlurObservable: BABYLON.Observable<InputText>;
  57822. /**Observable raised when the text is highlighted */
  57823. onTextHighlightObservable: BABYLON.Observable<InputText>;
  57824. /**Observable raised when copy event is triggered */
  57825. onTextCopyObservable: BABYLON.Observable<InputText>;
  57826. /** BABYLON.Observable raised when cut event is triggered */
  57827. onTextCutObservable: BABYLON.Observable<InputText>;
  57828. /** BABYLON.Observable raised when paste event is triggered */
  57829. onTextPasteObservable: BABYLON.Observable<InputText>;
  57830. /** BABYLON.Observable raised when a key event was processed */
  57831. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  57832. /** Gets or sets the maximum width allowed by the control */
  57833. maxWidth: string | number;
  57834. /** Gets the maximum width allowed by the control in pixels */
  57835. readonly maxWidthInPixels: number;
  57836. /** Gets or sets the text highlighter transparency; default: 0.4 */
  57837. highligherOpacity: number;
  57838. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  57839. onFocusSelectAll: boolean;
  57840. /** Gets or sets the text hightlight color */
  57841. textHighlightColor: string;
  57842. /** Gets or sets control margin */
  57843. margin: string;
  57844. /** Gets control margin in pixels */
  57845. readonly marginInPixels: number;
  57846. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  57847. autoStretchWidth: boolean;
  57848. /** Gets or sets border thickness */
  57849. thickness: number;
  57850. /** Gets or sets the background color when focused */
  57851. focusedBackground: string;
  57852. /** Gets or sets the background color when focused */
  57853. focusedColor: string;
  57854. /** Gets or sets the background color */
  57855. background: string;
  57856. /** Gets or sets the placeholder color */
  57857. placeholderColor: string;
  57858. /** Gets or sets the text displayed when the control is empty */
  57859. placeholderText: string;
  57860. /** Gets or sets the dead key flag */
  57861. deadKey: boolean;
  57862. /** Gets or sets the highlight text */
  57863. highlightedText: string;
  57864. /** Gets or sets if the current key should be added */
  57865. addKey: boolean;
  57866. /** Gets or sets the value of the current key being entered */
  57867. currentKey: string;
  57868. /** Gets or sets the text displayed in the control */
  57869. text: string;
  57870. /** Gets or sets control width */
  57871. width: string | number;
  57872. /**
  57873. * Creates a new InputText
  57874. * @param name defines the control name
  57875. * @param text defines the text of the control
  57876. */
  57877. constructor(name?: string | undefined, text?: string);
  57878. /** @hidden */
  57879. onBlur(): void;
  57880. /** @hidden */
  57881. onFocus(): void;
  57882. protected _getTypeName(): string;
  57883. /**
  57884. * Function called to get the list of controls that should not steal the focus from this control
  57885. * @returns an array of controls
  57886. */
  57887. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  57888. /** @hidden */
  57889. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  57890. /** @hidden */
  57891. private _updateValueFromCursorIndex;
  57892. /** @hidden */
  57893. private _processDblClick;
  57894. /** @hidden */
  57895. private _selectAllText;
  57896. /**
  57897. * Handles the keyboard event
  57898. * @param evt Defines the KeyboardEvent
  57899. */
  57900. processKeyboard(evt: KeyboardEvent): void;
  57901. /** @hidden */
  57902. private _onCopyText;
  57903. /** @hidden */
  57904. private _onCutText;
  57905. /** @hidden */
  57906. 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;
  57907. protected _beforeRenderText(text: string): string;
  57908. dispose(): void;
  57909. }
  57910. }
  57911. declare module BABYLON.GUI {
  57912. /**
  57913. * Class used to create a 2D grid container
  57914. */
  57915. export class Grid extends Container {
  57916. name?: string | undefined;
  57917. private _rowDefinitions;
  57918. private _columnDefinitions;
  57919. private _cells;
  57920. private _childControls;
  57921. /**
  57922. * Gets the number of columns
  57923. */
  57924. readonly columnCount: number;
  57925. /**
  57926. * Gets the number of rows
  57927. */
  57928. readonly rowCount: number;
  57929. /** Gets the list of children */
  57930. readonly children: Control[];
  57931. /**
  57932. * Gets the definition of a specific row
  57933. * @param index defines the index of the row
  57934. * @returns the row definition
  57935. */
  57936. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  57937. /**
  57938. * Gets the definition of a specific column
  57939. * @param index defines the index of the column
  57940. * @returns the column definition
  57941. */
  57942. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  57943. /**
  57944. * Adds a new row to the grid
  57945. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  57946. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  57947. * @returns the current grid
  57948. */
  57949. addRowDefinition(height: number, isPixel?: boolean): Grid;
  57950. /**
  57951. * Adds a new column to the grid
  57952. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  57953. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  57954. * @returns the current grid
  57955. */
  57956. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  57957. /**
  57958. * Update a row definition
  57959. * @param index defines the index of the row to update
  57960. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  57961. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  57962. * @returns the current grid
  57963. */
  57964. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  57965. /**
  57966. * Update a column definition
  57967. * @param index defines the index of the column to update
  57968. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  57969. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  57970. * @returns the current grid
  57971. */
  57972. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  57973. /**
  57974. * Gets the list of children stored in a specific cell
  57975. * @param row defines the row to check
  57976. * @param column defines the column to check
  57977. * @returns the list of controls
  57978. */
  57979. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  57980. /**
  57981. * Gets a string representing the child cell info (row x column)
  57982. * @param child defines the control to get info from
  57983. * @returns a string containing the child cell info (row x column)
  57984. */
  57985. getChildCellInfo(child: Control): string;
  57986. private _removeCell;
  57987. private _offsetCell;
  57988. /**
  57989. * Remove a column definition at specified index
  57990. * @param index defines the index of the column to remove
  57991. * @returns the current grid
  57992. */
  57993. removeColumnDefinition(index: number): Grid;
  57994. /**
  57995. * Remove a row definition at specified index
  57996. * @param index defines the index of the row to remove
  57997. * @returns the current grid
  57998. */
  57999. removeRowDefinition(index: number): Grid;
  58000. /**
  58001. * Adds a new control to the current grid
  58002. * @param control defines the control to add
  58003. * @param row defines the row where to add the control (0 by default)
  58004. * @param column defines the column where to add the control (0 by default)
  58005. * @returns the current grid
  58006. */
  58007. addControl(control: Control, row?: number, column?: number): Grid;
  58008. /**
  58009. * Removes a control from the current container
  58010. * @param control defines the control to remove
  58011. * @returns the current container
  58012. */
  58013. removeControl(control: Control): Container;
  58014. /**
  58015. * Creates a new Grid
  58016. * @param name defines control name
  58017. */
  58018. constructor(name?: string | undefined);
  58019. protected _getTypeName(): string;
  58020. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  58021. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58022. /** Releases associated resources */
  58023. dispose(): void;
  58024. }
  58025. }
  58026. declare module BABYLON.GUI {
  58027. /** Class used to create color pickers */
  58028. export class ColorPicker extends Control {
  58029. name?: string | undefined;
  58030. private static _Epsilon;
  58031. private _colorWheelCanvas;
  58032. private _value;
  58033. private _tmpColor;
  58034. private _pointerStartedOnSquare;
  58035. private _pointerStartedOnWheel;
  58036. private _squareLeft;
  58037. private _squareTop;
  58038. private _squareSize;
  58039. private _h;
  58040. private _s;
  58041. private _v;
  58042. /**
  58043. * BABYLON.Observable raised when the value changes
  58044. */
  58045. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  58046. /** Gets or sets the color of the color picker */
  58047. value: BABYLON.Color3;
  58048. /**
  58049. * Gets or sets control width
  58050. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58051. */
  58052. width: string | number;
  58053. /**
  58054. * Gets or sets control height
  58055. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58056. */
  58057. /** Gets or sets control height */
  58058. height: string | number;
  58059. /** Gets or sets control size */
  58060. size: string | number;
  58061. /**
  58062. * Creates a new ColorPicker
  58063. * @param name defines the control name
  58064. */
  58065. constructor(name?: string | undefined);
  58066. protected _getTypeName(): string;
  58067. /** @hidden */
  58068. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58069. private _updateSquareProps;
  58070. private _drawGradientSquare;
  58071. private _drawCircle;
  58072. private _createColorWheelCanvas;
  58073. private _RGBtoHSV;
  58074. private _HSVtoRGB;
  58075. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  58076. private _pointerIsDown;
  58077. private _updateValueFromPointer;
  58078. private _isPointOnSquare;
  58079. 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;
  58080. /**
  58081. * This function expands the color picker by creating a color picker dialog with manual
  58082. * color value input and the ability to save colors into an array to be used later in
  58083. * subsequent launches of the dialogue.
  58084. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  58085. * @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.
  58086. * @returns picked color as a hex string and the saved colors array as hex strings.
  58087. */
  58088. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  58089. pickerWidth?: string;
  58090. pickerHeight?: string;
  58091. headerHeight?: string;
  58092. lastColor?: string;
  58093. swatchLimit?: number;
  58094. numSwatchesPerLine?: number;
  58095. savedColors?: Array<string>;
  58096. }): Promise<{
  58097. savedColors?: string[];
  58098. pickedColor: string;
  58099. }>;
  58100. }
  58101. }
  58102. declare module BABYLON.GUI {
  58103. /** Class used to create 2D ellipse containers */
  58104. export class Ellipse extends Container {
  58105. name?: string | undefined;
  58106. private _thickness;
  58107. /** Gets or sets border thickness */
  58108. thickness: number;
  58109. /**
  58110. * Creates a new Ellipse
  58111. * @param name defines the control name
  58112. */
  58113. constructor(name?: string | undefined);
  58114. protected _getTypeName(): string;
  58115. protected _localDraw(context: CanvasRenderingContext2D): void;
  58116. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58117. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  58118. }
  58119. }
  58120. declare module BABYLON.GUI {
  58121. /**
  58122. * Class used to create a password control
  58123. */
  58124. export class InputPassword extends InputText {
  58125. protected _beforeRenderText(text: string): string;
  58126. }
  58127. }
  58128. declare module BABYLON.GUI {
  58129. /** Class used to render 2D lines */
  58130. export class Line extends Control {
  58131. name?: string | undefined;
  58132. private _lineWidth;
  58133. private _x1;
  58134. private _y1;
  58135. private _x2;
  58136. private _y2;
  58137. private _dash;
  58138. private _connectedControl;
  58139. private _connectedControlDirtyObserver;
  58140. /** Gets or sets the dash pattern */
  58141. dash: Array<number>;
  58142. /** Gets or sets the control connected with the line end */
  58143. connectedControl: Control;
  58144. /** Gets or sets start coordinates on X axis */
  58145. x1: string | number;
  58146. /** Gets or sets start coordinates on Y axis */
  58147. y1: string | number;
  58148. /** Gets or sets end coordinates on X axis */
  58149. x2: string | number;
  58150. /** Gets or sets end coordinates on Y axis */
  58151. y2: string | number;
  58152. /** Gets or sets line width */
  58153. lineWidth: number;
  58154. /** Gets or sets horizontal alignment */
  58155. horizontalAlignment: number;
  58156. /** Gets or sets vertical alignment */
  58157. verticalAlignment: number;
  58158. private readonly _effectiveX2;
  58159. private readonly _effectiveY2;
  58160. /**
  58161. * Creates a new Line
  58162. * @param name defines the control name
  58163. */
  58164. constructor(name?: string | undefined);
  58165. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  58166. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58167. /**
  58168. * Move one end of the line given 3D cartesian coordinates.
  58169. * @param position Targeted world position
  58170. * @param scene BABYLON.Scene
  58171. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58172. */
  58173. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  58174. /**
  58175. * Move one end of the line to a position in screen absolute space.
  58176. * @param projectedPosition Position in screen absolute space (X, Y)
  58177. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58178. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  58179. }
  58180. }
  58181. declare module BABYLON.GUI {
  58182. /**
  58183. * Class used to store a point for a MultiLine object.
  58184. * The point can be pure 2D coordinates, a mesh or a control
  58185. */
  58186. export class MultiLinePoint {
  58187. private _multiLine;
  58188. private _x;
  58189. private _y;
  58190. private _control;
  58191. private _mesh;
  58192. private _controlObserver;
  58193. private _meshObserver;
  58194. /** @hidden */ point: BABYLON.Vector2;
  58195. /**
  58196. * Creates a new MultiLinePoint
  58197. * @param multiLine defines the source MultiLine object
  58198. */
  58199. constructor(multiLine: MultiLine);
  58200. /** Gets or sets x coordinate */
  58201. x: string | number;
  58202. /** Gets or sets y coordinate */
  58203. y: string | number;
  58204. /** Gets or sets the control associated with this point */
  58205. control: BABYLON.Nullable<Control>;
  58206. /** Gets or sets the mesh associated with this point */
  58207. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58208. /** Resets links */
  58209. resetLinks(): void;
  58210. /**
  58211. * Gets a translation vector
  58212. * @returns the translation vector
  58213. */
  58214. translate(): BABYLON.Vector2;
  58215. private _translatePoint;
  58216. /** Release associated resources */
  58217. dispose(): void;
  58218. }
  58219. }
  58220. declare module BABYLON.GUI {
  58221. /**
  58222. * Class used to create multi line control
  58223. */
  58224. export class MultiLine extends Control {
  58225. name?: string | undefined;
  58226. private _lineWidth;
  58227. private _dash;
  58228. private _points;
  58229. private _minX;
  58230. private _minY;
  58231. private _maxX;
  58232. private _maxY;
  58233. /**
  58234. * Creates a new MultiLine
  58235. * @param name defines the control name
  58236. */
  58237. constructor(name?: string | undefined);
  58238. /** Gets or sets dash pattern */
  58239. dash: Array<number>;
  58240. /**
  58241. * Gets point stored at specified index
  58242. * @param index defines the index to look for
  58243. * @returns the requested point if found
  58244. */
  58245. getAt(index: number): MultiLinePoint;
  58246. /** Function called when a point is updated */
  58247. onPointUpdate: () => void;
  58248. /**
  58249. * Adds new points to the point collection
  58250. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  58251. * @returns the list of created MultiLinePoint
  58252. */
  58253. add(...items: (AbstractMesh | Control | {
  58254. x: string | number;
  58255. y: string | number;
  58256. })[]): MultiLinePoint[];
  58257. /**
  58258. * Adds a new point to the point collection
  58259. * @param item defines the item (mesh, control or 2d coordiantes) to add
  58260. * @returns the created MultiLinePoint
  58261. */
  58262. push(item?: (AbstractMesh | Control | {
  58263. x: string | number;
  58264. y: string | number;
  58265. })): MultiLinePoint;
  58266. /**
  58267. * Remove a specific value or point from the active point collection
  58268. * @param value defines the value or point to remove
  58269. */
  58270. remove(value: number | MultiLinePoint): void;
  58271. /**
  58272. * Resets this object to initial state (no point)
  58273. */
  58274. reset(): void;
  58275. /**
  58276. * Resets all links
  58277. */
  58278. resetLinks(): void;
  58279. /** Gets or sets line width */
  58280. lineWidth: number;
  58281. horizontalAlignment: number;
  58282. verticalAlignment: number;
  58283. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58284. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  58285. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58286. dispose(): void;
  58287. }
  58288. }
  58289. declare module BABYLON.GUI {
  58290. /**
  58291. * Class used to create radio button controls
  58292. */
  58293. export class RadioButton extends Control {
  58294. name?: string | undefined;
  58295. private _isChecked;
  58296. private _background;
  58297. private _checkSizeRatio;
  58298. private _thickness;
  58299. /** Gets or sets border thickness */
  58300. thickness: number;
  58301. /** Gets or sets group name */
  58302. group: string;
  58303. /** BABYLON.Observable raised when isChecked is changed */
  58304. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  58305. /** Gets or sets a value indicating the ratio between overall size and check size */
  58306. checkSizeRatio: number;
  58307. /** Gets or sets background color */
  58308. background: string;
  58309. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  58310. isChecked: boolean;
  58311. /**
  58312. * Creates a new RadioButton
  58313. * @param name defines the control name
  58314. */
  58315. constructor(name?: string | undefined);
  58316. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58317. /**
  58318. * Utility function to easily create a radio button with a header
  58319. * @param title defines the label to use for the header
  58320. * @param group defines the group to use for the radio button
  58321. * @param isChecked defines the initial state of the radio button
  58322. * @param onValueChanged defines the callback to call when value changes
  58323. * @returns a StackPanel containing the radio button and a textBlock
  58324. */
  58325. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  58326. }
  58327. }
  58328. declare module BABYLON.GUI {
  58329. /**
  58330. * Class used to create slider controls
  58331. */
  58332. export class BaseSlider extends Control {
  58333. name?: string | undefined;
  58334. protected _thumbWidth: ValueAndUnit;
  58335. private _minimum;
  58336. private _maximum;
  58337. private _value;
  58338. private _isVertical;
  58339. protected _barOffset: ValueAndUnit;
  58340. private _isThumbClamped;
  58341. protected _displayThumb: boolean;
  58342. private _step;
  58343. protected _effectiveBarOffset: number;
  58344. protected _renderLeft: number;
  58345. protected _renderTop: number;
  58346. protected _renderWidth: number;
  58347. protected _renderHeight: number;
  58348. protected _backgroundBoxLength: number;
  58349. protected _backgroundBoxThickness: number;
  58350. protected _effectiveThumbThickness: number;
  58351. /** BABYLON.Observable raised when the sldier value changes */
  58352. onValueChangedObservable: BABYLON.Observable<number>;
  58353. /** Gets or sets a boolean indicating if the thumb must be rendered */
  58354. displayThumb: boolean;
  58355. /** Gets or sets a step to apply to values (0 by default) */
  58356. step: number;
  58357. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  58358. barOffset: string | number;
  58359. /** Gets main bar offset in pixels*/
  58360. readonly barOffsetInPixels: number;
  58361. /** Gets or sets thumb width */
  58362. thumbWidth: string | number;
  58363. /** Gets thumb width in pixels */
  58364. readonly thumbWidthInPixels: number;
  58365. /** Gets or sets minimum value */
  58366. minimum: number;
  58367. /** Gets or sets maximum value */
  58368. maximum: number;
  58369. /** Gets or sets current value */
  58370. value: number;
  58371. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  58372. isVertical: boolean;
  58373. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  58374. isThumbClamped: boolean;
  58375. /**
  58376. * Creates a new BaseSlider
  58377. * @param name defines the control name
  58378. */
  58379. constructor(name?: string | undefined);
  58380. protected _getTypeName(): string;
  58381. protected _getThumbPosition(): number;
  58382. protected _getThumbThickness(type: string): number;
  58383. protected _prepareRenderingData(type: string): void;
  58384. private _pointerIsDown;
  58385. /** @hidden */
  58386. 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;
  58387. }
  58388. }
  58389. declare module BABYLON.GUI {
  58390. /**
  58391. * Class used to create slider controls
  58392. */
  58393. export class Slider extends BaseSlider {
  58394. name?: string | undefined;
  58395. private _background;
  58396. private _borderColor;
  58397. private _isThumbCircle;
  58398. protected _displayValueBar: boolean;
  58399. /** Gets or sets a boolean indicating if the value bar must be rendered */
  58400. displayValueBar: boolean;
  58401. /** Gets or sets border color */
  58402. borderColor: string;
  58403. /** Gets or sets background color */
  58404. background: string;
  58405. /** Gets or sets a boolean indicating if the thumb should be round or square */
  58406. isThumbCircle: boolean;
  58407. /**
  58408. * Creates a new Slider
  58409. * @param name defines the control name
  58410. */
  58411. constructor(name?: string | undefined);
  58412. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58413. }
  58414. }
  58415. declare module BABYLON.GUI {
  58416. /** Class used to create a RadioGroup
  58417. * which contains groups of radio buttons
  58418. */
  58419. export class SelectorGroup {
  58420. /** name of SelectorGroup */
  58421. name: string;
  58422. private _groupPanel;
  58423. private _selectors;
  58424. private _groupHeader;
  58425. /**
  58426. * Creates a new SelectorGroup
  58427. * @param name of group, used as a group heading
  58428. */
  58429. constructor(
  58430. /** name of SelectorGroup */
  58431. name: string);
  58432. /** Gets the groupPanel of the SelectorGroup */
  58433. readonly groupPanel: StackPanel;
  58434. /** Gets the selectors array */
  58435. readonly selectors: StackPanel[];
  58436. /** Gets and sets the group header */
  58437. header: string;
  58438. /** @hidden */
  58439. private _addGroupHeader;
  58440. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  58441. /** Removes the selector at the given position
  58442. * @param selectorNb the position of the selector within the group
  58443. */
  58444. removeSelector(selectorNb: number): void;
  58445. }
  58446. /** Class used to create a CheckboxGroup
  58447. * which contains groups of checkbox buttons
  58448. */
  58449. export class CheckboxGroup extends SelectorGroup {
  58450. /** Adds a checkbox as a control
  58451. * @param text is the label for the selector
  58452. * @param func is the function called when the Selector is checked
  58453. * @param checked is true when Selector is checked
  58454. */
  58455. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  58456. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58457. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58458. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58459. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58460. }
  58461. /** Class used to create a RadioGroup
  58462. * which contains groups of radio buttons
  58463. */
  58464. export class RadioGroup extends SelectorGroup {
  58465. private _selectNb;
  58466. /** Adds a radio button as a control
  58467. * @param label is the label for the selector
  58468. * @param func is the function called when the Selector is checked
  58469. * @param checked is true when Selector is checked
  58470. */
  58471. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  58472. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58473. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58474. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58475. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58476. }
  58477. /** Class used to create a SliderGroup
  58478. * which contains groups of slider buttons
  58479. */
  58480. export class SliderGroup extends SelectorGroup {
  58481. /**
  58482. * Adds a slider to the SelectorGroup
  58483. * @param label is the label for the SliderBar
  58484. * @param func is the function called when the Slider moves
  58485. * @param unit is a string describing the units used, eg degrees or metres
  58486. * @param min is the minimum value for the Slider
  58487. * @param max is the maximum value for the Slider
  58488. * @param value is the start value for the Slider between min and max
  58489. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  58490. */
  58491. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  58492. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58493. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58494. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58495. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58496. }
  58497. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  58498. * @see http://doc.babylonjs.com/how_to/selector
  58499. */
  58500. export class SelectionPanel extends Rectangle {
  58501. /** name of SelectionPanel */
  58502. name: string;
  58503. /** an array of SelectionGroups */
  58504. groups: SelectorGroup[];
  58505. private _panel;
  58506. private _buttonColor;
  58507. private _buttonBackground;
  58508. private _headerColor;
  58509. private _barColor;
  58510. private _barHeight;
  58511. private _spacerHeight;
  58512. private _labelColor;
  58513. private _groups;
  58514. private _bars;
  58515. /**
  58516. * Creates a new SelectionPanel
  58517. * @param name of SelectionPanel
  58518. * @param groups is an array of SelectionGroups
  58519. */
  58520. constructor(
  58521. /** name of SelectionPanel */
  58522. name: string,
  58523. /** an array of SelectionGroups */
  58524. groups?: SelectorGroup[]);
  58525. protected _getTypeName(): string;
  58526. /** Gets or sets the headerColor */
  58527. headerColor: string;
  58528. private _setHeaderColor;
  58529. /** Gets or sets the button color */
  58530. buttonColor: string;
  58531. private _setbuttonColor;
  58532. /** Gets or sets the label color */
  58533. labelColor: string;
  58534. private _setLabelColor;
  58535. /** Gets or sets the button background */
  58536. buttonBackground: string;
  58537. private _setButtonBackground;
  58538. /** Gets or sets the color of separator bar */
  58539. barColor: string;
  58540. private _setBarColor;
  58541. /** Gets or sets the height of separator bar */
  58542. barHeight: string;
  58543. private _setBarHeight;
  58544. /** Gets or sets the height of spacers*/
  58545. spacerHeight: string;
  58546. private _setSpacerHeight;
  58547. /** Adds a bar between groups */
  58548. private _addSpacer;
  58549. /** Add a group to the selection panel
  58550. * @param group is the selector group to add
  58551. */
  58552. addGroup(group: SelectorGroup): void;
  58553. /** Remove the group from the given position
  58554. * @param groupNb is the position of the group in the list
  58555. */
  58556. removeGroup(groupNb: number): void;
  58557. /** Change a group header label
  58558. * @param label is the new group header label
  58559. * @param groupNb is the number of the group to relabel
  58560. * */
  58561. setHeaderName(label: string, groupNb: number): void;
  58562. /** Change selector label to the one given
  58563. * @param label is the new selector label
  58564. * @param groupNb is the number of the groupcontaining the selector
  58565. * @param selectorNb is the number of the selector within a group to relabel
  58566. * */
  58567. relabel(label: string, groupNb: number, selectorNb: number): void;
  58568. /** For a given group position remove the selector at the given position
  58569. * @param groupNb is the number of the group to remove the selector from
  58570. * @param selectorNb is the number of the selector within the group
  58571. */
  58572. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  58573. /** For a given group position of correct type add a checkbox button
  58574. * @param groupNb is the number of the group to remove the selector from
  58575. * @param label is the label for the selector
  58576. * @param func is the function called when the Selector is checked
  58577. * @param checked is true when Selector is checked
  58578. */
  58579. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58580. /** For a given group position of correct type add a radio button
  58581. * @param groupNb is the number of the group to remove the selector from
  58582. * @param label is the label for the selector
  58583. * @param func is the function called when the Selector is checked
  58584. * @param checked is true when Selector is checked
  58585. */
  58586. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58587. /**
  58588. * For a given slider group add a slider
  58589. * @param groupNb is the number of the group to add the slider to
  58590. * @param label is the label for the Slider
  58591. * @param func is the function called when the Slider moves
  58592. * @param unit is a string describing the units used, eg degrees or metres
  58593. * @param min is the minimum value for the Slider
  58594. * @param max is the maximum value for the Slider
  58595. * @param value is the start value for the Slider between min and max
  58596. * @param onVal is the function used to format the value displayed, eg radians to degrees
  58597. */
  58598. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  58599. }
  58600. }
  58601. declare module BABYLON.GUI {
  58602. /**
  58603. * Class used to hold a the container for ScrollViewer
  58604. * @hidden
  58605. */
  58606. export class _ScrollViewerWindow extends Container {
  58607. parentClientWidth: number;
  58608. parentClientHeight: number;
  58609. /**
  58610. * Creates a new ScrollViewerWindow
  58611. * @param name of ScrollViewerWindow
  58612. */
  58613. constructor(name?: string);
  58614. protected _getTypeName(): string;
  58615. /** @hidden */
  58616. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58617. protected _postMeasure(): void;
  58618. }
  58619. }
  58620. declare module BABYLON.GUI {
  58621. /**
  58622. * Class used to create slider controls
  58623. */
  58624. export class ScrollBar extends BaseSlider {
  58625. name?: string | undefined;
  58626. private _background;
  58627. private _borderColor;
  58628. private _thumbMeasure;
  58629. /** Gets or sets border color */
  58630. borderColor: string;
  58631. /** Gets or sets background color */
  58632. background: string;
  58633. /**
  58634. * Creates a new Slider
  58635. * @param name defines the control name
  58636. */
  58637. constructor(name?: string | undefined);
  58638. protected _getTypeName(): string;
  58639. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  58640. private _first;
  58641. private _originX;
  58642. private _originY;
  58643. /** @hidden */
  58644. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58645. }
  58646. }
  58647. declare module BABYLON.GUI {
  58648. /**
  58649. * Class used to hold a viewer window and sliders in a grid
  58650. */
  58651. export class ScrollViewer extends Rectangle {
  58652. private _grid;
  58653. private _horizontalBarSpace;
  58654. private _verticalBarSpace;
  58655. private _dragSpace;
  58656. private _horizontalBar;
  58657. private _verticalBar;
  58658. private _barColor;
  58659. private _barBackground;
  58660. private _barSize;
  58661. private _endLeft;
  58662. private _endTop;
  58663. private _window;
  58664. private _pointerIsOver;
  58665. private _wheelPrecision;
  58666. private _onPointerObserver;
  58667. private _clientWidth;
  58668. private _clientHeight;
  58669. /**
  58670. * Gets the horizontal scrollbar
  58671. */
  58672. readonly horizontalBar: ScrollBar;
  58673. /**
  58674. * Gets the vertical scrollbar
  58675. */
  58676. readonly verticalBar: ScrollBar;
  58677. /**
  58678. * Adds a new control to the current container
  58679. * @param control defines the control to add
  58680. * @returns the current container
  58681. */
  58682. addControl(control: BABYLON.Nullable<Control>): Container;
  58683. /**
  58684. * Removes a control from the current container
  58685. * @param control defines the control to remove
  58686. * @returns the current container
  58687. */
  58688. removeControl(control: Control): Container;
  58689. /** Gets the list of children */
  58690. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  58691. /**
  58692. * Creates a new ScrollViewer
  58693. * @param name of ScrollViewer
  58694. */
  58695. constructor(name?: string);
  58696. /** Reset the scroll viewer window to initial size */
  58697. resetWindow(): void;
  58698. protected _getTypeName(): string;
  58699. private _buildClientSizes;
  58700. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58701. protected _postMeasure(): void;
  58702. /**
  58703. * Gets or sets the mouse wheel precision
  58704. * from 0 to 1 with a default value of 0.05
  58705. * */
  58706. wheelPrecision: number;
  58707. /** Gets or sets the bar color */
  58708. barColor: string;
  58709. /** Gets or sets the size of the bar */
  58710. barSize: number;
  58711. /** Gets or sets the bar background */
  58712. barBackground: string;
  58713. /** @hidden */
  58714. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  58715. /** @hidden */
  58716. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58717. /** Releases associated resources */
  58718. dispose(): void;
  58719. }
  58720. }
  58721. declare module BABYLON.GUI {
  58722. /** Class used to render a grid */
  58723. export class DisplayGrid extends Control {
  58724. name?: string | undefined;
  58725. private _cellWidth;
  58726. private _cellHeight;
  58727. private _minorLineTickness;
  58728. private _minorLineColor;
  58729. private _majorLineTickness;
  58730. private _majorLineColor;
  58731. private _majorLineFrequency;
  58732. private _background;
  58733. private _displayMajorLines;
  58734. private _displayMinorLines;
  58735. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  58736. displayMinorLines: boolean;
  58737. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  58738. displayMajorLines: boolean;
  58739. /** Gets or sets background color (Black by default) */
  58740. background: string;
  58741. /** Gets or sets the width of each cell (20 by default) */
  58742. cellWidth: number;
  58743. /** Gets or sets the height of each cell (20 by default) */
  58744. cellHeight: number;
  58745. /** Gets or sets the tickness of minor lines (1 by default) */
  58746. minorLineTickness: number;
  58747. /** Gets or sets the color of minor lines (DarkGray by default) */
  58748. minorLineColor: string;
  58749. /** Gets or sets the tickness of major lines (2 by default) */
  58750. majorLineTickness: number;
  58751. /** Gets or sets the color of major lines (White by default) */
  58752. majorLineColor: string;
  58753. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  58754. majorLineFrequency: number;
  58755. /**
  58756. * Creates a new GridDisplayRectangle
  58757. * @param name defines the control name
  58758. */
  58759. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  58760. protected _getTypeName(): string;
  58761. }
  58762. }
  58763. declare module BABYLON.GUI {
  58764. /**
  58765. * Class used to create slider controls based on images
  58766. */
  58767. export class ImageBasedSlider extends BaseSlider {
  58768. name?: string | undefined;
  58769. private _backgroundImage;
  58770. private _thumbImage;
  58771. private _valueBarImage;
  58772. private _tempMeasure;
  58773. displayThumb: boolean;
  58774. /**
  58775. * Gets or sets the image used to render the background
  58776. */
  58777. backgroundImage: Image;
  58778. /**
  58779. * Gets or sets the image used to render the value bar
  58780. */
  58781. valueBarImage: Image;
  58782. /**
  58783. * Gets or sets the image used to render the thumb
  58784. */
  58785. thumbImage: Image;
  58786. /**
  58787. * Creates a new ImageBasedSlider
  58788. * @param name defines the control name
  58789. */
  58790. constructor(name?: string | undefined);
  58791. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58792. }
  58793. }
  58794. declare module BABYLON.GUI {
  58795. /**
  58796. * Forcing an export so that this code will execute
  58797. * @hidden
  58798. */
  58799. const name = "Statics";
  58800. }
  58801. declare module BABYLON.GUI {
  58802. /**
  58803. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  58804. */
  58805. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  58806. /**
  58807. * Define the instrumented AdvancedDynamicTexture.
  58808. */
  58809. texture: AdvancedDynamicTexture;
  58810. private _captureRenderTime;
  58811. private _renderTime;
  58812. private _captureLayoutTime;
  58813. private _layoutTime;
  58814. private _onBeginRenderObserver;
  58815. private _onEndRenderObserver;
  58816. private _onBeginLayoutObserver;
  58817. private _onEndLayoutObserver;
  58818. /**
  58819. * Gets the perf counter used to capture render time
  58820. */
  58821. readonly renderTimeCounter: BABYLON.PerfCounter;
  58822. /**
  58823. * Gets the perf counter used to capture layout time
  58824. */
  58825. readonly layoutTimeCounter: BABYLON.PerfCounter;
  58826. /**
  58827. * Enable or disable the render time capture
  58828. */
  58829. captureRenderTime: boolean;
  58830. /**
  58831. * Enable or disable the layout time capture
  58832. */
  58833. captureLayoutTime: boolean;
  58834. /**
  58835. * Instantiates a new advanced dynamic texture instrumentation.
  58836. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  58837. * @param texture Defines the AdvancedDynamicTexture to instrument
  58838. */
  58839. constructor(
  58840. /**
  58841. * Define the instrumented AdvancedDynamicTexture.
  58842. */
  58843. texture: AdvancedDynamicTexture);
  58844. /**
  58845. * Dispose and release associated resources.
  58846. */
  58847. dispose(): void;
  58848. }
  58849. }
  58850. declare module BABYLON.GUI {
  58851. /**
  58852. * Class used to create containers for controls
  58853. */
  58854. export class Container3D extends Control3D {
  58855. private _blockLayout;
  58856. /**
  58857. * Gets the list of child controls
  58858. */
  58859. protected _children: Control3D[];
  58860. /**
  58861. * Gets the list of child controls
  58862. */
  58863. readonly children: Array<Control3D>;
  58864. /**
  58865. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  58866. * This is helpful to optimize layout operation when adding multiple children in a row
  58867. */
  58868. blockLayout: boolean;
  58869. /**
  58870. * Creates a new container
  58871. * @param name defines the container name
  58872. */
  58873. constructor(name?: string);
  58874. /**
  58875. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  58876. * @returns the current container
  58877. */
  58878. updateLayout(): Container3D;
  58879. /**
  58880. * Gets a boolean indicating if the given control is in the children of this control
  58881. * @param control defines the control to check
  58882. * @returns true if the control is in the child list
  58883. */
  58884. containsControl(control: Control3D): boolean;
  58885. /**
  58886. * Adds a control to the children of this control
  58887. * @param control defines the control to add
  58888. * @returns the current container
  58889. */
  58890. addControl(control: Control3D): Container3D;
  58891. /**
  58892. * This function will be called everytime a new control is added
  58893. */
  58894. protected _arrangeChildren(): void;
  58895. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  58896. /**
  58897. * Removes a control from the children of this control
  58898. * @param control defines the control to remove
  58899. * @returns the current container
  58900. */
  58901. removeControl(control: Control3D): Container3D;
  58902. protected _getTypeName(): string;
  58903. /**
  58904. * Releases all associated resources
  58905. */
  58906. dispose(): void;
  58907. /** Control rotation will remain unchanged */
  58908. static readonly UNSET_ORIENTATION: number;
  58909. /** Control will rotate to make it look at sphere central axis */
  58910. static readonly FACEORIGIN_ORIENTATION: number;
  58911. /** Control will rotate to make it look back at sphere central axis */
  58912. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  58913. /** Control will rotate to look at z axis (0, 0, 1) */
  58914. static readonly FACEFORWARD_ORIENTATION: number;
  58915. /** Control will rotate to look at negative z axis (0, 0, -1) */
  58916. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  58917. }
  58918. }
  58919. declare module BABYLON.GUI {
  58920. /**
  58921. * Class used to manage 3D user interface
  58922. * @see http://doc.babylonjs.com/how_to/gui3d
  58923. */
  58924. export class GUI3DManager implements BABYLON.IDisposable {
  58925. private _scene;
  58926. private _sceneDisposeObserver;
  58927. private _utilityLayer;
  58928. private _rootContainer;
  58929. private _pointerObserver;
  58930. private _pointerOutObserver;
  58931. /** @hidden */ lastPickedControl: Control3D;
  58932. /** @hidden */ lastControlOver: {
  58933. [pointerId: number]: Control3D;
  58934. };
  58935. /** @hidden */ lastControlDown: {
  58936. [pointerId: number]: Control3D;
  58937. };
  58938. /**
  58939. * BABYLON.Observable raised when the point picked by the pointer events changed
  58940. */
  58941. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  58942. /** @hidden */ sharedMaterials: {
  58943. [key: string]: BABYLON.Material;
  58944. };
  58945. /** Gets the hosting scene */
  58946. readonly scene: BABYLON.Scene;
  58947. /** Gets associated utility layer */
  58948. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  58949. /**
  58950. * Creates a new GUI3DManager
  58951. * @param scene
  58952. */
  58953. constructor(scene?: BABYLON.Scene);
  58954. private _handlePointerOut;
  58955. private _doPicking;
  58956. /**
  58957. * Gets the root container
  58958. */
  58959. readonly rootContainer: Container3D;
  58960. /**
  58961. * Gets a boolean indicating if the given control is in the root child list
  58962. * @param control defines the control to check
  58963. * @returns true if the control is in the root child list
  58964. */
  58965. containsControl(control: Control3D): boolean;
  58966. /**
  58967. * Adds a control to the root child list
  58968. * @param control defines the control to add
  58969. * @returns the current manager
  58970. */
  58971. addControl(control: Control3D): GUI3DManager;
  58972. /**
  58973. * Removes a control from the root child list
  58974. * @param control defines the control to remove
  58975. * @returns the current container
  58976. */
  58977. removeControl(control: Control3D): GUI3DManager;
  58978. /**
  58979. * Releases all associated resources
  58980. */
  58981. dispose(): void;
  58982. }
  58983. }
  58984. declare module BABYLON.GUI {
  58985. /**
  58986. * Class used to transport BABYLON.Vector3 information for pointer events
  58987. */
  58988. export class Vector3WithInfo extends BABYLON.Vector3 {
  58989. /** defines the current mouse button index */
  58990. buttonIndex: number;
  58991. /**
  58992. * Creates a new Vector3WithInfo
  58993. * @param source defines the vector3 data to transport
  58994. * @param buttonIndex defines the current mouse button index
  58995. */
  58996. constructor(source: BABYLON.Vector3,
  58997. /** defines the current mouse button index */
  58998. buttonIndex?: number);
  58999. }
  59000. }
  59001. declare module BABYLON.GUI {
  59002. /**
  59003. * Class used as base class for controls
  59004. */
  59005. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  59006. /** Defines the control name */
  59007. name?: string | undefined;
  59008. /** @hidden */ host: GUI3DManager;
  59009. private _node;
  59010. private _downCount;
  59011. private _enterCount;
  59012. private _downPointerIds;
  59013. private _isVisible;
  59014. /** Gets or sets the control position in world space */
  59015. position: BABYLON.Vector3;
  59016. /** Gets or sets the control scaling in world space */
  59017. scaling: BABYLON.Vector3;
  59018. /** Callback used to start pointer enter animation */
  59019. pointerEnterAnimation: () => void;
  59020. /** Callback used to start pointer out animation */
  59021. pointerOutAnimation: () => void;
  59022. /** Callback used to start pointer down animation */
  59023. pointerDownAnimation: () => void;
  59024. /** Callback used to start pointer up animation */
  59025. pointerUpAnimation: () => void;
  59026. /**
  59027. * An event triggered when the pointer move over the control
  59028. */
  59029. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  59030. /**
  59031. * An event triggered when the pointer move out of the control
  59032. */
  59033. onPointerOutObservable: BABYLON.Observable<Control3D>;
  59034. /**
  59035. * An event triggered when the pointer taps the control
  59036. */
  59037. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  59038. /**
  59039. * An event triggered when pointer is up
  59040. */
  59041. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  59042. /**
  59043. * An event triggered when a control is clicked on (with a mouse)
  59044. */
  59045. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  59046. /**
  59047. * An event triggered when pointer enters the control
  59048. */
  59049. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  59050. /**
  59051. * Gets or sets the parent container
  59052. */
  59053. parent: BABYLON.Nullable<Container3D>;
  59054. private _behaviors;
  59055. /**
  59056. * Gets the list of attached behaviors
  59057. * @see http://doc.babylonjs.com/features/behaviour
  59058. */
  59059. readonly behaviors: BABYLON.Behavior<Control3D>[];
  59060. /**
  59061. * Attach a behavior to the control
  59062. * @see http://doc.babylonjs.com/features/behaviour
  59063. * @param behavior defines the behavior to attach
  59064. * @returns the current control
  59065. */
  59066. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59067. /**
  59068. * Remove an attached behavior
  59069. * @see http://doc.babylonjs.com/features/behaviour
  59070. * @param behavior defines the behavior to attach
  59071. * @returns the current control
  59072. */
  59073. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59074. /**
  59075. * Gets an attached behavior by name
  59076. * @param name defines the name of the behavior to look for
  59077. * @see http://doc.babylonjs.com/features/behaviour
  59078. * @returns null if behavior was not found else the requested behavior
  59079. */
  59080. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  59081. /** Gets or sets a boolean indicating if the control is visible */
  59082. isVisible: boolean;
  59083. /**
  59084. * Creates a new control
  59085. * @param name defines the control name
  59086. */
  59087. constructor(
  59088. /** Defines the control name */
  59089. name?: string | undefined);
  59090. /**
  59091. * Gets a string representing the class name
  59092. */
  59093. readonly typeName: string;
  59094. /**
  59095. * Get the current class name of the control.
  59096. * @returns current class name
  59097. */
  59098. getClassName(): string;
  59099. protected _getTypeName(): string;
  59100. /**
  59101. * Gets the transform node used by this control
  59102. */
  59103. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  59104. /**
  59105. * Gets the mesh used to render this control
  59106. */
  59107. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59108. /**
  59109. * Link the control as child of the given node
  59110. * @param node defines the node to link to. Use null to unlink the control
  59111. * @returns the current control
  59112. */
  59113. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  59114. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  59115. /**
  59116. * Node creation.
  59117. * Can be overriden by children
  59118. * @param scene defines the scene where the node must be attached
  59119. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  59120. */
  59121. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  59122. /**
  59123. * Affect a material to the given mesh
  59124. * @param mesh defines the mesh which will represent the control
  59125. */
  59126. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59127. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  59128. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  59129. /** @hidden */ onPointerOut(target: Control3D): void;
  59130. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59131. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59132. /** @hidden */
  59133. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  59134. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59135. /** @hidden */ disposeNode(): void;
  59136. /**
  59137. * Releases all associated resources
  59138. */
  59139. dispose(): void;
  59140. }
  59141. }
  59142. declare module BABYLON.GUI {
  59143. /**
  59144. * Class used as a root to all buttons
  59145. */
  59146. export class AbstractButton3D extends Control3D {
  59147. /**
  59148. * Creates a new button
  59149. * @param name defines the control name
  59150. */
  59151. constructor(name?: string);
  59152. protected _getTypeName(): string;
  59153. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59154. }
  59155. }
  59156. declare module BABYLON.GUI {
  59157. /**
  59158. * Class used to create a button in 3D
  59159. */
  59160. export class Button3D extends AbstractButton3D {
  59161. /** @hidden */
  59162. protected _currentMaterial: BABYLON.Material;
  59163. private _facadeTexture;
  59164. private _content;
  59165. private _contentResolution;
  59166. private _contentScaleRatio;
  59167. /**
  59168. * Gets or sets the texture resolution used to render content (512 by default)
  59169. */
  59170. contentResolution: BABYLON.int;
  59171. /**
  59172. * Gets or sets the texture scale ratio used to render content (2 by default)
  59173. */
  59174. contentScaleRatio: number;
  59175. protected _disposeFacadeTexture(): void;
  59176. protected _resetContent(): void;
  59177. /**
  59178. * Creates a new button
  59179. * @param name defines the control name
  59180. */
  59181. constructor(name?: string);
  59182. /**
  59183. * Gets or sets the GUI 2D content used to display the button's facade
  59184. */
  59185. content: Control;
  59186. /**
  59187. * Apply the facade texture (created from the content property).
  59188. * This function can be overloaded by child classes
  59189. * @param facadeTexture defines the AdvancedDynamicTexture to use
  59190. */
  59191. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59192. protected _getTypeName(): string;
  59193. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59194. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59195. /**
  59196. * Releases all associated resources
  59197. */
  59198. dispose(): void;
  59199. }
  59200. }
  59201. declare module BABYLON.GUI {
  59202. /**
  59203. * Abstract class used to create a container panel deployed on the surface of a volume
  59204. */
  59205. export abstract class VolumeBasedPanel extends Container3D {
  59206. private _columns;
  59207. private _rows;
  59208. private _rowThenColum;
  59209. private _orientation;
  59210. protected _cellWidth: number;
  59211. protected _cellHeight: number;
  59212. /**
  59213. * Gets or sets the distance between elements
  59214. */
  59215. margin: number;
  59216. /**
  59217. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  59218. * | Value | Type | Description |
  59219. * | ----- | ----------------------------------- | ----------- |
  59220. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  59221. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  59222. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  59223. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  59224. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  59225. */
  59226. orientation: number;
  59227. /**
  59228. * Gets or sets the number of columns requested (10 by default).
  59229. * The panel will automatically compute the number of rows based on number of child controls.
  59230. */
  59231. columns: BABYLON.int;
  59232. /**
  59233. * Gets or sets a the number of rows requested.
  59234. * The panel will automatically compute the number of columns based on number of child controls.
  59235. */
  59236. rows: BABYLON.int;
  59237. /**
  59238. * Creates new VolumeBasedPanel
  59239. */
  59240. constructor();
  59241. protected _arrangeChildren(): void;
  59242. /** Child classes must implement this function to provide correct control positioning */
  59243. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59244. /** Child classes can implement this function to provide additional processing */
  59245. protected _finalProcessing(): void;
  59246. }
  59247. }
  59248. declare module BABYLON.GUI {
  59249. /**
  59250. * Class used to create a container panel deployed on the surface of a cylinder
  59251. */
  59252. export class CylinderPanel extends VolumeBasedPanel {
  59253. private _radius;
  59254. /**
  59255. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  59256. */
  59257. radius: BABYLON.float;
  59258. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59259. private _cylindricalMapping;
  59260. }
  59261. }
  59262. declare module BABYLON.GUI {
  59263. /** @hidden */
  59264. export var fluentVertexShader: {
  59265. name: string;
  59266. shader: string;
  59267. };
  59268. }
  59269. declare module BABYLON.GUI {
  59270. /** @hidden */
  59271. export var fluentPixelShader: {
  59272. name: string;
  59273. shader: string;
  59274. };
  59275. }
  59276. declare module BABYLON.GUI {
  59277. /** @hidden */
  59278. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  59279. INNERGLOW: boolean;
  59280. BORDER: boolean;
  59281. HOVERLIGHT: boolean;
  59282. TEXTURE: boolean;
  59283. constructor();
  59284. }
  59285. /**
  59286. * Class used to render controls with fluent desgin
  59287. */
  59288. export class FluentMaterial extends BABYLON.PushMaterial {
  59289. /**
  59290. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  59291. */
  59292. innerGlowColorIntensity: number;
  59293. /**
  59294. * Gets or sets the inner glow color (white by default)
  59295. */
  59296. innerGlowColor: BABYLON.Color3;
  59297. /**
  59298. * Gets or sets alpha value (default is 1.0)
  59299. */
  59300. alpha: number;
  59301. /**
  59302. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  59303. */
  59304. albedoColor: BABYLON.Color3;
  59305. /**
  59306. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  59307. */
  59308. renderBorders: boolean;
  59309. /**
  59310. * Gets or sets border width (default is 0.5)
  59311. */
  59312. borderWidth: number;
  59313. /**
  59314. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  59315. */
  59316. edgeSmoothingValue: number;
  59317. /**
  59318. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  59319. */
  59320. borderMinValue: number;
  59321. /**
  59322. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  59323. */
  59324. renderHoverLight: boolean;
  59325. /**
  59326. * Gets or sets the radius used to render the hover light (default is 1.0)
  59327. */
  59328. hoverRadius: number;
  59329. /**
  59330. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  59331. */
  59332. hoverColor: BABYLON.Color4;
  59333. /**
  59334. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  59335. */
  59336. hoverPosition: BABYLON.Vector3;
  59337. private _albedoTexture;
  59338. /** Gets or sets the texture to use for albedo color */
  59339. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  59340. /**
  59341. * Creates a new Fluent material
  59342. * @param name defines the name of the material
  59343. * @param scene defines the hosting scene
  59344. */
  59345. constructor(name: string, scene: BABYLON.Scene);
  59346. needAlphaBlending(): boolean;
  59347. needAlphaTesting(): boolean;
  59348. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  59349. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  59350. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  59351. getActiveTextures(): BABYLON.BaseTexture[];
  59352. hasTexture(texture: BABYLON.BaseTexture): boolean;
  59353. dispose(forceDisposeEffect?: boolean): void;
  59354. clone(name: string): FluentMaterial;
  59355. serialize(): any;
  59356. getClassName(): string;
  59357. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  59358. }
  59359. }
  59360. declare module BABYLON.GUI {
  59361. /**
  59362. * Class used to create a holographic button in 3D
  59363. */
  59364. export class HolographicButton extends Button3D {
  59365. private _backPlate;
  59366. private _textPlate;
  59367. private _frontPlate;
  59368. private _text;
  59369. private _imageUrl;
  59370. private _shareMaterials;
  59371. private _frontMaterial;
  59372. private _backMaterial;
  59373. private _plateMaterial;
  59374. private _pickedPointObserver;
  59375. private _tooltipFade;
  59376. private _tooltipTextBlock;
  59377. private _tooltipTexture;
  59378. private _tooltipMesh;
  59379. private _tooltipHoverObserver;
  59380. private _tooltipOutObserver;
  59381. private _disposeTooltip;
  59382. /**
  59383. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  59384. */
  59385. tooltipText: BABYLON.Nullable<string>;
  59386. /**
  59387. * Gets or sets text for the button
  59388. */
  59389. text: string;
  59390. /**
  59391. * Gets or sets the image url for the button
  59392. */
  59393. imageUrl: string;
  59394. /**
  59395. * Gets the back material used by this button
  59396. */
  59397. readonly backMaterial: FluentMaterial;
  59398. /**
  59399. * Gets the front material used by this button
  59400. */
  59401. readonly frontMaterial: FluentMaterial;
  59402. /**
  59403. * Gets the plate material used by this button
  59404. */
  59405. readonly plateMaterial: BABYLON.StandardMaterial;
  59406. /**
  59407. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  59408. */
  59409. readonly shareMaterials: boolean;
  59410. /**
  59411. * Creates a new button
  59412. * @param name defines the control name
  59413. */
  59414. constructor(name?: string, shareMaterials?: boolean);
  59415. protected _getTypeName(): string;
  59416. private _rebuildContent;
  59417. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59418. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59419. private _createBackMaterial;
  59420. private _createFrontMaterial;
  59421. private _createPlateMaterial;
  59422. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  59423. /**
  59424. * Releases all associated resources
  59425. */
  59426. dispose(): void;
  59427. }
  59428. }
  59429. declare module BABYLON.GUI {
  59430. /**
  59431. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  59432. */
  59433. export class MeshButton3D extends Button3D {
  59434. /** @hidden */
  59435. protected _currentMesh: BABYLON.Mesh;
  59436. /**
  59437. * Creates a new 3D button based on a mesh
  59438. * @param mesh mesh to become a 3D button
  59439. * @param name defines the control name
  59440. */
  59441. constructor(mesh: BABYLON.Mesh, name?: string);
  59442. protected _getTypeName(): string;
  59443. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59444. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59445. }
  59446. }
  59447. declare module BABYLON.GUI {
  59448. /**
  59449. * Class used to create a container panel deployed on the surface of a plane
  59450. */
  59451. export class PlanePanel extends VolumeBasedPanel {
  59452. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59453. }
  59454. }
  59455. declare module BABYLON.GUI {
  59456. /**
  59457. * Class used to create a container panel where items get randomized planar mapping
  59458. */
  59459. export class ScatterPanel extends VolumeBasedPanel {
  59460. private _iteration;
  59461. /**
  59462. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  59463. */
  59464. iteration: BABYLON.float;
  59465. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59466. private _scatterMapping;
  59467. protected _finalProcessing(): void;
  59468. }
  59469. }
  59470. declare module BABYLON.GUI {
  59471. /**
  59472. * Class used to create a container panel deployed on the surface of a sphere
  59473. */
  59474. export class SpherePanel extends VolumeBasedPanel {
  59475. private _radius;
  59476. /**
  59477. * Gets or sets the radius of the sphere where to project controls (5 by default)
  59478. */
  59479. radius: BABYLON.float;
  59480. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59481. private _sphericalMapping;
  59482. }
  59483. }
  59484. declare module BABYLON.GUI {
  59485. /**
  59486. * Class used to create a stack panel in 3D on XY plane
  59487. */
  59488. export class StackPanel3D extends Container3D {
  59489. private _isVertical;
  59490. /**
  59491. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  59492. */
  59493. isVertical: boolean;
  59494. /**
  59495. * Gets or sets the distance between elements
  59496. */
  59497. margin: number;
  59498. /**
  59499. * Creates new StackPanel
  59500. * @param isVertical
  59501. */
  59502. constructor(isVertical?: boolean);
  59503. protected _arrangeChildren(): void;
  59504. }
  59505. }
  59506. declare module BABYLON {
  59507. /**
  59508. * Mode that determines the coordinate system to use.
  59509. */
  59510. export enum GLTFLoaderCoordinateSystemMode {
  59511. /**
  59512. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  59513. */
  59514. AUTO = 0,
  59515. /**
  59516. * Sets the useRightHandedSystem flag on the scene.
  59517. */
  59518. FORCE_RIGHT_HANDED = 1
  59519. }
  59520. /**
  59521. * Mode that determines what animations will start.
  59522. */
  59523. export enum GLTFLoaderAnimationStartMode {
  59524. /**
  59525. * No animation will start.
  59526. */
  59527. NONE = 0,
  59528. /**
  59529. * The first animation will start.
  59530. */
  59531. FIRST = 1,
  59532. /**
  59533. * All animations will start.
  59534. */
  59535. ALL = 2
  59536. }
  59537. /**
  59538. * Interface that contains the data for the glTF asset.
  59539. */
  59540. export interface IGLTFLoaderData {
  59541. /**
  59542. * Object that represents the glTF JSON.
  59543. */
  59544. json: Object;
  59545. /**
  59546. * The BIN chunk of a binary glTF.
  59547. */
  59548. bin: Nullable<ArrayBufferView>;
  59549. }
  59550. /**
  59551. * Interface for extending the loader.
  59552. */
  59553. export interface IGLTFLoaderExtension {
  59554. /**
  59555. * The name of this extension.
  59556. */
  59557. readonly name: string;
  59558. /**
  59559. * Defines whether this extension is enabled.
  59560. */
  59561. enabled: boolean;
  59562. }
  59563. /**
  59564. * Loader state.
  59565. */
  59566. export enum GLTFLoaderState {
  59567. /**
  59568. * The asset is loading.
  59569. */
  59570. LOADING = 0,
  59571. /**
  59572. * The asset is ready for rendering.
  59573. */
  59574. READY = 1,
  59575. /**
  59576. * The asset is completely loaded.
  59577. */
  59578. COMPLETE = 2
  59579. }
  59580. /** @hidden */
  59581. export interface IGLTFLoader extends IDisposable {
  59582. readonly state: Nullable<GLTFLoaderState>;
  59583. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  59584. meshes: AbstractMesh[];
  59585. particleSystems: IParticleSystem[];
  59586. skeletons: Skeleton[];
  59587. animationGroups: AnimationGroup[];
  59588. }>;
  59589. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  59590. }
  59591. /**
  59592. * File loader for loading glTF files into a scene.
  59593. */
  59594. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  59595. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59596. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59597. /**
  59598. * Raised when the asset has been parsed
  59599. */
  59600. onParsedObservable: Observable<IGLTFLoaderData>;
  59601. private _onParsedObserver;
  59602. /**
  59603. * Raised when the asset has been parsed
  59604. */
  59605. onParsed: (loaderData: IGLTFLoaderData) => void;
  59606. /**
  59607. * 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.
  59608. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  59609. * Defaults to true.
  59610. * @hidden
  59611. */
  59612. static IncrementalLoading: boolean;
  59613. /**
  59614. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  59615. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  59616. * @hidden
  59617. */
  59618. static HomogeneousCoordinates: boolean;
  59619. /**
  59620. * The coordinate system mode. Defaults to AUTO.
  59621. */
  59622. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  59623. /**
  59624. * The animation start mode. Defaults to FIRST.
  59625. */
  59626. animationStartMode: GLTFLoaderAnimationStartMode;
  59627. /**
  59628. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  59629. */
  59630. compileMaterials: boolean;
  59631. /**
  59632. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  59633. */
  59634. useClipPlane: boolean;
  59635. /**
  59636. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  59637. */
  59638. compileShadowGenerators: boolean;
  59639. /**
  59640. * Defines if the Alpha blended materials are only applied as coverage.
  59641. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  59642. * If true, no extra effects are applied to transparent pixels.
  59643. */
  59644. transparencyAsCoverage: boolean;
  59645. /**
  59646. * Function called before loading a url referenced by the asset.
  59647. */
  59648. preprocessUrlAsync: (url: string) => Promise<string>;
  59649. /**
  59650. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59651. */
  59652. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  59653. private _onMeshLoadedObserver;
  59654. /**
  59655. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59656. */
  59657. onMeshLoaded: (mesh: AbstractMesh) => void;
  59658. /**
  59659. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  59660. */
  59661. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  59662. private _onTextureLoadedObserver;
  59663. /**
  59664. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  59665. */
  59666. onTextureLoaded: (texture: BaseTexture) => void;
  59667. /**
  59668. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  59669. */
  59670. readonly onMaterialLoadedObservable: Observable<Material>;
  59671. private _onMaterialLoadedObserver;
  59672. /**
  59673. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  59674. */
  59675. onMaterialLoaded: (material: Material) => void;
  59676. /**
  59677. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  59678. */
  59679. readonly onCameraLoadedObservable: Observable<Camera>;
  59680. private _onCameraLoadedObserver;
  59681. /**
  59682. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  59683. */
  59684. onCameraLoaded: (camera: Camera) => void;
  59685. /**
  59686. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  59687. * For assets with LODs, raised when all of the LODs are complete.
  59688. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59689. */
  59690. readonly onCompleteObservable: Observable<void>;
  59691. private _onCompleteObserver;
  59692. /**
  59693. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  59694. * For assets with LODs, raised when all of the LODs are complete.
  59695. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59696. */
  59697. onComplete: () => void;
  59698. /**
  59699. * Observable raised when an error occurs.
  59700. */
  59701. readonly onErrorObservable: Observable<any>;
  59702. private _onErrorObserver;
  59703. /**
  59704. * Callback raised when an error occurs.
  59705. */
  59706. onError: (reason: any) => void;
  59707. /**
  59708. * Observable raised after the loader is disposed.
  59709. */
  59710. readonly onDisposeObservable: Observable<void>;
  59711. private _onDisposeObserver;
  59712. /**
  59713. * Callback raised after the loader is disposed.
  59714. */
  59715. onDispose: () => void;
  59716. /**
  59717. * Observable raised after a loader extension is created.
  59718. * Set additional options for a loader extension in this event.
  59719. */
  59720. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  59721. private _onExtensionLoadedObserver;
  59722. /**
  59723. * Callback raised after a loader extension is created.
  59724. */
  59725. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  59726. /**
  59727. * Defines if the loader logging is enabled.
  59728. */
  59729. loggingEnabled: boolean;
  59730. /**
  59731. * Defines if the loader should capture performance counters.
  59732. */
  59733. capturePerformanceCounters: boolean;
  59734. /**
  59735. * Defines if the loader should validate the asset.
  59736. */
  59737. validate: boolean;
  59738. /**
  59739. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  59740. */
  59741. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  59742. private _onValidatedObserver;
  59743. /**
  59744. * Callback raised after a loader extension is created.
  59745. */
  59746. onValidated: (results: IGLTFValidationResults) => void;
  59747. private _loader;
  59748. /**
  59749. * Name of the loader ("gltf")
  59750. */
  59751. name: string;
  59752. /**
  59753. * Supported file extensions of the loader (.gltf, .glb)
  59754. */
  59755. extensions: ISceneLoaderPluginExtensions;
  59756. /**
  59757. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  59758. */
  59759. dispose(): void;
  59760. /** @hidden */ clear(): void;
  59761. /**
  59762. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  59763. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  59764. * @param scene the scene the meshes should be added to
  59765. * @param data the glTF data to load
  59766. * @param rootUrl root url to load from
  59767. * @param onProgress event that fires when loading progress has occured
  59768. * @param fileName Defines the name of the file to load
  59769. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  59770. */
  59771. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  59772. meshes: AbstractMesh[];
  59773. particleSystems: IParticleSystem[];
  59774. skeletons: Skeleton[];
  59775. animationGroups: AnimationGroup[];
  59776. }>;
  59777. /**
  59778. * Imports all objects from the loaded glTF data and adds them to the scene
  59779. * @param scene the scene the objects should be added to
  59780. * @param data the glTF data to load
  59781. * @param rootUrl root url to load from
  59782. * @param onProgress event that fires when loading progress has occured
  59783. * @param fileName Defines the name of the file to load
  59784. * @returns a promise which completes when objects have been loaded to the scene
  59785. */
  59786. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  59787. /**
  59788. * Load into an asset container.
  59789. * @param scene The scene to load into
  59790. * @param data The data to import
  59791. * @param rootUrl The root url for scene and resources
  59792. * @param onProgress The callback when the load progresses
  59793. * @param fileName Defines the name of the file to load
  59794. * @returns The loaded asset container
  59795. */
  59796. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  59797. /**
  59798. * If the data string can be loaded directly.
  59799. * @param data string contianing the file data
  59800. * @returns if the data can be loaded directly
  59801. */
  59802. canDirectLoad(data: string): boolean;
  59803. /**
  59804. * Rewrites a url by combining a root url and response url.
  59805. */
  59806. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  59807. /**
  59808. * Instantiates a glTF file loader plugin.
  59809. * @returns the created plugin
  59810. */
  59811. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  59812. /**
  59813. * The loader state or null if the loader is not active.
  59814. */
  59815. readonly loaderState: Nullable<GLTFLoaderState>;
  59816. /**
  59817. * Returns a promise that resolves when the asset is completely loaded.
  59818. * @returns a promise that resolves when the asset is completely loaded.
  59819. */
  59820. whenCompleteAsync(): Promise<void>;
  59821. private _parseAsync;
  59822. private _validateAsync;
  59823. private _getLoader;
  59824. private _unpackBinary;
  59825. private _unpackBinaryV1;
  59826. private _unpackBinaryV2;
  59827. private static _parseVersion;
  59828. private static _compareVersion;
  59829. private static _decodeBufferToText;
  59830. private static readonly _logSpaces;
  59831. private _logIndentLevel;
  59832. private _loggingEnabled;
  59833. /** @hidden */ log: (message: string) => void;
  59834. /** @hidden */ logOpen(message: string): void;
  59835. /** @hidden */ logClose(): void;
  59836. private _logEnabled;
  59837. private _logDisabled;
  59838. private _capturePerformanceCounters;
  59839. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  59840. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  59841. private _startPerformanceCounterEnabled;
  59842. private _startPerformanceCounterDisabled;
  59843. private _endPerformanceCounterEnabled;
  59844. private _endPerformanceCounterDisabled;
  59845. }
  59846. }
  59847. declare module BABYLON.GLTF1 {
  59848. /**
  59849. * Enums
  59850. * @hidden
  59851. */
  59852. export enum EComponentType {
  59853. BYTE = 5120,
  59854. UNSIGNED_BYTE = 5121,
  59855. SHORT = 5122,
  59856. UNSIGNED_SHORT = 5123,
  59857. FLOAT = 5126
  59858. }
  59859. /** @hidden */
  59860. export enum EShaderType {
  59861. FRAGMENT = 35632,
  59862. VERTEX = 35633
  59863. }
  59864. /** @hidden */
  59865. export enum EParameterType {
  59866. BYTE = 5120,
  59867. UNSIGNED_BYTE = 5121,
  59868. SHORT = 5122,
  59869. UNSIGNED_SHORT = 5123,
  59870. INT = 5124,
  59871. UNSIGNED_INT = 5125,
  59872. FLOAT = 5126,
  59873. FLOAT_VEC2 = 35664,
  59874. FLOAT_VEC3 = 35665,
  59875. FLOAT_VEC4 = 35666,
  59876. INT_VEC2 = 35667,
  59877. INT_VEC3 = 35668,
  59878. INT_VEC4 = 35669,
  59879. BOOL = 35670,
  59880. BOOL_VEC2 = 35671,
  59881. BOOL_VEC3 = 35672,
  59882. BOOL_VEC4 = 35673,
  59883. FLOAT_MAT2 = 35674,
  59884. FLOAT_MAT3 = 35675,
  59885. FLOAT_MAT4 = 35676,
  59886. SAMPLER_2D = 35678
  59887. }
  59888. /** @hidden */
  59889. export enum ETextureWrapMode {
  59890. CLAMP_TO_EDGE = 33071,
  59891. MIRRORED_REPEAT = 33648,
  59892. REPEAT = 10497
  59893. }
  59894. /** @hidden */
  59895. export enum ETextureFilterType {
  59896. NEAREST = 9728,
  59897. LINEAR = 9728,
  59898. NEAREST_MIPMAP_NEAREST = 9984,
  59899. LINEAR_MIPMAP_NEAREST = 9985,
  59900. NEAREST_MIPMAP_LINEAR = 9986,
  59901. LINEAR_MIPMAP_LINEAR = 9987
  59902. }
  59903. /** @hidden */
  59904. export enum ETextureFormat {
  59905. ALPHA = 6406,
  59906. RGB = 6407,
  59907. RGBA = 6408,
  59908. LUMINANCE = 6409,
  59909. LUMINANCE_ALPHA = 6410
  59910. }
  59911. /** @hidden */
  59912. export enum ECullingType {
  59913. FRONT = 1028,
  59914. BACK = 1029,
  59915. FRONT_AND_BACK = 1032
  59916. }
  59917. /** @hidden */
  59918. export enum EBlendingFunction {
  59919. ZERO = 0,
  59920. ONE = 1,
  59921. SRC_COLOR = 768,
  59922. ONE_MINUS_SRC_COLOR = 769,
  59923. DST_COLOR = 774,
  59924. ONE_MINUS_DST_COLOR = 775,
  59925. SRC_ALPHA = 770,
  59926. ONE_MINUS_SRC_ALPHA = 771,
  59927. DST_ALPHA = 772,
  59928. ONE_MINUS_DST_ALPHA = 773,
  59929. CONSTANT_COLOR = 32769,
  59930. ONE_MINUS_CONSTANT_COLOR = 32770,
  59931. CONSTANT_ALPHA = 32771,
  59932. ONE_MINUS_CONSTANT_ALPHA = 32772,
  59933. SRC_ALPHA_SATURATE = 776
  59934. }
  59935. /** @hidden */
  59936. export interface IGLTFProperty {
  59937. extensions?: {
  59938. [key: string]: any;
  59939. };
  59940. extras?: Object;
  59941. }
  59942. /** @hidden */
  59943. export interface IGLTFChildRootProperty extends IGLTFProperty {
  59944. name?: string;
  59945. }
  59946. /** @hidden */
  59947. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  59948. bufferView: string;
  59949. byteOffset: number;
  59950. byteStride: number;
  59951. count: number;
  59952. type: string;
  59953. componentType: EComponentType;
  59954. max?: number[];
  59955. min?: number[];
  59956. name?: string;
  59957. }
  59958. /** @hidden */
  59959. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  59960. buffer: string;
  59961. byteOffset: number;
  59962. byteLength: number;
  59963. byteStride: number;
  59964. target?: number;
  59965. }
  59966. /** @hidden */
  59967. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  59968. uri: string;
  59969. byteLength?: number;
  59970. type?: string;
  59971. }
  59972. /** @hidden */
  59973. export interface IGLTFShader extends IGLTFChildRootProperty {
  59974. uri: string;
  59975. type: EShaderType;
  59976. }
  59977. /** @hidden */
  59978. export interface IGLTFProgram extends IGLTFChildRootProperty {
  59979. attributes: string[];
  59980. fragmentShader: string;
  59981. vertexShader: string;
  59982. }
  59983. /** @hidden */
  59984. export interface IGLTFTechniqueParameter {
  59985. type: number;
  59986. count?: number;
  59987. semantic?: string;
  59988. node?: string;
  59989. value?: number | boolean | string | Array<any>;
  59990. source?: string;
  59991. babylonValue?: any;
  59992. }
  59993. /** @hidden */
  59994. export interface IGLTFTechniqueCommonProfile {
  59995. lightingModel: string;
  59996. texcoordBindings: Object;
  59997. parameters?: Array<any>;
  59998. }
  59999. /** @hidden */
  60000. export interface IGLTFTechniqueStatesFunctions {
  60001. blendColor?: number[];
  60002. blendEquationSeparate?: number[];
  60003. blendFuncSeparate?: number[];
  60004. colorMask: boolean[];
  60005. cullFace: number[];
  60006. }
  60007. /** @hidden */
  60008. export interface IGLTFTechniqueStates {
  60009. enable: number[];
  60010. functions: IGLTFTechniqueStatesFunctions;
  60011. }
  60012. /** @hidden */
  60013. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  60014. parameters: {
  60015. [key: string]: IGLTFTechniqueParameter;
  60016. };
  60017. program: string;
  60018. attributes: {
  60019. [key: string]: string;
  60020. };
  60021. uniforms: {
  60022. [key: string]: string;
  60023. };
  60024. states: IGLTFTechniqueStates;
  60025. }
  60026. /** @hidden */
  60027. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  60028. technique?: string;
  60029. values: string[];
  60030. }
  60031. /** @hidden */
  60032. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  60033. attributes: {
  60034. [key: string]: string;
  60035. };
  60036. indices: string;
  60037. material: string;
  60038. mode?: number;
  60039. }
  60040. /** @hidden */
  60041. export interface IGLTFMesh extends IGLTFChildRootProperty {
  60042. primitives: IGLTFMeshPrimitive[];
  60043. }
  60044. /** @hidden */
  60045. export interface IGLTFImage extends IGLTFChildRootProperty {
  60046. uri: string;
  60047. }
  60048. /** @hidden */
  60049. export interface IGLTFSampler extends IGLTFChildRootProperty {
  60050. magFilter?: number;
  60051. minFilter?: number;
  60052. wrapS?: number;
  60053. wrapT?: number;
  60054. }
  60055. /** @hidden */
  60056. export interface IGLTFTexture extends IGLTFChildRootProperty {
  60057. sampler: string;
  60058. source: string;
  60059. format?: ETextureFormat;
  60060. internalFormat?: ETextureFormat;
  60061. target?: number;
  60062. type?: number;
  60063. babylonTexture?: Texture;
  60064. }
  60065. /** @hidden */
  60066. export interface IGLTFAmbienLight {
  60067. color?: number[];
  60068. }
  60069. /** @hidden */
  60070. export interface IGLTFDirectionalLight {
  60071. color?: number[];
  60072. }
  60073. /** @hidden */
  60074. export interface IGLTFPointLight {
  60075. color?: number[];
  60076. constantAttenuation?: number;
  60077. linearAttenuation?: number;
  60078. quadraticAttenuation?: number;
  60079. }
  60080. /** @hidden */
  60081. export interface IGLTFSpotLight {
  60082. color?: number[];
  60083. constantAttenuation?: number;
  60084. fallOfAngle?: number;
  60085. fallOffExponent?: number;
  60086. linearAttenuation?: number;
  60087. quadraticAttenuation?: number;
  60088. }
  60089. /** @hidden */
  60090. export interface IGLTFLight extends IGLTFChildRootProperty {
  60091. type: string;
  60092. }
  60093. /** @hidden */
  60094. export interface IGLTFCameraOrthographic {
  60095. xmag: number;
  60096. ymag: number;
  60097. zfar: number;
  60098. znear: number;
  60099. }
  60100. /** @hidden */
  60101. export interface IGLTFCameraPerspective {
  60102. aspectRatio: number;
  60103. yfov: number;
  60104. zfar: number;
  60105. znear: number;
  60106. }
  60107. /** @hidden */
  60108. export interface IGLTFCamera extends IGLTFChildRootProperty {
  60109. type: string;
  60110. }
  60111. /** @hidden */
  60112. export interface IGLTFAnimationChannelTarget {
  60113. id: string;
  60114. path: string;
  60115. }
  60116. /** @hidden */
  60117. export interface IGLTFAnimationChannel {
  60118. sampler: string;
  60119. target: IGLTFAnimationChannelTarget;
  60120. }
  60121. /** @hidden */
  60122. export interface IGLTFAnimationSampler {
  60123. input: string;
  60124. output: string;
  60125. interpolation?: string;
  60126. }
  60127. /** @hidden */
  60128. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  60129. channels?: IGLTFAnimationChannel[];
  60130. parameters?: {
  60131. [key: string]: string;
  60132. };
  60133. samplers?: {
  60134. [key: string]: IGLTFAnimationSampler;
  60135. };
  60136. }
  60137. /** @hidden */
  60138. export interface IGLTFNodeInstanceSkin {
  60139. skeletons: string[];
  60140. skin: string;
  60141. meshes: string[];
  60142. }
  60143. /** @hidden */
  60144. export interface IGLTFSkins extends IGLTFChildRootProperty {
  60145. bindShapeMatrix: number[];
  60146. inverseBindMatrices: string;
  60147. jointNames: string[];
  60148. babylonSkeleton?: Skeleton;
  60149. }
  60150. /** @hidden */
  60151. export interface IGLTFNode extends IGLTFChildRootProperty {
  60152. camera?: string;
  60153. children: string[];
  60154. skin?: string;
  60155. jointName?: string;
  60156. light?: string;
  60157. matrix: number[];
  60158. mesh?: string;
  60159. meshes?: string[];
  60160. rotation?: number[];
  60161. scale?: number[];
  60162. translation?: number[];
  60163. babylonNode?: Node;
  60164. }
  60165. /** @hidden */
  60166. export interface IGLTFScene extends IGLTFChildRootProperty {
  60167. nodes: string[];
  60168. }
  60169. /** @hidden */
  60170. export interface IGLTFRuntime {
  60171. extensions: {
  60172. [key: string]: any;
  60173. };
  60174. accessors: {
  60175. [key: string]: IGLTFAccessor;
  60176. };
  60177. buffers: {
  60178. [key: string]: IGLTFBuffer;
  60179. };
  60180. bufferViews: {
  60181. [key: string]: IGLTFBufferView;
  60182. };
  60183. meshes: {
  60184. [key: string]: IGLTFMesh;
  60185. };
  60186. lights: {
  60187. [key: string]: IGLTFLight;
  60188. };
  60189. cameras: {
  60190. [key: string]: IGLTFCamera;
  60191. };
  60192. nodes: {
  60193. [key: string]: IGLTFNode;
  60194. };
  60195. images: {
  60196. [key: string]: IGLTFImage;
  60197. };
  60198. textures: {
  60199. [key: string]: IGLTFTexture;
  60200. };
  60201. shaders: {
  60202. [key: string]: IGLTFShader;
  60203. };
  60204. programs: {
  60205. [key: string]: IGLTFProgram;
  60206. };
  60207. samplers: {
  60208. [key: string]: IGLTFSampler;
  60209. };
  60210. techniques: {
  60211. [key: string]: IGLTFTechnique;
  60212. };
  60213. materials: {
  60214. [key: string]: IGLTFMaterial;
  60215. };
  60216. animations: {
  60217. [key: string]: IGLTFAnimation;
  60218. };
  60219. skins: {
  60220. [key: string]: IGLTFSkins;
  60221. };
  60222. currentScene?: Object;
  60223. scenes: {
  60224. [key: string]: IGLTFScene;
  60225. };
  60226. extensionsUsed: string[];
  60227. extensionsRequired?: string[];
  60228. buffersCount: number;
  60229. shaderscount: number;
  60230. scene: Scene;
  60231. rootUrl: string;
  60232. loadedBufferCount: number;
  60233. loadedBufferViews: {
  60234. [name: string]: ArrayBufferView;
  60235. };
  60236. loadedShaderCount: number;
  60237. importOnlyMeshes: boolean;
  60238. importMeshesNames?: string[];
  60239. dummyNodes: Node[];
  60240. }
  60241. /** @hidden */
  60242. export interface INodeToRoot {
  60243. bone: Bone;
  60244. node: IGLTFNode;
  60245. id: string;
  60246. }
  60247. /** @hidden */
  60248. export interface IJointNode {
  60249. node: IGLTFNode;
  60250. id: string;
  60251. }
  60252. }
  60253. declare module BABYLON.GLTF1 {
  60254. /**
  60255. * Utils functions for GLTF
  60256. * @hidden
  60257. */
  60258. export class GLTFUtils {
  60259. /**
  60260. * Sets the given "parameter" matrix
  60261. * @param scene: the Scene object
  60262. * @param source: the source node where to pick the matrix
  60263. * @param parameter: the GLTF technique parameter
  60264. * @param uniformName: the name of the shader's uniform
  60265. * @param shaderMaterial: the shader material
  60266. */
  60267. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  60268. /**
  60269. * Sets the given "parameter" matrix
  60270. * @param shaderMaterial: the shader material
  60271. * @param uniform: the name of the shader's uniform
  60272. * @param value: the value of the uniform
  60273. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  60274. */
  60275. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  60276. /**
  60277. * Returns the wrap mode of the texture
  60278. * @param mode: the mode value
  60279. */
  60280. static GetWrapMode(mode: number): number;
  60281. /**
  60282. * Returns the byte stride giving an accessor
  60283. * @param accessor: the GLTF accessor objet
  60284. */
  60285. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  60286. /**
  60287. * Returns the texture filter mode giving a mode value
  60288. * @param mode: the filter mode value
  60289. */
  60290. static GetTextureFilterMode(mode: number): ETextureFilterType;
  60291. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  60292. /**
  60293. * Returns a buffer from its accessor
  60294. * @param gltfRuntime: the GLTF runtime
  60295. * @param accessor: the GLTF accessor
  60296. */
  60297. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  60298. /**
  60299. * Decodes a buffer view into a string
  60300. * @param view: the buffer view
  60301. */
  60302. static DecodeBufferToText(view: ArrayBufferView): string;
  60303. /**
  60304. * Returns the default material of gltf. Related to
  60305. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  60306. * @param scene: the Babylon.js scene
  60307. */
  60308. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  60309. private static _DefaultMaterial;
  60310. }
  60311. }
  60312. declare module BABYLON.GLTF1 {
  60313. /**
  60314. * Implementation of the base glTF spec
  60315. * @hidden
  60316. */
  60317. export class GLTFLoaderBase {
  60318. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  60319. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60320. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  60321. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60322. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  60323. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60324. }
  60325. /**
  60326. * glTF V1 Loader
  60327. * @hidden
  60328. */
  60329. export class GLTFLoader implements IGLTFLoader {
  60330. static Extensions: {
  60331. [name: string]: GLTFLoaderExtension;
  60332. };
  60333. static RegisterExtension(extension: GLTFLoaderExtension): void;
  60334. state: Nullable<GLTFLoaderState>;
  60335. dispose(): void;
  60336. private _importMeshAsync;
  60337. /**
  60338. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  60339. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  60340. * @param scene the scene the meshes should be added to
  60341. * @param data gltf data containing information of the meshes in a loaded file
  60342. * @param rootUrl root url to load from
  60343. * @param onProgress event that fires when loading progress has occured
  60344. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  60345. */
  60346. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  60347. meshes: AbstractMesh[];
  60348. particleSystems: IParticleSystem[];
  60349. skeletons: Skeleton[];
  60350. animationGroups: AnimationGroup[];
  60351. }>;
  60352. private _loadAsync;
  60353. /**
  60354. * Imports all objects from a loaded gltf file and adds them to the scene
  60355. * @param scene the scene the objects should be added to
  60356. * @param data gltf data containing information of the meshes in a loaded file
  60357. * @param rootUrl root url to load from
  60358. * @param onProgress event that fires when loading progress has occured
  60359. * @returns a promise which completes when objects have been loaded to the scene
  60360. */
  60361. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  60362. private _loadShadersAsync;
  60363. private _loadBuffersAsync;
  60364. private _createNodes;
  60365. }
  60366. /** @hidden */
  60367. export abstract class GLTFLoaderExtension {
  60368. private _name;
  60369. constructor(name: string);
  60370. readonly name: string;
  60371. /**
  60372. * Defines an override for loading the runtime
  60373. * Return true to stop further extensions from loading the runtime
  60374. */
  60375. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  60376. /**
  60377. * Defines an onverride for creating gltf runtime
  60378. * Return true to stop further extensions from creating the runtime
  60379. */
  60380. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  60381. /**
  60382. * Defines an override for loading buffers
  60383. * Return true to stop further extensions from loading this buffer
  60384. */
  60385. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  60386. /**
  60387. * Defines an override for loading texture buffers
  60388. * Return true to stop further extensions from loading this texture data
  60389. */
  60390. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60391. /**
  60392. * Defines an override for creating textures
  60393. * Return true to stop further extensions from loading this texture
  60394. */
  60395. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  60396. /**
  60397. * Defines an override for loading shader strings
  60398. * Return true to stop further extensions from loading this shader data
  60399. */
  60400. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60401. /**
  60402. * Defines an override for loading materials
  60403. * Return true to stop further extensions from loading this material
  60404. */
  60405. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60406. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  60407. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  60408. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60409. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60410. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  60411. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60412. private static LoadTextureBufferAsync;
  60413. private static CreateTextureAsync;
  60414. private static ApplyExtensions;
  60415. }
  60416. }
  60417. declare module BABYLON.GLTF1 {
  60418. /** @hidden */
  60419. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  60420. private _bin;
  60421. constructor();
  60422. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  60423. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60424. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60425. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60426. }
  60427. }
  60428. declare module BABYLON.GLTF1 {
  60429. /** @hidden */
  60430. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  60431. constructor();
  60432. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  60433. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60434. private _loadTexture;
  60435. }
  60436. }
  60437. declare module BABYLON.GLTF2.Loader {
  60438. /**
  60439. * Loader interface with an index field.
  60440. */
  60441. export interface IArrayItem {
  60442. /**
  60443. * The index of this item in the array.
  60444. */
  60445. index: number;
  60446. }
  60447. /**
  60448. * Loader interface with additional members.
  60449. */
  60450. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  60451. /** @hidden */ data?: Promise<ArrayBufferView>;
  60452. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  60453. }
  60454. /**
  60455. * Loader interface with additional members.
  60456. */
  60457. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  60458. }
  60459. /** @hidden */
  60460. export interface _IAnimationSamplerData {
  60461. input: Float32Array;
  60462. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  60463. output: Float32Array;
  60464. }
  60465. /**
  60466. * Loader interface with additional members.
  60467. */
  60468. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  60469. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  60470. }
  60471. /**
  60472. * Loader interface with additional members.
  60473. */
  60474. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  60475. channels: IAnimationChannel[];
  60476. samplers: IAnimationSampler[];
  60477. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  60478. }
  60479. /**
  60480. * Loader interface with additional members.
  60481. */
  60482. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  60483. /** @hidden */ data?: Promise<ArrayBufferView>;
  60484. }
  60485. /**
  60486. * Loader interface with additional members.
  60487. */
  60488. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  60489. /** @hidden */ data?: Promise<ArrayBufferView>;
  60490. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  60491. }
  60492. /**
  60493. * Loader interface with additional members.
  60494. */
  60495. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  60496. }
  60497. /**
  60498. * Loader interface with additional members.
  60499. */
  60500. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  60501. /** @hidden */ data?: Promise<ArrayBufferView>;
  60502. }
  60503. /**
  60504. * Loader interface with additional members.
  60505. */
  60506. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  60507. }
  60508. /**
  60509. * Loader interface with additional members.
  60510. */
  60511. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  60512. }
  60513. /**
  60514. * Loader interface with additional members.
  60515. */
  60516. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  60517. baseColorTexture?: ITextureInfo;
  60518. metallicRoughnessTexture?: ITextureInfo;
  60519. }
  60520. /**
  60521. * Loader interface with additional members.
  60522. */
  60523. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  60524. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  60525. normalTexture?: IMaterialNormalTextureInfo;
  60526. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60527. emissiveTexture?: ITextureInfo;
  60528. /** @hidden */ data?: {
  60529. [babylonDrawMode: number]: {
  60530. babylonMaterial: Material;
  60531. babylonMeshes: AbstractMesh[];
  60532. promise: Promise<void>;
  60533. };
  60534. };
  60535. }
  60536. /**
  60537. * Loader interface with additional members.
  60538. */
  60539. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  60540. primitives: IMeshPrimitive[];
  60541. }
  60542. /**
  60543. * Loader interface with additional members.
  60544. */
  60545. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  60546. /** @hidden */ instanceData?: {
  60547. babylonSourceMesh: Mesh;
  60548. promise: Promise<any>;
  60549. };
  60550. }
  60551. /**
  60552. * Loader interface with additional members.
  60553. */
  60554. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  60555. /**
  60556. * The parent glTF node.
  60557. */
  60558. parent?: INode;
  60559. /** @hidden */ babylonTransformNode?: TransformNode;
  60560. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  60561. /** @hidden */ babylonBones?: Bone[];
  60562. /** @hidden */ numMorphTargets?: number;
  60563. }
  60564. /** @hidden */
  60565. export interface _ISamplerData {
  60566. noMipMaps: boolean;
  60567. samplingMode: number;
  60568. wrapU: number;
  60569. wrapV: number;
  60570. }
  60571. /**
  60572. * Loader interface with additional members.
  60573. */
  60574. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  60575. /** @hidden */ data?: _ISamplerData;
  60576. }
  60577. /**
  60578. * Loader interface with additional members.
  60579. */
  60580. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  60581. }
  60582. /**
  60583. * Loader interface with additional members.
  60584. */
  60585. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  60586. /** @hidden */ data?: {
  60587. babylonSkeleton: Skeleton;
  60588. promise: Promise<void>;
  60589. };
  60590. }
  60591. /**
  60592. * Loader interface with additional members.
  60593. */
  60594. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  60595. }
  60596. /**
  60597. * Loader interface with additional members.
  60598. */
  60599. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  60600. }
  60601. /**
  60602. * Loader interface with additional members.
  60603. */
  60604. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  60605. accessors?: IAccessor[];
  60606. animations?: IAnimation[];
  60607. buffers?: IBuffer[];
  60608. bufferViews?: IBufferView[];
  60609. cameras?: ICamera[];
  60610. images?: IImage[];
  60611. materials?: IMaterial[];
  60612. meshes?: IMesh[];
  60613. nodes?: INode[];
  60614. samplers?: ISampler[];
  60615. scenes?: IScene[];
  60616. skins?: ISkin[];
  60617. textures?: ITexture[];
  60618. }
  60619. }
  60620. declare module BABYLON.GLTF2 {
  60621. /**
  60622. * Interface for a glTF loader extension.
  60623. */
  60624. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  60625. /**
  60626. * Called after the loader state changes to LOADING.
  60627. */
  60628. onLoading?(): void;
  60629. /**
  60630. * Called after the loader state changes to READY.
  60631. */
  60632. onReady?(): void;
  60633. /**
  60634. * Define this method to modify the default behavior when loading scenes.
  60635. * @param context The context when loading the asset
  60636. * @param scene The glTF scene property
  60637. * @returns A promise that resolves when the load is complete or null if not handled
  60638. */
  60639. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  60640. /**
  60641. * Define this method to modify the default behavior when loading nodes.
  60642. * @param context The context when loading the asset
  60643. * @param node The glTF node property
  60644. * @param assign A function called synchronously after parsing the glTF properties
  60645. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  60646. */
  60647. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60648. /**
  60649. * Define this method to modify the default behavior when loading cameras.
  60650. * @param context The context when loading the asset
  60651. * @param camera The glTF camera property
  60652. * @param assign A function called synchronously after parsing the glTF properties
  60653. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  60654. */
  60655. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  60656. /**
  60657. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  60658. * @param context The context when loading the asset
  60659. * @param primitive The glTF mesh primitive property
  60660. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  60661. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60662. /**
  60663. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  60664. * @param context The context when loading the asset
  60665. * @param name The mesh name when loading the asset
  60666. * @param node The glTF node when loading the asset
  60667. * @param mesh The glTF mesh when loading the asset
  60668. * @param primitive The glTF mesh primitive property
  60669. * @param assign A function called synchronously after parsing the glTF properties
  60670. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  60671. */ loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  60672. /**
  60673. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  60674. * @param context The context when loading the asset
  60675. * @param material The glTF material property
  60676. * @param assign A function called synchronously after parsing the glTF properties
  60677. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  60678. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  60679. /**
  60680. * Define this method to modify the default behavior when creating materials.
  60681. * @param context The context when loading the asset
  60682. * @param material The glTF material property
  60683. * @param babylonDrawMode The draw mode for the Babylon material
  60684. * @returns The Babylon material or null if not handled
  60685. */
  60686. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  60687. /**
  60688. * Define this method to modify the default behavior when loading material properties.
  60689. * @param context The context when loading the asset
  60690. * @param material The glTF material property
  60691. * @param babylonMaterial The Babylon material
  60692. * @returns A promise that resolves when the load is complete or null if not handled
  60693. */
  60694. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60695. /**
  60696. * Define this method to modify the default behavior when loading texture infos.
  60697. * @param context The context when loading the asset
  60698. * @param textureInfo The glTF texture info property
  60699. * @param assign A function called synchronously after parsing the glTF properties
  60700. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  60701. */
  60702. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60703. /**
  60704. * Define this method to modify the default behavior when loading animations.
  60705. * @param context The context when loading the asset
  60706. * @param animation The glTF animation property
  60707. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  60708. */
  60709. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60710. /**
  60711. * @hidden Define this method to modify the default behavior when loading skins.
  60712. * @param context The context when loading the asset
  60713. * @param node The glTF node property
  60714. * @param skin The glTF skin property
  60715. * @returns A promise that resolves when the load is complete or null if not handled
  60716. */ loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  60717. /**
  60718. * @hidden Define this method to modify the default behavior when loading uris.
  60719. * @param context The context when loading the asset
  60720. * @param property The glTF property associated with the uri
  60721. * @param uri The uri to load
  60722. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  60723. */ loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  60724. }
  60725. }
  60726. declare module BABYLON.GLTF2 {
  60727. /**
  60728. * Helper class for working with arrays when loading the glTF asset
  60729. */
  60730. export class ArrayItem {
  60731. /**
  60732. * Gets an item from the given array.
  60733. * @param context The context when loading the asset
  60734. * @param array The array to get the item from
  60735. * @param index The index to the array
  60736. * @returns The array item
  60737. */
  60738. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  60739. /**
  60740. * Assign an `index` field to each item of the given array.
  60741. * @param array The array of items
  60742. */
  60743. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  60744. }
  60745. /**
  60746. * The glTF 2.0 loader
  60747. */
  60748. export class GLTFLoader implements IGLTFLoader {
  60749. /** @hidden */ completePromises: Promise<any>[];
  60750. private _disposed;
  60751. private _parent;
  60752. private _state;
  60753. private _extensions;
  60754. private _rootUrl;
  60755. private _fileName;
  60756. private _uniqueRootUrl;
  60757. private _gltf;
  60758. private _babylonScene;
  60759. private _rootBabylonMesh;
  60760. private _defaultBabylonMaterialData;
  60761. private _progressCallback?;
  60762. private _requests;
  60763. private static readonly _DefaultSampler;
  60764. private static _ExtensionNames;
  60765. private static _ExtensionFactories;
  60766. /**
  60767. * Registers a loader extension.
  60768. * @param name The name of the loader extension.
  60769. * @param factory The factory function that creates the loader extension.
  60770. */
  60771. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  60772. /**
  60773. * Unregisters a loader extension.
  60774. * @param name The name of the loader extenion.
  60775. * @returns A boolean indicating whether the extension has been unregistered
  60776. */
  60777. static UnregisterExtension(name: string): boolean;
  60778. /**
  60779. * Gets the loader state.
  60780. */
  60781. readonly state: Nullable<GLTFLoaderState>;
  60782. /**
  60783. * The glTF object parsed from the JSON.
  60784. */
  60785. readonly gltf: IGLTF;
  60786. /**
  60787. * The Babylon scene when loading the asset.
  60788. */
  60789. readonly babylonScene: Scene;
  60790. /**
  60791. * The root Babylon mesh when loading the asset.
  60792. */
  60793. readonly rootBabylonMesh: Mesh;
  60794. /** @hidden */
  60795. constructor(parent: GLTFFileLoader);
  60796. /** @hidden */
  60797. dispose(): void;
  60798. /** @hidden */
  60799. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  60800. meshes: AbstractMesh[];
  60801. particleSystems: IParticleSystem[];
  60802. skeletons: Skeleton[];
  60803. animationGroups: AnimationGroup[];
  60804. }>;
  60805. /** @hidden */
  60806. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  60807. private _loadAsync;
  60808. private _loadData;
  60809. private _setupData;
  60810. private _loadExtensions;
  60811. private _checkExtensions;
  60812. private _setState;
  60813. private _createRootNode;
  60814. /**
  60815. * Loads a glTF scene.
  60816. * @param context The context when loading the asset
  60817. * @param scene The glTF scene property
  60818. * @returns A promise that resolves when the load is complete
  60819. */
  60820. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  60821. private _forEachPrimitive;
  60822. private _getMeshes;
  60823. private _getSkeletons;
  60824. private _getAnimationGroups;
  60825. private _startAnimations;
  60826. /**
  60827. * Loads a glTF node.
  60828. * @param context The context when loading the asset
  60829. * @param node The glTF node property
  60830. * @param assign A function called synchronously after parsing the glTF properties
  60831. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  60832. */
  60833. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  60834. private _loadMeshAsync;
  60835. /**
  60836. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  60837. * @param context The context when loading the asset
  60838. * @param name The mesh name when loading the asset
  60839. * @param node The glTF node when loading the asset
  60840. * @param mesh The glTF mesh when loading the asset
  60841. * @param primitive The glTF mesh primitive property
  60842. * @param assign A function called synchronously after parsing the glTF properties
  60843. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  60844. */ loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  60845. private _loadVertexDataAsync;
  60846. private _createMorphTargets;
  60847. private _loadMorphTargetsAsync;
  60848. private _loadMorphTargetVertexDataAsync;
  60849. private static _LoadTransform;
  60850. private _loadSkinAsync;
  60851. private _loadBones;
  60852. private _loadBone;
  60853. private _loadSkinInverseBindMatricesDataAsync;
  60854. private _updateBoneMatrices;
  60855. private _getNodeMatrix;
  60856. /**
  60857. * Loads a glTF camera.
  60858. * @param context The context when loading the asset
  60859. * @param camera The glTF camera property
  60860. * @param assign A function called synchronously after parsing the glTF properties
  60861. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  60862. */
  60863. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  60864. private _loadAnimationsAsync;
  60865. /**
  60866. * Loads a glTF animation.
  60867. * @param context The context when loading the asset
  60868. * @param animation The glTF animation property
  60869. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  60870. */
  60871. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  60872. /**
  60873. * @hidden Loads a glTF animation channel.
  60874. * @param context The context when loading the asset
  60875. * @param animationContext The context of the animation when loading the asset
  60876. * @param animation The glTF animation property
  60877. * @param channel The glTF animation channel property
  60878. * @param babylonAnimationGroup The babylon animation group property
  60879. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  60880. * @returns A void promise when the channel load is complete
  60881. */ loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  60882. private _loadAnimationSamplerAsync;
  60883. private _loadBufferAsync;
  60884. /**
  60885. * Loads a glTF buffer view.
  60886. * @param context The context when loading the asset
  60887. * @param bufferView The glTF buffer view property
  60888. * @returns A promise that resolves with the loaded data when the load is complete
  60889. */
  60890. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  60891. private _loadIndicesAccessorAsync;
  60892. private _loadFloatAccessorAsync;
  60893. private _loadVertexBufferViewAsync;
  60894. private _loadVertexAccessorAsync;
  60895. private _loadMaterialMetallicRoughnessPropertiesAsync;
  60896. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  60897. private _createDefaultMaterial;
  60898. /**
  60899. * Creates a Babylon material from a glTF material.
  60900. * @param context The context when loading the asset
  60901. * @param material The glTF material property
  60902. * @param babylonDrawMode The draw mode for the Babylon material
  60903. * @returns The Babylon material
  60904. */
  60905. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  60906. /**
  60907. * Loads properties from a glTF material into a Babylon material.
  60908. * @param context The context when loading the asset
  60909. * @param material The glTF material property
  60910. * @param babylonMaterial The Babylon material
  60911. * @returns A promise that resolves when the load is complete
  60912. */
  60913. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  60914. /**
  60915. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  60916. * @param context The context when loading the asset
  60917. * @param material The glTF material property
  60918. * @param babylonMaterial The Babylon material
  60919. * @returns A promise that resolves when the load is complete
  60920. */
  60921. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  60922. /**
  60923. * Loads the alpha properties from a glTF material into a Babylon material.
  60924. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  60925. * @param context The context when loading the asset
  60926. * @param material The glTF material property
  60927. * @param babylonMaterial The Babylon material
  60928. */
  60929. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  60930. /**
  60931. * Loads a glTF texture info.
  60932. * @param context The context when loading the asset
  60933. * @param textureInfo The glTF texture info property
  60934. * @param assign A function called synchronously after parsing the glTF properties
  60935. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  60936. */
  60937. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  60938. private _loadTextureAsync;
  60939. private _loadSampler;
  60940. /**
  60941. * Loads a glTF image.
  60942. * @param context The context when loading the asset
  60943. * @param image The glTF image property
  60944. * @returns A promise that resolves with the loaded data when the load is complete
  60945. */
  60946. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  60947. /**
  60948. * Loads a glTF uri.
  60949. * @param context The context when loading the asset
  60950. * @param property The glTF property associated with the uri
  60951. * @param uri The base64 or relative uri
  60952. * @returns A promise that resolves with the loaded data when the load is complete
  60953. */
  60954. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  60955. private _onProgress;
  60956. /**
  60957. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  60958. * @param babylonObject the Babylon object with metadata
  60959. * @param pointer the JSON pointer
  60960. */
  60961. static AddPointerMetadata(babylonObject: {
  60962. metadata: any;
  60963. }, pointer: string): void;
  60964. private static _GetTextureWrapMode;
  60965. private static _GetTextureSamplingMode;
  60966. private static _GetTypedArray;
  60967. private static _GetNumComponents;
  60968. private static _ValidateUri;
  60969. private static _GetDrawMode;
  60970. private _compileMaterialsAsync;
  60971. private _compileShadowGeneratorsAsync;
  60972. private _forEachExtensions;
  60973. private _applyExtensions;
  60974. private _extensionsOnLoading;
  60975. private _extensionsOnReady;
  60976. private _extensionsLoadSceneAsync;
  60977. private _extensionsLoadNodeAsync;
  60978. private _extensionsLoadCameraAsync;
  60979. private _extensionsLoadVertexDataAsync;
  60980. private _extensionsLoadMeshPrimitiveAsync;
  60981. private _extensionsLoadMaterialAsync;
  60982. private _extensionsCreateMaterial;
  60983. private _extensionsLoadMaterialPropertiesAsync;
  60984. private _extensionsLoadTextureInfoAsync;
  60985. private _extensionsLoadAnimationAsync;
  60986. private _extensionsLoadSkinAsync;
  60987. private _extensionsLoadUriAsync;
  60988. /**
  60989. * Helper method called by a loader extension to load an glTF extension.
  60990. * @param context The context when loading the asset
  60991. * @param property The glTF property to load the extension from
  60992. * @param extensionName The name of the extension to load
  60993. * @param actionAsync The action to run
  60994. * @returns The promise returned by actionAsync or null if the extension does not exist
  60995. */
  60996. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  60997. /**
  60998. * Helper method called by a loader extension to load a glTF extra.
  60999. * @param context The context when loading the asset
  61000. * @param property The glTF property to load the extra from
  61001. * @param extensionName The name of the extension to load
  61002. * @param actionAsync The action to run
  61003. * @returns The promise returned by actionAsync or null if the extra does not exist
  61004. */
  61005. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  61006. /**
  61007. * Increments the indentation level and logs a message.
  61008. * @param message The message to log
  61009. */
  61010. logOpen(message: string): void;
  61011. /**
  61012. * Decrements the indentation level.
  61013. */
  61014. logClose(): void;
  61015. /**
  61016. * Logs a message
  61017. * @param message The message to log
  61018. */
  61019. log(message: string): void;
  61020. /**
  61021. * Starts a performance counter.
  61022. * @param counterName The name of the performance counter
  61023. */
  61024. startPerformanceCounter(counterName: string): void;
  61025. /**
  61026. * Ends a performance counter.
  61027. * @param counterName The name of the performance counter
  61028. */
  61029. endPerformanceCounter(counterName: string): void;
  61030. }
  61031. }
  61032. declare module BABYLON.GLTF2.Loader.Extensions {
  61033. /**
  61034. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  61035. */
  61036. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  61037. /** The name of this extension. */
  61038. readonly name: string;
  61039. /** Defines whether this extension is enabled. */
  61040. enabled: boolean;
  61041. private _loader;
  61042. private _lights?;
  61043. /** @hidden */
  61044. constructor(loader: GLTFLoader);
  61045. /** @hidden */
  61046. dispose(): void;
  61047. /** @hidden */
  61048. onLoading(): void;
  61049. /** @hidden */
  61050. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61051. private _loadLightAsync;
  61052. }
  61053. }
  61054. declare module BABYLON.GLTF2.Loader.Extensions {
  61055. /**
  61056. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  61057. */
  61058. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  61059. /** The name of this extension. */
  61060. readonly name: string;
  61061. /** The draco compression used to decode vertex data. */
  61062. dracoCompression?: DracoCompression;
  61063. /** Defines whether this extension is enabled. */
  61064. enabled: boolean;
  61065. private _loader;
  61066. private _dracoCompressionOwned;
  61067. /** @hidden */
  61068. constructor(loader: GLTFLoader);
  61069. /** @hidden */
  61070. dispose(): void;
  61071. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  61072. }
  61073. }
  61074. declare module BABYLON.GLTF2.Loader.Extensions {
  61075. /**
  61076. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  61077. */
  61078. export class KHR_lights implements IGLTFLoaderExtension {
  61079. /** The name of this extension. */
  61080. readonly name: string;
  61081. /** Defines whether this extension is enabled. */
  61082. enabled: boolean;
  61083. private _loader;
  61084. private _lights?;
  61085. /** @hidden */
  61086. constructor(loader: GLTFLoader);
  61087. /** @hidden */
  61088. dispose(): void;
  61089. /** @hidden */
  61090. onLoading(): void;
  61091. /** @hidden */
  61092. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61093. }
  61094. }
  61095. declare module BABYLON.GLTF2.Loader.Extensions {
  61096. /**
  61097. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  61098. */
  61099. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  61100. /** The name of this extension. */
  61101. readonly name: string;
  61102. /** Defines whether this extension is enabled. */
  61103. enabled: boolean;
  61104. private _loader;
  61105. /** @hidden */
  61106. constructor(loader: GLTFLoader);
  61107. /** @hidden */
  61108. dispose(): void;
  61109. /** @hidden */
  61110. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61111. private _loadSpecularGlossinessPropertiesAsync;
  61112. }
  61113. }
  61114. declare module BABYLON.GLTF2.Loader.Extensions {
  61115. /**
  61116. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  61117. */
  61118. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  61119. /** The name of this extension. */
  61120. readonly name: string;
  61121. /** Defines whether this extension is enabled. */
  61122. enabled: boolean;
  61123. private _loader;
  61124. /** @hidden */
  61125. constructor(loader: GLTFLoader);
  61126. /** @hidden */
  61127. dispose(): void;
  61128. /** @hidden */
  61129. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61130. private _loadUnlitPropertiesAsync;
  61131. }
  61132. }
  61133. declare module BABYLON.GLTF2.Loader.Extensions {
  61134. /**
  61135. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  61136. */
  61137. export class KHR_texture_transform implements IGLTFLoaderExtension {
  61138. /** The name of this extension. */
  61139. readonly name: string;
  61140. /** Defines whether this extension is enabled. */
  61141. enabled: boolean;
  61142. private _loader;
  61143. /** @hidden */
  61144. constructor(loader: GLTFLoader);
  61145. /** @hidden */
  61146. dispose(): void;
  61147. /** @hidden */
  61148. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  61149. }
  61150. }
  61151. declare module BABYLON.GLTF2.Loader.Extensions {
  61152. /**
  61153. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  61154. */
  61155. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  61156. /** The name of this extension. */
  61157. readonly name: string;
  61158. /** Defines whether this extension is enabled. */
  61159. enabled: boolean;
  61160. private _loader;
  61161. private _clips;
  61162. private _emitters;
  61163. /** @hidden */
  61164. constructor(loader: GLTFLoader);
  61165. /** @hidden */
  61166. dispose(): void;
  61167. /** @hidden */
  61168. onLoading(): void;
  61169. /** @hidden */
  61170. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61171. /** @hidden */
  61172. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61173. /** @hidden */
  61174. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  61175. private _loadClipAsync;
  61176. private _loadEmitterAsync;
  61177. private _getEventAction;
  61178. private _loadAnimationEventAsync;
  61179. }
  61180. }
  61181. declare module BABYLON.GLTF2.Loader.Extensions {
  61182. /**
  61183. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  61184. */
  61185. export class MSFT_lod implements IGLTFLoaderExtension {
  61186. /** The name of this extension. */
  61187. readonly name: string;
  61188. /** Defines whether this extension is enabled. */
  61189. enabled: boolean;
  61190. /**
  61191. * Maximum number of LODs to load, starting from the lowest LOD.
  61192. */
  61193. maxLODsToLoad: number;
  61194. /**
  61195. * Observable raised when all node LODs of one level are loaded.
  61196. * The event data is the index of the loaded LOD starting from zero.
  61197. * Dispose the loader to cancel the loading of the next level of LODs.
  61198. */
  61199. onNodeLODsLoadedObservable: Observable<number>;
  61200. /**
  61201. * Observable raised when all material LODs of one level are loaded.
  61202. * The event data is the index of the loaded LOD starting from zero.
  61203. * Dispose the loader to cancel the loading of the next level of LODs.
  61204. */
  61205. onMaterialLODsLoadedObservable: Observable<number>;
  61206. private _loader;
  61207. private _nodeIndexLOD;
  61208. private _nodeSignalLODs;
  61209. private _nodePromiseLODs;
  61210. private _materialIndexLOD;
  61211. private _materialSignalLODs;
  61212. private _materialPromiseLODs;
  61213. /** @hidden */
  61214. constructor(loader: GLTFLoader);
  61215. /** @hidden */
  61216. dispose(): void;
  61217. /** @hidden */
  61218. onReady(): void;
  61219. /** @hidden */
  61220. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61221. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  61222. /** @hidden */ loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  61223. /**
  61224. * Gets an array of LOD properties from lowest to highest.
  61225. */
  61226. private _getLODs;
  61227. private _disposeUnusedMaterials;
  61228. }
  61229. }
  61230. declare module BABYLON.GLTF2.Loader.Extensions {
  61231. /** @hidden */
  61232. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  61233. readonly name: string;
  61234. enabled: boolean;
  61235. private _loader;
  61236. constructor(loader: GLTFLoader);
  61237. dispose(): void;
  61238. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61239. }
  61240. }
  61241. declare module BABYLON.GLTF2.Loader.Extensions {
  61242. /** @hidden */
  61243. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  61244. readonly name: string;
  61245. enabled: boolean;
  61246. private _loader;
  61247. constructor(loader: GLTFLoader);
  61248. dispose(): void;
  61249. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61250. }
  61251. }
  61252. declare module BABYLON {
  61253. /**
  61254. * Class reading and parsing the MTL file bundled with the obj file.
  61255. */
  61256. export class MTLFileLoader {
  61257. /**
  61258. * All material loaded from the mtl will be set here
  61259. */
  61260. materials: StandardMaterial[];
  61261. /**
  61262. * This function will read the mtl file and create each material described inside
  61263. * This function could be improve by adding :
  61264. * -some component missing (Ni, Tf...)
  61265. * -including the specific options available
  61266. *
  61267. * @param scene defines the scene the material will be created in
  61268. * @param data defines the mtl data to parse
  61269. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  61270. */
  61271. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  61272. /**
  61273. * Gets the texture for the material.
  61274. *
  61275. * If the material is imported from input file,
  61276. * We sanitize the url to ensure it takes the textre from aside the material.
  61277. *
  61278. * @param rootUrl The root url to load from
  61279. * @param value The value stored in the mtl
  61280. * @return The Texture
  61281. */
  61282. private static _getTexture;
  61283. }
  61284. /**
  61285. * Options for loading OBJ/MTL files
  61286. */
  61287. type MeshLoadOptions = {
  61288. /**
  61289. * Defines if UVs are optimized by default during load.
  61290. */
  61291. OptimizeWithUV: boolean;
  61292. /**
  61293. * Invert model on y-axis (does a model scaling inversion)
  61294. */
  61295. InvertY: boolean;
  61296. /**
  61297. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61298. */
  61299. ImportVertexColors: boolean;
  61300. /**
  61301. * Compute the normals for the model, even if normals are present in the file.
  61302. */
  61303. ComputeNormals: boolean;
  61304. /**
  61305. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61306. */
  61307. SkipMaterials: boolean;
  61308. /**
  61309. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61310. */
  61311. MaterialLoadingFailsSilently: boolean;
  61312. };
  61313. /**
  61314. * OBJ file type loader.
  61315. * This is a babylon scene loader plugin.
  61316. */
  61317. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  61318. /**
  61319. * Defines if UVs are optimized by default during load.
  61320. */
  61321. static OPTIMIZE_WITH_UV: boolean;
  61322. /**
  61323. * Invert model on y-axis (does a model scaling inversion)
  61324. */
  61325. static INVERT_Y: boolean;
  61326. /**
  61327. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61328. */
  61329. static IMPORT_VERTEX_COLORS: boolean;
  61330. /**
  61331. * Compute the normals for the model, even if normals are present in the file.
  61332. */
  61333. static COMPUTE_NORMALS: boolean;
  61334. /**
  61335. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61336. */
  61337. static SKIP_MATERIALS: boolean;
  61338. /**
  61339. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61340. *
  61341. * Defaults to true for backwards compatibility.
  61342. */
  61343. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  61344. /**
  61345. * Defines the name of the plugin.
  61346. */
  61347. name: string;
  61348. /**
  61349. * Defines the extension the plugin is able to load.
  61350. */
  61351. extensions: string;
  61352. /** @hidden */
  61353. obj: RegExp;
  61354. /** @hidden */
  61355. group: RegExp;
  61356. /** @hidden */
  61357. mtllib: RegExp;
  61358. /** @hidden */
  61359. usemtl: RegExp;
  61360. /** @hidden */
  61361. smooth: RegExp;
  61362. /** @hidden */
  61363. vertexPattern: RegExp;
  61364. /** @hidden */
  61365. normalPattern: RegExp;
  61366. /** @hidden */
  61367. uvPattern: RegExp;
  61368. /** @hidden */
  61369. facePattern1: RegExp;
  61370. /** @hidden */
  61371. facePattern2: RegExp;
  61372. /** @hidden */
  61373. facePattern3: RegExp;
  61374. /** @hidden */
  61375. facePattern4: RegExp;
  61376. /** @hidden */
  61377. facePattern5: RegExp;
  61378. private _meshLoadOptions;
  61379. /**
  61380. * Creates loader for .OBJ files
  61381. *
  61382. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  61383. */
  61384. constructor(meshLoadOptions?: MeshLoadOptions);
  61385. private static readonly currentMeshLoadOptions;
  61386. /**
  61387. * Calls synchronously the MTL file attached to this obj.
  61388. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  61389. * Without this function materials are not displayed in the first frame (but displayed after).
  61390. * In consequence it is impossible to get material information in your HTML file
  61391. *
  61392. * @param url The URL of the MTL file
  61393. * @param rootUrl
  61394. * @param onSuccess Callback function to be called when the MTL file is loaded
  61395. * @private
  61396. */
  61397. private _loadMTL;
  61398. /**
  61399. * Instantiates a OBJ file loader plugin.
  61400. * @returns the created plugin
  61401. */
  61402. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  61403. /**
  61404. * If the data string can be loaded directly.
  61405. *
  61406. * @param data string containing the file data
  61407. * @returns if the data can be loaded directly
  61408. */
  61409. canDirectLoad(data: string): boolean;
  61410. /**
  61411. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  61412. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  61413. * @param scene the scene the meshes should be added to
  61414. * @param data the OBJ data to load
  61415. * @param rootUrl root url to load from
  61416. * @param onProgress event that fires when loading progress has occured
  61417. * @param fileName Defines the name of the file to load
  61418. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  61419. */
  61420. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61421. meshes: AbstractMesh[];
  61422. particleSystems: IParticleSystem[];
  61423. skeletons: Skeleton[];
  61424. animationGroups: AnimationGroup[];
  61425. }>;
  61426. /**
  61427. * Imports all objects from the loaded OBJ data and adds them to the scene
  61428. * @param scene the scene the objects should be added to
  61429. * @param data the OBJ data to load
  61430. * @param rootUrl root url to load from
  61431. * @param onProgress event that fires when loading progress has occured
  61432. * @param fileName Defines the name of the file to load
  61433. * @returns a promise which completes when objects have been loaded to the scene
  61434. */
  61435. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61436. /**
  61437. * Load into an asset container.
  61438. * @param scene The scene to load into
  61439. * @param data The data to import
  61440. * @param rootUrl The root url for scene and resources
  61441. * @param onProgress The callback when the load progresses
  61442. * @param fileName Defines the name of the file to load
  61443. * @returns The loaded asset container
  61444. */
  61445. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  61446. /**
  61447. * Read the OBJ file and create an Array of meshes.
  61448. * Each mesh contains all information given by the OBJ and the MTL file.
  61449. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  61450. *
  61451. * @param meshesNames
  61452. * @param scene Scene The scene where are displayed the data
  61453. * @param data String The content of the obj file
  61454. * @param rootUrl String The path to the folder
  61455. * @returns Array<AbstractMesh>
  61456. * @private
  61457. */
  61458. private _parseSolid;
  61459. }
  61460. }
  61461. declare module BABYLON {
  61462. /**
  61463. * STL file type loader.
  61464. * This is a babylon scene loader plugin.
  61465. */
  61466. export class STLFileLoader implements ISceneLoaderPlugin {
  61467. /** @hidden */
  61468. solidPattern: RegExp;
  61469. /** @hidden */
  61470. facetsPattern: RegExp;
  61471. /** @hidden */
  61472. normalPattern: RegExp;
  61473. /** @hidden */
  61474. vertexPattern: RegExp;
  61475. /**
  61476. * Defines the name of the plugin.
  61477. */
  61478. name: string;
  61479. /**
  61480. * Defines the extensions the stl loader is able to load.
  61481. * force data to come in as an ArrayBuffer
  61482. * we'll convert to string if it looks like it's an ASCII .stl
  61483. */
  61484. extensions: ISceneLoaderPluginExtensions;
  61485. /**
  61486. * Import meshes into a scene.
  61487. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  61488. * @param scene The scene to import into
  61489. * @param data The data to import
  61490. * @param rootUrl The root url for scene and resources
  61491. * @param meshes The meshes array to import into
  61492. * @param particleSystems The particle systems array to import into
  61493. * @param skeletons The skeletons array to import into
  61494. * @param onError The callback when import fails
  61495. * @returns True if successful or false otherwise
  61496. */
  61497. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  61498. /**
  61499. * Load into a scene.
  61500. * @param scene The scene to load into
  61501. * @param data The data to import
  61502. * @param rootUrl The root url for scene and resources
  61503. * @param onError The callback when import fails
  61504. * @returns true if successful or false otherwise
  61505. */
  61506. load(scene: Scene, data: any, rootUrl: string): boolean;
  61507. /**
  61508. * Load into an asset container.
  61509. * @param scene The scene to load into
  61510. * @param data The data to import
  61511. * @param rootUrl The root url for scene and resources
  61512. * @param onError The callback when import fails
  61513. * @returns The loaded asset container
  61514. */
  61515. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  61516. private _isBinary;
  61517. private _parseBinary;
  61518. private _parseASCII;
  61519. }
  61520. }
  61521. declare module BABYLON {
  61522. /**
  61523. * Class for generating OBJ data from a Babylon scene.
  61524. */
  61525. export class OBJExport {
  61526. /**
  61527. * Exports the geometry of a Mesh array in .OBJ file format (text)
  61528. * @param mesh defines the list of meshes to serialize
  61529. * @param materials defines if materials should be exported
  61530. * @param matlibname defines the name of the associated mtl file
  61531. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  61532. * @returns the OBJ content
  61533. */
  61534. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  61535. /**
  61536. * Exports the material(s) of a mesh in .MTL file format (text)
  61537. * @param mesh defines the mesh to extract the material from
  61538. * @returns the mtl content
  61539. */
  61540. static MTL(mesh: Mesh): string;
  61541. }
  61542. }
  61543. declare module BABYLON {
  61544. /** @hidden */
  61545. export var __IGLTFExporterExtension: number;
  61546. /**
  61547. * Interface for extending the exporter
  61548. * @hidden
  61549. */
  61550. export interface IGLTFExporterExtension {
  61551. /**
  61552. * The name of this extension
  61553. */
  61554. readonly name: string;
  61555. /**
  61556. * Defines whether this extension is enabled
  61557. */
  61558. enabled: boolean;
  61559. /**
  61560. * Defines whether this extension is required
  61561. */
  61562. required: boolean;
  61563. }
  61564. }
  61565. declare module BABYLON.GLTF2.Exporter {
  61566. /** @hidden */
  61567. export var __IGLTFExporterExtensionV2: number;
  61568. /**
  61569. * Interface for a glTF exporter extension
  61570. * @hidden
  61571. */
  61572. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  61573. /**
  61574. * Define this method to modify the default behavior before exporting a texture
  61575. * @param context The context when loading the asset
  61576. * @param babylonTexture The glTF texture info property
  61577. * @param mimeType The mime-type of the generated image
  61578. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  61579. */
  61580. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  61581. /**
  61582. * Define this method to modify the default behavior when exporting texture info
  61583. * @param context The context when loading the asset
  61584. * @param meshPrimitive glTF mesh primitive
  61585. * @param babylonSubMesh Babylon submesh
  61586. * @param binaryWriter glTF serializer binary writer instance
  61587. * @returns nullable IMeshPrimitive promise
  61588. */
  61589. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  61590. /**
  61591. * Define this method to modify the default behavior when exporting a node
  61592. * @param context The context when exporting the node
  61593. * @param node glTF node
  61594. * @param babylonNode BabylonJS node
  61595. * @returns nullable INode promise
  61596. */
  61597. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  61598. /**
  61599. * Called after the exporter state changes to EXPORTING
  61600. */
  61601. onExporting?(): void;
  61602. }
  61603. }
  61604. declare module BABYLON.GLTF2.Exporter {
  61605. /**
  61606. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  61607. * @hidden
  61608. */
  61609. export class _GLTFMaterialExporter {
  61610. /**
  61611. * Represents the dielectric specular values for R, G and B
  61612. */
  61613. private static readonly _DielectricSpecular;
  61614. /**
  61615. * Allows the maximum specular power to be defined for material calculations
  61616. */
  61617. private static readonly _MaxSpecularPower;
  61618. /**
  61619. * Mapping to store textures
  61620. */
  61621. private _textureMap;
  61622. /**
  61623. * Numeric tolerance value
  61624. */
  61625. private static readonly _Epsilon;
  61626. /**
  61627. * Reference to the glTF Exporter
  61628. */
  61629. private _exporter;
  61630. constructor(exporter: _Exporter);
  61631. /**
  61632. * Specifies if two colors are approximately equal in value
  61633. * @param color1 first color to compare to
  61634. * @param color2 second color to compare to
  61635. * @param epsilon threshold value
  61636. */
  61637. private static FuzzyEquals;
  61638. /**
  61639. * Gets the materials from a Babylon scene and converts them to glTF materials
  61640. * @param scene babylonjs scene
  61641. * @param mimeType texture mime type
  61642. * @param images array of images
  61643. * @param textures array of textures
  61644. * @param materials array of materials
  61645. * @param imageData mapping of texture names to base64 textures
  61646. * @param hasTextureCoords specifies if texture coordinates are present on the material
  61647. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61648. /**
  61649. * Makes a copy of the glTF material without the texture parameters
  61650. * @param originalMaterial original glTF material
  61651. * @returns glTF material without texture parameters
  61652. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  61653. /**
  61654. * Specifies if the material has any texture parameters present
  61655. * @param material glTF Material
  61656. * @returns boolean specifying if texture parameters are present
  61657. */ hasTexturesPresent(material: IMaterial): boolean;
  61658. /**
  61659. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  61660. * @param babylonStandardMaterial
  61661. * @returns glTF Metallic Roughness Material representation
  61662. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  61663. /**
  61664. * Computes the metallic factor
  61665. * @param diffuse diffused value
  61666. * @param specular specular value
  61667. * @param oneMinusSpecularStrength one minus the specular strength
  61668. * @returns metallic value
  61669. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  61670. /**
  61671. * Gets the glTF alpha mode from the Babylon Material
  61672. * @param babylonMaterial Babylon Material
  61673. * @returns The Babylon alpha mode value
  61674. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  61675. /**
  61676. * Converts a Babylon Standard Material to a glTF Material
  61677. * @param babylonStandardMaterial BJS Standard Material
  61678. * @param mimeType mime type to use for the textures
  61679. * @param images array of glTF image interfaces
  61680. * @param textures array of glTF texture interfaces
  61681. * @param materials array of glTF material interfaces
  61682. * @param imageData map of image file name to data
  61683. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61684. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61685. /**
  61686. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61687. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  61688. * @param mimeType mime type to use for the textures
  61689. * @param images array of glTF image interfaces
  61690. * @param textures array of glTF texture interfaces
  61691. * @param materials array of glTF material interfaces
  61692. * @param imageData map of image file name to data
  61693. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61694. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61695. /**
  61696. * Converts an image typed array buffer to a base64 image
  61697. * @param buffer typed array buffer
  61698. * @param width width of the image
  61699. * @param height height of the image
  61700. * @param mimeType mimetype of the image
  61701. * @returns base64 image string
  61702. */
  61703. private _createBase64FromCanvasAsync;
  61704. /**
  61705. * Generates a white texture based on the specified width and height
  61706. * @param width width of the texture in pixels
  61707. * @param height height of the texture in pixels
  61708. * @param scene babylonjs scene
  61709. * @returns white texture
  61710. */
  61711. private _createWhiteTexture;
  61712. /**
  61713. * 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
  61714. * @param texture1 first texture to resize
  61715. * @param texture2 second texture to resize
  61716. * @param scene babylonjs scene
  61717. * @returns resized textures or null
  61718. */
  61719. private _resizeTexturesToSameDimensions;
  61720. /**
  61721. * Converts an array of pixels to a Float32Array
  61722. * Throws an error if the pixel format is not supported
  61723. * @param pixels - array buffer containing pixel values
  61724. * @returns Float32 of pixels
  61725. */
  61726. private _convertPixelArrayToFloat32;
  61727. /**
  61728. * Convert Specular Glossiness Textures to Metallic Roughness
  61729. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  61730. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  61731. * @param diffuseTexture texture used to store diffuse information
  61732. * @param specularGlossinessTexture texture used to store specular and glossiness information
  61733. * @param factors specular glossiness material factors
  61734. * @param mimeType the mime type to use for the texture
  61735. * @returns pbr metallic roughness interface or null
  61736. */
  61737. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  61738. /**
  61739. * Converts specular glossiness material properties to metallic roughness
  61740. * @param specularGlossiness interface with specular glossiness material properties
  61741. * @returns interface with metallic roughness material properties
  61742. */
  61743. private _convertSpecularGlossinessToMetallicRoughness;
  61744. /**
  61745. * Calculates the surface reflectance, independent of lighting conditions
  61746. * @param color Color source to calculate brightness from
  61747. * @returns number representing the perceived brightness, or zero if color is undefined
  61748. */
  61749. private _getPerceivedBrightness;
  61750. /**
  61751. * Returns the maximum color component value
  61752. * @param color
  61753. * @returns maximum color component value, or zero if color is null or undefined
  61754. */
  61755. private _getMaxComponent;
  61756. /**
  61757. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  61758. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61759. * @param mimeType mime type to use for the textures
  61760. * @param images array of glTF image interfaces
  61761. * @param textures array of glTF texture interfaces
  61762. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61763. * @param imageData map of image file name to data
  61764. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61765. * @returns glTF PBR Metallic Roughness factors
  61766. */
  61767. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  61768. private _getGLTFTextureSampler;
  61769. private _getGLTFTextureWrapMode;
  61770. private _getGLTFTextureWrapModesSampler;
  61771. /**
  61772. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  61773. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61774. * @param mimeType mime type to use for the textures
  61775. * @param images array of glTF image interfaces
  61776. * @param textures array of glTF texture interfaces
  61777. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61778. * @param imageData map of image file name to data
  61779. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61780. * @returns glTF PBR Metallic Roughness factors
  61781. */
  61782. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  61783. /**
  61784. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61785. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61786. * @param mimeType mime type to use for the textures
  61787. * @param images array of glTF image interfaces
  61788. * @param textures array of glTF texture interfaces
  61789. * @param materials array of glTF material interfaces
  61790. * @param imageData map of image file name to data
  61791. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61792. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61793. private setMetallicRoughnessPbrMaterial;
  61794. private getPixelsFromTexture;
  61795. /**
  61796. * Extracts a texture from a Babylon texture into file data and glTF data
  61797. * @param babylonTexture Babylon texture to extract
  61798. * @param mimeType Mime Type of the babylonTexture
  61799. * @return glTF texture info, or null if the texture format is not supported
  61800. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  61801. /**
  61802. * Builds a texture from base64 string
  61803. * @param base64Texture base64 texture string
  61804. * @param baseTextureName Name to use for the texture
  61805. * @param mimeType image mime type for the texture
  61806. * @param images array of images
  61807. * @param textures array of textures
  61808. * @param imageData map of image data
  61809. * @returns glTF texture info, or null if the texture format is not supported
  61810. */
  61811. private _getTextureInfoFromBase64;
  61812. }
  61813. }
  61814. declare module BABYLON {
  61815. /**
  61816. * Class for holding and downloading glTF file data
  61817. */
  61818. export class GLTFData {
  61819. /**
  61820. * Object which contains the file name as the key and its data as the value
  61821. */
  61822. glTFFiles: {
  61823. [fileName: string]: string | Blob;
  61824. };
  61825. /**
  61826. * Initializes the glTF file object
  61827. */
  61828. constructor();
  61829. /**
  61830. * Downloads the glTF data as files based on their names and data
  61831. */
  61832. downloadFiles(): void;
  61833. }
  61834. }
  61835. declare module BABYLON {
  61836. /**
  61837. * Holds a collection of exporter options and parameters
  61838. */
  61839. export interface IExportOptions {
  61840. /**
  61841. * Function which indicates whether a babylon node should be exported or not
  61842. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  61843. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  61844. */
  61845. shouldExportNode?(node: Node): boolean;
  61846. /**
  61847. * The sample rate to bake animation curves
  61848. */
  61849. animationSampleRate?: number;
  61850. /**
  61851. * Begin serialization without waiting for the scene to be ready
  61852. */
  61853. exportWithoutWaitingForScene?: boolean;
  61854. }
  61855. /**
  61856. * Class for generating glTF data from a Babylon scene.
  61857. */
  61858. export class GLTF2Export {
  61859. /**
  61860. * Exports the geometry of the scene to .gltf file format asynchronously
  61861. * @param scene Babylon scene with scene hierarchy information
  61862. * @param filePrefix File prefix to use when generating the glTF file
  61863. * @param options Exporter options
  61864. * @returns Returns an object with a .gltf file and associates texture names
  61865. * as keys and their data and paths as values
  61866. */
  61867. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  61868. private static _PreExportAsync;
  61869. private static _PostExportAsync;
  61870. /**
  61871. * Exports the geometry of the scene to .glb file format asychronously
  61872. * @param scene Babylon scene with scene hierarchy information
  61873. * @param filePrefix File prefix to use when generating glb file
  61874. * @param options Exporter options
  61875. * @returns Returns an object with a .glb filename as key and data as value
  61876. */
  61877. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  61878. }
  61879. }
  61880. declare module BABYLON.GLTF2.Exporter {
  61881. /**
  61882. * @hidden
  61883. */
  61884. export class _GLTFUtilities {
  61885. /**
  61886. * Creates a buffer view based on the supplied arguments
  61887. * @param bufferIndex index value of the specified buffer
  61888. * @param byteOffset byte offset value
  61889. * @param byteLength byte length of the bufferView
  61890. * @param byteStride byte distance between conequential elements
  61891. * @param name name of the buffer view
  61892. * @returns bufferView for glTF
  61893. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  61894. /**
  61895. * Creates an accessor based on the supplied arguments
  61896. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  61897. * @param name The name of the accessor
  61898. * @param type The type of the accessor
  61899. * @param componentType The datatype of components in the attribute
  61900. * @param count The number of attributes referenced by this accessor
  61901. * @param byteOffset The offset relative to the start of the bufferView in bytes
  61902. * @param min Minimum value of each component in this attribute
  61903. * @param max Maximum value of each component in this attribute
  61904. * @returns accessor for glTF
  61905. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  61906. /**
  61907. * Calculates the minimum and maximum values of an array of position floats
  61908. * @param positions Positions array of a mesh
  61909. * @param vertexStart Starting vertex offset to calculate min and max values
  61910. * @param vertexCount Number of vertices to check for min and max values
  61911. * @returns min number array and max number array
  61912. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  61913. min: number[];
  61914. max: number[];
  61915. };
  61916. /**
  61917. * Converts a new right-handed Vector3
  61918. * @param vector vector3 array
  61919. * @returns right-handed Vector3
  61920. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  61921. /**
  61922. * Converts a Vector3 to right-handed
  61923. * @param vector Vector3 to convert to right-handed
  61924. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  61925. /**
  61926. * Converts a three element number array to right-handed
  61927. * @param vector number array to convert to right-handed
  61928. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  61929. /**
  61930. * Converts a new right-handed Vector3
  61931. * @param vector vector3 array
  61932. * @returns right-handed Vector3
  61933. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  61934. /**
  61935. * Converts a Vector3 to right-handed
  61936. * @param vector Vector3 to convert to right-handed
  61937. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  61938. /**
  61939. * Converts a three element number array to right-handed
  61940. * @param vector number array to convert to right-handed
  61941. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  61942. /**
  61943. * Converts a Vector4 to right-handed
  61944. * @param vector Vector4 to convert to right-handed
  61945. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  61946. /**
  61947. * Converts a Vector4 to right-handed
  61948. * @param vector Vector4 to convert to right-handed
  61949. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  61950. /**
  61951. * Converts a Quaternion to right-handed
  61952. * @param quaternion Source quaternion to convert to right-handed
  61953. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  61954. /**
  61955. * Converts a Quaternion to right-handed
  61956. * @param quaternion Source quaternion to convert to right-handed
  61957. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  61958. }
  61959. }
  61960. declare module BABYLON.GLTF2.Exporter {
  61961. /**
  61962. * Converts Babylon Scene into glTF 2.0.
  61963. * @hidden
  61964. */
  61965. export class _Exporter {
  61966. /**
  61967. * Stores the glTF to export
  61968. */ glTF: IGLTF;
  61969. /**
  61970. * Stores all generated buffer views, which represents views into the main glTF buffer data
  61971. */ bufferViews: IBufferView[];
  61972. /**
  61973. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  61974. */ accessors: IAccessor[];
  61975. /**
  61976. * Stores all the generated nodes, which contains transform and/or mesh information per node
  61977. */
  61978. private _nodes;
  61979. /**
  61980. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  61981. */
  61982. private _scenes;
  61983. /**
  61984. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  61985. */
  61986. private _meshes;
  61987. /**
  61988. * Stores all the generated material information, which represents the appearance of each primitive
  61989. */ materials: IMaterial[]; materialMap: {
  61990. [materialID: number]: number;
  61991. };
  61992. /**
  61993. * Stores all the generated texture information, which is referenced by glTF materials
  61994. */ textures: ITexture[];
  61995. /**
  61996. * Stores all the generated image information, which is referenced by glTF textures
  61997. */ images: IImage[];
  61998. /**
  61999. * Stores all the texture samplers
  62000. */ samplers: ISampler[];
  62001. /**
  62002. * Stores all the generated animation samplers, which is referenced by glTF animations
  62003. */
  62004. /**
  62005. * Stores the animations for glTF models
  62006. */
  62007. private _animations;
  62008. /**
  62009. * Stores the total amount of bytes stored in the glTF buffer
  62010. */
  62011. private _totalByteLength;
  62012. /**
  62013. * Stores a reference to the Babylon scene containing the source geometry and material information
  62014. */ babylonScene: Scene;
  62015. /**
  62016. * Stores a map of the image data, where the key is the file name and the value
  62017. * is the image data
  62018. */ imageData: {
  62019. [fileName: string]: {
  62020. data: Uint8Array;
  62021. mimeType: ImageMimeType;
  62022. };
  62023. };
  62024. /**
  62025. * Stores a map of the unique id of a node to its index in the node array
  62026. */
  62027. private _nodeMap;
  62028. /**
  62029. * Specifies if the Babylon scene should be converted to right-handed on export
  62030. */ convertToRightHandedSystem: boolean;
  62031. /**
  62032. * Baked animation sample rate
  62033. */
  62034. private _animationSampleRate;
  62035. /**
  62036. * Callback which specifies if a node should be exported or not
  62037. */
  62038. private _shouldExportNode;
  62039. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  62040. private _extensions;
  62041. private static _ExtensionNames;
  62042. private static _ExtensionFactories;
  62043. 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>>;
  62044. private _forEachExtensions;
  62045. private _extensionsOnExporting;
  62046. /**
  62047. * Load glTF serializer extensions
  62048. */
  62049. private _loadExtensions;
  62050. /**
  62051. * Creates a glTF Exporter instance, which can accept optional exporter options
  62052. * @param babylonScene Babylon scene object
  62053. * @param options Options to modify the behavior of the exporter
  62054. */
  62055. constructor(babylonScene: Scene, options?: IExportOptions);
  62056. /**
  62057. * Registers a glTF exporter extension
  62058. * @param name Name of the extension to export
  62059. * @param factory The factory function that creates the exporter extension
  62060. */
  62061. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  62062. /**
  62063. * Un-registers an exporter extension
  62064. * @param name The name fo the exporter extension
  62065. * @returns A boolean indicating whether the extension has been un-registered
  62066. */
  62067. static UnregisterExtension(name: string): boolean;
  62068. /**
  62069. * Lazy load a local engine with premultiplied alpha set to false
  62070. */ getLocalEngine(): Engine;
  62071. private reorderIndicesBasedOnPrimitiveMode;
  62072. /**
  62073. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  62074. * clock-wise during export to glTF
  62075. * @param submesh BabylonJS submesh
  62076. * @param primitiveMode Primitive mode of the mesh
  62077. * @param sideOrientation the winding order of the submesh
  62078. * @param vertexBufferKind The type of vertex attribute
  62079. * @param meshAttributeArray The vertex attribute data
  62080. * @param byteOffset The offset to the binary data
  62081. * @param binaryWriter The binary data for the glTF file
  62082. */
  62083. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  62084. /**
  62085. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  62086. * clock-wise during export to glTF
  62087. * @param submesh BabylonJS submesh
  62088. * @param primitiveMode Primitive mode of the mesh
  62089. * @param sideOrientation the winding order of the submesh
  62090. * @param vertexBufferKind The type of vertex attribute
  62091. * @param meshAttributeArray The vertex attribute data
  62092. * @param byteOffset The offset to the binary data
  62093. * @param binaryWriter The binary data for the glTF file
  62094. */
  62095. private reorderTriangleFillMode;
  62096. /**
  62097. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  62098. * clock-wise during export to glTF
  62099. * @param submesh BabylonJS submesh
  62100. * @param primitiveMode Primitive mode of the mesh
  62101. * @param sideOrientation the winding order of the submesh
  62102. * @param vertexBufferKind The type of vertex attribute
  62103. * @param meshAttributeArray The vertex attribute data
  62104. * @param byteOffset The offset to the binary data
  62105. * @param binaryWriter The binary data for the glTF file
  62106. */
  62107. private reorderTriangleStripDrawMode;
  62108. /**
  62109. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  62110. * clock-wise during export to glTF
  62111. * @param submesh BabylonJS submesh
  62112. * @param primitiveMode Primitive mode of the mesh
  62113. * @param sideOrientation the winding order of the submesh
  62114. * @param vertexBufferKind The type of vertex attribute
  62115. * @param meshAttributeArray The vertex attribute data
  62116. * @param byteOffset The offset to the binary data
  62117. * @param binaryWriter The binary data for the glTF file
  62118. */
  62119. private reorderTriangleFanMode;
  62120. /**
  62121. * Writes the vertex attribute data to binary
  62122. * @param vertices The vertices to write to the binary writer
  62123. * @param byteOffset The offset into the binary writer to overwrite binary data
  62124. * @param vertexAttributeKind The vertex attribute type
  62125. * @param meshAttributeArray The vertex attribute data
  62126. * @param binaryWriter The writer containing the binary data
  62127. */
  62128. private writeVertexAttributeData;
  62129. /**
  62130. * Writes mesh attribute data to a data buffer
  62131. * Returns the bytelength of the data
  62132. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  62133. * @param meshAttributeArray Array containing the attribute data
  62134. * @param binaryWriter The buffer to write the binary data to
  62135. * @param indices Used to specify the order of the vertex data
  62136. */
  62137. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  62138. /**
  62139. * Generates glTF json data
  62140. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  62141. * @param glTFPrefix Text to use when prefixing a glTF file
  62142. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  62143. * @returns json data as string
  62144. */
  62145. private generateJSON;
  62146. /**
  62147. * Generates data for .gltf and .bin files based on the glTF prefix string
  62148. * @param glTFPrefix Text to use when prefixing a glTF file
  62149. * @returns GLTFData with glTF file data
  62150. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  62151. /**
  62152. * Creates a binary buffer for glTF
  62153. * @returns array buffer for binary data
  62154. */
  62155. private _generateBinaryAsync;
  62156. /**
  62157. * Pads the number to a multiple of 4
  62158. * @param num number to pad
  62159. * @returns padded number
  62160. */
  62161. private _getPadding;
  62162. /**
  62163. * Generates a glb file from the json and binary data
  62164. * Returns an object with the glb file name as the key and data as the value
  62165. * @param glTFPrefix
  62166. * @returns object with glb filename as key and data as value
  62167. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  62168. /**
  62169. * Sets the TRS for each node
  62170. * @param node glTF Node for storing the transformation data
  62171. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  62172. */
  62173. private setNodeTransformation;
  62174. private getVertexBufferFromMesh;
  62175. /**
  62176. * Creates a bufferview based on the vertices type for the Babylon mesh
  62177. * @param kind Indicates the type of vertices data
  62178. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  62179. * @param binaryWriter The buffer to write the bufferview data to
  62180. */
  62181. private createBufferViewKind;
  62182. /**
  62183. * The primitive mode of the Babylon mesh
  62184. * @param babylonMesh The BabylonJS mesh
  62185. */
  62186. private getMeshPrimitiveMode;
  62187. /**
  62188. * Sets the primitive mode of the glTF mesh primitive
  62189. * @param meshPrimitive glTF mesh primitive
  62190. * @param primitiveMode The primitive mode
  62191. */
  62192. private setPrimitiveMode;
  62193. /**
  62194. * Sets the vertex attribute accessor based of the glTF mesh primitive
  62195. * @param meshPrimitive glTF mesh primitive
  62196. * @param attributeKind vertex attribute
  62197. * @returns boolean specifying if uv coordinates are present
  62198. */
  62199. private setAttributeKind;
  62200. /**
  62201. * Sets data for the primitive attributes of each submesh
  62202. * @param mesh glTF Mesh object to store the primitive attribute information
  62203. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  62204. * @param binaryWriter Buffer to write the attribute data to
  62205. */
  62206. private setPrimitiveAttributesAsync;
  62207. /**
  62208. * Creates a glTF scene based on the array of meshes
  62209. * Returns the the total byte offset
  62210. * @param babylonScene Babylon scene to get the mesh data from
  62211. * @param binaryWriter Buffer to write binary data to
  62212. */
  62213. private createSceneAsync;
  62214. /**
  62215. * Creates a mapping of Node unique id to node index and handles animations
  62216. * @param babylonScene Babylon Scene
  62217. * @param nodes Babylon transform nodes
  62218. * @param shouldExportNode Callback specifying if a transform node should be exported
  62219. * @param binaryWriter Buffer to write binary data to
  62220. * @returns Node mapping of unique id to index
  62221. */
  62222. private createNodeMapAndAnimationsAsync;
  62223. /**
  62224. * Creates a glTF node from a Babylon mesh
  62225. * @param babylonMesh Source Babylon mesh
  62226. * @param binaryWriter Buffer for storing geometry data
  62227. * @returns glTF node
  62228. */
  62229. private createNodeAsync;
  62230. }
  62231. /**
  62232. * @hidden
  62233. *
  62234. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  62235. */
  62236. export class _BinaryWriter {
  62237. /**
  62238. * Array buffer which stores all binary data
  62239. */
  62240. private _arrayBuffer;
  62241. /**
  62242. * View of the array buffer
  62243. */
  62244. private _dataView;
  62245. /**
  62246. * byte offset of data in array buffer
  62247. */
  62248. private _byteOffset;
  62249. /**
  62250. * Initialize binary writer with an initial byte length
  62251. * @param byteLength Initial byte length of the array buffer
  62252. */
  62253. constructor(byteLength: number);
  62254. /**
  62255. * Resize the array buffer to the specified byte length
  62256. * @param byteLength
  62257. */
  62258. private resizeBuffer;
  62259. /**
  62260. * Get an array buffer with the length of the byte offset
  62261. * @returns ArrayBuffer resized to the byte offset
  62262. */
  62263. getArrayBuffer(): ArrayBuffer;
  62264. /**
  62265. * Get the byte offset of the array buffer
  62266. * @returns byte offset
  62267. */
  62268. getByteOffset(): number;
  62269. /**
  62270. * Stores an UInt8 in the array buffer
  62271. * @param entry
  62272. * @param byteOffset If defined, specifies where to set the value as an offset.
  62273. */
  62274. setUInt8(entry: number, byteOffset?: number): void;
  62275. /**
  62276. * Gets an UInt32 in the array buffer
  62277. * @param entry
  62278. * @param byteOffset If defined, specifies where to set the value as an offset.
  62279. */
  62280. getUInt32(byteOffset: number): number;
  62281. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62282. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62283. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62284. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62285. /**
  62286. * Stores a Float32 in the array buffer
  62287. * @param entry
  62288. */
  62289. setFloat32(entry: number, byteOffset?: number): void;
  62290. /**
  62291. * Stores an UInt32 in the array buffer
  62292. * @param entry
  62293. * @param byteOffset If defined, specifies where to set the value as an offset.
  62294. */
  62295. setUInt32(entry: number, byteOffset?: number): void;
  62296. }
  62297. }
  62298. declare module BABYLON.GLTF2.Exporter {
  62299. /**
  62300. * @hidden
  62301. * Interface to store animation data.
  62302. */
  62303. export interface _IAnimationData {
  62304. /**
  62305. * Keyframe data.
  62306. */
  62307. inputs: number[];
  62308. /**
  62309. * Value data.
  62310. */
  62311. outputs: number[][];
  62312. /**
  62313. * Animation interpolation data.
  62314. */
  62315. samplerInterpolation: AnimationSamplerInterpolation;
  62316. /**
  62317. * Minimum keyframe value.
  62318. */
  62319. inputsMin: number;
  62320. /**
  62321. * Maximum keyframe value.
  62322. */
  62323. inputsMax: number;
  62324. }
  62325. /**
  62326. * @hidden
  62327. */
  62328. export interface _IAnimationInfo {
  62329. /**
  62330. * The target channel for the animation
  62331. */
  62332. animationChannelTargetPath: AnimationChannelTargetPath;
  62333. /**
  62334. * The glTF accessor type for the data.
  62335. */
  62336. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  62337. /**
  62338. * Specifies if quaternions should be used.
  62339. */
  62340. useQuaternion: boolean;
  62341. }
  62342. /**
  62343. * @hidden
  62344. * Utility class for generating glTF animation data from BabylonJS.
  62345. */
  62346. export class _GLTFAnimation {
  62347. /**
  62348. * @ignore
  62349. *
  62350. * Creates glTF channel animation from BabylonJS animation.
  62351. * @param babylonTransformNode - BabylonJS mesh.
  62352. * @param animation - animation.
  62353. * @param animationChannelTargetPath - The target animation channel.
  62354. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  62355. * @param useQuaternion - Specifies if quaternions are used.
  62356. * @returns nullable IAnimationData
  62357. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  62358. private static _DeduceAnimationInfo;
  62359. /**
  62360. * @ignore
  62361. * Create node animations from the transform node animations
  62362. * @param babylonNode
  62363. * @param runtimeGLTFAnimation
  62364. * @param idleGLTFAnimations
  62365. * @param nodeMap
  62366. * @param nodes
  62367. * @param binaryWriter
  62368. * @param bufferViews
  62369. * @param accessors
  62370. * @param convertToRightHandedSystem
  62371. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  62372. [key: number]: number;
  62373. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62374. /**
  62375. * @ignore
  62376. * Create node animations from the animation groups
  62377. * @param babylonScene
  62378. * @param glTFAnimations
  62379. * @param nodeMap
  62380. * @param nodes
  62381. * @param binaryWriter
  62382. * @param bufferViews
  62383. * @param accessors
  62384. * @param convertToRightHandedSystem
  62385. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  62386. [key: number]: number;
  62387. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62388. private static AddAnimation;
  62389. /**
  62390. * Create a baked animation
  62391. * @param babylonTransformNode BabylonJS mesh
  62392. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  62393. * @param animationChannelTargetPath animation target channel
  62394. * @param minFrame minimum animation frame
  62395. * @param maxFrame maximum animation frame
  62396. * @param fps frames per second of the animation
  62397. * @param inputs input key frames of the animation
  62398. * @param outputs output key frame data of the animation
  62399. * @param convertToRightHandedSystem converts the values to right-handed
  62400. * @param useQuaternion specifies if quaternions should be used
  62401. */
  62402. private static _CreateBakedAnimation;
  62403. private static _ConvertFactorToVector3OrQuaternion;
  62404. private static _SetInterpolatedValue;
  62405. /**
  62406. * Creates linear animation from the animation key frames
  62407. * @param babylonTransformNode BabylonJS mesh
  62408. * @param animation BabylonJS animation
  62409. * @param animationChannelTargetPath The target animation channel
  62410. * @param frameDelta The difference between the last and first frame of the animation
  62411. * @param inputs Array to store the key frame times
  62412. * @param outputs Array to store the key frame data
  62413. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62414. * @param useQuaternion Specifies if quaternions are used in the animation
  62415. */
  62416. private static _CreateLinearOrStepAnimation;
  62417. /**
  62418. * Creates cubic spline animation from the animation key frames
  62419. * @param babylonTransformNode BabylonJS mesh
  62420. * @param animation BabylonJS animation
  62421. * @param animationChannelTargetPath The target animation channel
  62422. * @param frameDelta The difference between the last and first frame of the animation
  62423. * @param inputs Array to store the key frame times
  62424. * @param outputs Array to store the key frame data
  62425. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62426. * @param useQuaternion Specifies if quaternions are used in the animation
  62427. */
  62428. private static _CreateCubicSplineAnimation;
  62429. private static _GetBasePositionRotationOrScale;
  62430. /**
  62431. * Adds a key frame value
  62432. * @param keyFrame
  62433. * @param animation
  62434. * @param outputs
  62435. * @param animationChannelTargetPath
  62436. * @param basePositionRotationOrScale
  62437. * @param convertToRightHandedSystem
  62438. * @param useQuaternion
  62439. */
  62440. private static _AddKeyframeValue;
  62441. /**
  62442. * Determine the interpolation based on the key frames
  62443. * @param keyFrames
  62444. * @param animationChannelTargetPath
  62445. * @param useQuaternion
  62446. */
  62447. private static _DeduceInterpolation;
  62448. /**
  62449. * Adds an input tangent or output tangent to the output data
  62450. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  62451. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  62452. * @param outputs The animation data by keyframe
  62453. * @param animationChannelTargetPath The target animation channel
  62454. * @param interpolation The interpolation type
  62455. * @param keyFrame The key frame with the animation data
  62456. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  62457. * @param useQuaternion Specifies if quaternions are used
  62458. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  62459. */
  62460. private static AddSplineTangent;
  62461. /**
  62462. * Get the minimum and maximum key frames' frame values
  62463. * @param keyFrames animation key frames
  62464. * @returns the minimum and maximum key frame value
  62465. */
  62466. private static calculateMinMaxKeyFrames;
  62467. }
  62468. }
  62469. declare module BABYLON.GLTF2.Exporter {
  62470. /** @hidden */
  62471. export var textureTransformPixelShader: {
  62472. name: string;
  62473. shader: string;
  62474. };
  62475. }
  62476. declare module BABYLON.GLTF2.Exporter.Extensions {
  62477. /**
  62478. * @hidden
  62479. */
  62480. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  62481. /** Name of this extension */
  62482. readonly name: string;
  62483. /** Defines whether this extension is enabled */
  62484. enabled: boolean;
  62485. /** Defines whether this extension is required */
  62486. required: boolean;
  62487. /** Reference to the glTF exporter */
  62488. private _exporter;
  62489. constructor(exporter: _Exporter);
  62490. dispose(): void;
  62491. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  62492. /**
  62493. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  62494. * @param babylonTexture
  62495. * @param offset
  62496. * @param rotation
  62497. * @param scale
  62498. * @param scene
  62499. */
  62500. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  62501. }
  62502. }
  62503. declare module BABYLON.GLTF2.Exporter.Extensions {
  62504. /**
  62505. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  62506. */
  62507. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  62508. /** The name of this extension. */
  62509. readonly name: string;
  62510. /** Defines whether this extension is enabled. */
  62511. enabled: boolean;
  62512. /** Defines whether this extension is required */
  62513. required: boolean;
  62514. /** Reference to the glTF exporter */
  62515. private _exporter;
  62516. private _lights;
  62517. /** @hidden */
  62518. constructor(exporter: _Exporter);
  62519. /** @hidden */
  62520. dispose(): void;
  62521. /** @hidden */
  62522. onExporting(): void;
  62523. /**
  62524. * Define this method to modify the default behavior when exporting a node
  62525. * @param context The context when exporting the node
  62526. * @param node glTF node
  62527. * @param babylonNode BabylonJS node
  62528. * @returns nullable INode promise
  62529. */
  62530. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62531. }
  62532. }
  62533. declare module BABYLON {
  62534. /**
  62535. * Class for generating STL data from a Babylon scene.
  62536. */
  62537. export class STLExport {
  62538. /**
  62539. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  62540. * @param meshes list defines the mesh to serialize
  62541. * @param download triggers the automatic download of the file.
  62542. * @param fileName changes the downloads fileName.
  62543. * @param binary changes the STL to a binary type.
  62544. * @param isLittleEndian toggle for binary type exporter.
  62545. * @returns the STL as UTF8 string
  62546. */
  62547. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  62548. }
  62549. }
  62550. /**
  62551. * @ignoreChildren
  62552. * @ignore
  62553. */
  62554. declare module "babylonjs-gltf2interface" {
  62555. export = BABYLON.GLTF2;
  62556. }
  62557. /**
  62558. * Module for glTF 2.0 Interface
  62559. * @ignoreChildren
  62560. * @ignore
  62561. */
  62562. declare module BABYLON.GLTF2 {
  62563. /**
  62564. * The datatype of the components in the attribute
  62565. */
  62566. const enum AccessorComponentType {
  62567. /**
  62568. * Byte
  62569. */
  62570. BYTE = 5120,
  62571. /**
  62572. * Unsigned Byte
  62573. */
  62574. UNSIGNED_BYTE = 5121,
  62575. /**
  62576. * Short
  62577. */
  62578. SHORT = 5122,
  62579. /**
  62580. * Unsigned Short
  62581. */
  62582. UNSIGNED_SHORT = 5123,
  62583. /**
  62584. * Unsigned Int
  62585. */
  62586. UNSIGNED_INT = 5125,
  62587. /**
  62588. * Float
  62589. */
  62590. FLOAT = 5126,
  62591. }
  62592. /**
  62593. * Specifies if the attirbute is a scalar, vector, or matrix
  62594. */
  62595. const enum AccessorType {
  62596. /**
  62597. * Scalar
  62598. */
  62599. SCALAR = "SCALAR",
  62600. /**
  62601. * Vector2
  62602. */
  62603. VEC2 = "VEC2",
  62604. /**
  62605. * Vector3
  62606. */
  62607. VEC3 = "VEC3",
  62608. /**
  62609. * Vector4
  62610. */
  62611. VEC4 = "VEC4",
  62612. /**
  62613. * Matrix2x2
  62614. */
  62615. MAT2 = "MAT2",
  62616. /**
  62617. * Matrix3x3
  62618. */
  62619. MAT3 = "MAT3",
  62620. /**
  62621. * Matrix4x4
  62622. */
  62623. MAT4 = "MAT4",
  62624. }
  62625. /**
  62626. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62627. */
  62628. const enum AnimationChannelTargetPath {
  62629. /**
  62630. * Translation
  62631. */
  62632. TRANSLATION = "translation",
  62633. /**
  62634. * Rotation
  62635. */
  62636. ROTATION = "rotation",
  62637. /**
  62638. * Scale
  62639. */
  62640. SCALE = "scale",
  62641. /**
  62642. * Weights
  62643. */
  62644. WEIGHTS = "weights",
  62645. }
  62646. /**
  62647. * Interpolation algorithm
  62648. */
  62649. const enum AnimationSamplerInterpolation {
  62650. /**
  62651. * The animated values are linearly interpolated between keyframes
  62652. */
  62653. LINEAR = "LINEAR",
  62654. /**
  62655. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  62656. */
  62657. STEP = "STEP",
  62658. /**
  62659. * The animation's interpolation is computed using a cubic spline with specified tangents
  62660. */
  62661. CUBICSPLINE = "CUBICSPLINE",
  62662. }
  62663. /**
  62664. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62665. */
  62666. const enum CameraType {
  62667. /**
  62668. * A perspective camera containing properties to create a perspective projection matrix
  62669. */
  62670. PERSPECTIVE = "perspective",
  62671. /**
  62672. * An orthographic camera containing properties to create an orthographic projection matrix
  62673. */
  62674. ORTHOGRAPHIC = "orthographic",
  62675. }
  62676. /**
  62677. * The mime-type of the image
  62678. */
  62679. const enum ImageMimeType {
  62680. /**
  62681. * JPEG Mime-type
  62682. */
  62683. JPEG = "image/jpeg",
  62684. /**
  62685. * PNG Mime-type
  62686. */
  62687. PNG = "image/png",
  62688. }
  62689. /**
  62690. * The alpha rendering mode of the material
  62691. */
  62692. const enum MaterialAlphaMode {
  62693. /**
  62694. * The alpha value is ignored and the rendered output is fully opaque
  62695. */
  62696. OPAQUE = "OPAQUE",
  62697. /**
  62698. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  62699. */
  62700. MASK = "MASK",
  62701. /**
  62702. * 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)
  62703. */
  62704. BLEND = "BLEND",
  62705. }
  62706. /**
  62707. * The type of the primitives to render
  62708. */
  62709. const enum MeshPrimitiveMode {
  62710. /**
  62711. * Points
  62712. */
  62713. POINTS = 0,
  62714. /**
  62715. * Lines
  62716. */
  62717. LINES = 1,
  62718. /**
  62719. * Line Loop
  62720. */
  62721. LINE_LOOP = 2,
  62722. /**
  62723. * Line Strip
  62724. */
  62725. LINE_STRIP = 3,
  62726. /**
  62727. * Triangles
  62728. */
  62729. TRIANGLES = 4,
  62730. /**
  62731. * Triangle Strip
  62732. */
  62733. TRIANGLE_STRIP = 5,
  62734. /**
  62735. * Triangle Fan
  62736. */
  62737. TRIANGLE_FAN = 6,
  62738. }
  62739. /**
  62740. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  62741. */
  62742. const enum TextureMagFilter {
  62743. /**
  62744. * Nearest
  62745. */
  62746. NEAREST = 9728,
  62747. /**
  62748. * Linear
  62749. */
  62750. LINEAR = 9729,
  62751. }
  62752. /**
  62753. * Minification filter. All valid values correspond to WebGL enums
  62754. */
  62755. const enum TextureMinFilter {
  62756. /**
  62757. * Nearest
  62758. */
  62759. NEAREST = 9728,
  62760. /**
  62761. * Linear
  62762. */
  62763. LINEAR = 9729,
  62764. /**
  62765. * Nearest Mip-Map Nearest
  62766. */
  62767. NEAREST_MIPMAP_NEAREST = 9984,
  62768. /**
  62769. * Linear Mipmap Nearest
  62770. */
  62771. LINEAR_MIPMAP_NEAREST = 9985,
  62772. /**
  62773. * Nearest Mipmap Linear
  62774. */
  62775. NEAREST_MIPMAP_LINEAR = 9986,
  62776. /**
  62777. * Linear Mipmap Linear
  62778. */
  62779. LINEAR_MIPMAP_LINEAR = 9987,
  62780. }
  62781. /**
  62782. * S (U) wrapping mode. All valid values correspond to WebGL enums
  62783. */
  62784. const enum TextureWrapMode {
  62785. /**
  62786. * Clamp to Edge
  62787. */
  62788. CLAMP_TO_EDGE = 33071,
  62789. /**
  62790. * Mirrored Repeat
  62791. */
  62792. MIRRORED_REPEAT = 33648,
  62793. /**
  62794. * Repeat
  62795. */
  62796. REPEAT = 10497,
  62797. }
  62798. /**
  62799. * glTF Property
  62800. */
  62801. interface IProperty {
  62802. /**
  62803. * Dictionary object with extension-specific objects
  62804. */
  62805. extensions?: {
  62806. [key: string]: any;
  62807. };
  62808. /**
  62809. * Application-Specific data
  62810. */
  62811. extras?: any;
  62812. }
  62813. /**
  62814. * glTF Child of Root Property
  62815. */
  62816. interface IChildRootProperty extends IProperty {
  62817. /**
  62818. * The user-defined name of this object
  62819. */
  62820. name?: string;
  62821. }
  62822. /**
  62823. * Indices of those attributes that deviate from their initialization value
  62824. */
  62825. interface IAccessorSparseIndices extends IProperty {
  62826. /**
  62827. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  62828. */
  62829. bufferView: number;
  62830. /**
  62831. * The offset relative to the start of the bufferView in bytes. Must be aligned
  62832. */
  62833. byteOffset?: number;
  62834. /**
  62835. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  62836. */
  62837. componentType: AccessorComponentType;
  62838. }
  62839. /**
  62840. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  62841. */
  62842. interface IAccessorSparseValues extends IProperty {
  62843. /**
  62844. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  62845. */
  62846. bufferView: number;
  62847. /**
  62848. * The offset relative to the start of the bufferView in bytes. Must be aligned
  62849. */
  62850. byteOffset?: number;
  62851. }
  62852. /**
  62853. * Sparse storage of attributes that deviate from their initialization value
  62854. */
  62855. interface IAccessorSparse extends IProperty {
  62856. /**
  62857. * The number of attributes encoded in this sparse accessor
  62858. */
  62859. count: number;
  62860. /**
  62861. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  62862. */
  62863. indices: IAccessorSparseIndices;
  62864. /**
  62865. * 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
  62866. */
  62867. values: IAccessorSparseValues;
  62868. }
  62869. /**
  62870. * 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
  62871. */
  62872. interface IAccessor extends IChildRootProperty {
  62873. /**
  62874. * The index of the bufferview
  62875. */
  62876. bufferView?: number;
  62877. /**
  62878. * The offset relative to the start of the bufferView in bytes
  62879. */
  62880. byteOffset?: number;
  62881. /**
  62882. * The datatype of components in the attribute
  62883. */
  62884. componentType: AccessorComponentType;
  62885. /**
  62886. * Specifies whether integer data values should be normalized
  62887. */
  62888. normalized?: boolean;
  62889. /**
  62890. * The number of attributes referenced by this accessor
  62891. */
  62892. count: number;
  62893. /**
  62894. * Specifies if the attribute is a scalar, vector, or matrix
  62895. */
  62896. type: AccessorType;
  62897. /**
  62898. * Maximum value of each component in this attribute
  62899. */
  62900. max?: number[];
  62901. /**
  62902. * Minimum value of each component in this attribute
  62903. */
  62904. min?: number[];
  62905. /**
  62906. * Sparse storage of attributes that deviate from their initialization value
  62907. */
  62908. sparse?: IAccessorSparse;
  62909. }
  62910. /**
  62911. * Targets an animation's sampler at a node's property
  62912. */
  62913. interface IAnimationChannel extends IProperty {
  62914. /**
  62915. * The index of a sampler in this animation used to compute the value for the target
  62916. */
  62917. sampler: number;
  62918. /**
  62919. * The index of the node and TRS property to target
  62920. */
  62921. target: IAnimationChannelTarget;
  62922. }
  62923. /**
  62924. * The index of the node and TRS property that an animation channel targets
  62925. */
  62926. interface IAnimationChannelTarget extends IProperty {
  62927. /**
  62928. * The index of the node to target
  62929. */
  62930. node: number;
  62931. /**
  62932. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62933. */
  62934. path: AnimationChannelTargetPath;
  62935. }
  62936. /**
  62937. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  62938. */
  62939. interface IAnimationSampler extends IProperty {
  62940. /**
  62941. * The index of an accessor containing keyframe input values, e.g., time
  62942. */
  62943. input: number;
  62944. /**
  62945. * Interpolation algorithm
  62946. */
  62947. interpolation?: AnimationSamplerInterpolation;
  62948. /**
  62949. * The index of an accessor, containing keyframe output values
  62950. */
  62951. output: number;
  62952. }
  62953. /**
  62954. * A keyframe animation
  62955. */
  62956. interface IAnimation extends IChildRootProperty {
  62957. /**
  62958. * An array of channels, each of which targets an animation's sampler at a node's property
  62959. */
  62960. channels: IAnimationChannel[];
  62961. /**
  62962. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  62963. */
  62964. samplers: IAnimationSampler[];
  62965. }
  62966. /**
  62967. * Metadata about the glTF asset
  62968. */
  62969. interface IAsset extends IChildRootProperty {
  62970. /**
  62971. * A copyright message suitable for display to credit the content creator
  62972. */
  62973. copyright?: string;
  62974. /**
  62975. * Tool that generated this glTF model. Useful for debugging
  62976. */
  62977. generator?: string;
  62978. /**
  62979. * The glTF version that this asset targets
  62980. */
  62981. version: string;
  62982. /**
  62983. * The minimum glTF version that this asset targets
  62984. */
  62985. minVersion?: string;
  62986. }
  62987. /**
  62988. * A buffer points to binary geometry, animation, or skins
  62989. */
  62990. interface IBuffer extends IChildRootProperty {
  62991. /**
  62992. * 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
  62993. */
  62994. uri?: string;
  62995. /**
  62996. * The length of the buffer in bytes
  62997. */
  62998. byteLength: number;
  62999. }
  63000. /**
  63001. * A view into a buffer generally representing a subset of the buffer
  63002. */
  63003. interface IBufferView extends IChildRootProperty {
  63004. /**
  63005. * The index of the buffer
  63006. */
  63007. buffer: number;
  63008. /**
  63009. * The offset into the buffer in bytes
  63010. */
  63011. byteOffset?: number;
  63012. /**
  63013. * The lenth of the bufferView in bytes
  63014. */
  63015. byteLength: number;
  63016. /**
  63017. * The stride, in bytes
  63018. */
  63019. byteStride?: number;
  63020. }
  63021. /**
  63022. * An orthographic camera containing properties to create an orthographic projection matrix
  63023. */
  63024. interface ICameraOrthographic extends IProperty {
  63025. /**
  63026. * The floating-point horizontal magnification of the view. Must not be zero
  63027. */
  63028. xmag: number;
  63029. /**
  63030. * The floating-point vertical magnification of the view. Must not be zero
  63031. */
  63032. ymag: number;
  63033. /**
  63034. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  63035. */
  63036. zfar: number;
  63037. /**
  63038. * The floating-point distance to the near clipping plane
  63039. */
  63040. znear: number;
  63041. }
  63042. /**
  63043. * A perspective camera containing properties to create a perspective projection matrix
  63044. */
  63045. interface ICameraPerspective extends IProperty {
  63046. /**
  63047. * The floating-point aspect ratio of the field of view
  63048. */
  63049. aspectRatio?: number;
  63050. /**
  63051. * The floating-point vertical field of view in radians
  63052. */
  63053. yfov: number;
  63054. /**
  63055. * The floating-point distance to the far clipping plane
  63056. */
  63057. zfar?: number;
  63058. /**
  63059. * The floating-point distance to the near clipping plane
  63060. */
  63061. znear: number;
  63062. }
  63063. /**
  63064. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  63065. */
  63066. interface ICamera extends IChildRootProperty {
  63067. /**
  63068. * An orthographic camera containing properties to create an orthographic projection matrix
  63069. */
  63070. orthographic?: ICameraOrthographic;
  63071. /**
  63072. * A perspective camera containing properties to create a perspective projection matrix
  63073. */
  63074. perspective?: ICameraPerspective;
  63075. /**
  63076. * Specifies if the camera uses a perspective or orthographic projection
  63077. */
  63078. type: CameraType;
  63079. }
  63080. /**
  63081. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  63082. */
  63083. interface IImage extends IChildRootProperty {
  63084. /**
  63085. * 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
  63086. */
  63087. uri?: string;
  63088. /**
  63089. * The image's MIME type
  63090. */
  63091. mimeType?: ImageMimeType;
  63092. /**
  63093. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  63094. */
  63095. bufferView?: number;
  63096. }
  63097. /**
  63098. * Material Normal Texture Info
  63099. */
  63100. interface IMaterialNormalTextureInfo extends ITextureInfo {
  63101. /**
  63102. * The scalar multiplier applied to each normal vector of the normal texture
  63103. */
  63104. scale?: number;
  63105. }
  63106. /**
  63107. * Material Occlusion Texture Info
  63108. */
  63109. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  63110. /**
  63111. * A scalar multiplier controlling the amount of occlusion applied
  63112. */
  63113. strength?: number;
  63114. }
  63115. /**
  63116. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  63117. */
  63118. interface IMaterialPbrMetallicRoughness {
  63119. /**
  63120. * The material's base color factor
  63121. */
  63122. baseColorFactor?: number[];
  63123. /**
  63124. * The base color texture
  63125. */
  63126. baseColorTexture?: ITextureInfo;
  63127. /**
  63128. * The metalness of the material
  63129. */
  63130. metallicFactor?: number;
  63131. /**
  63132. * The roughness of the material
  63133. */
  63134. roughnessFactor?: number;
  63135. /**
  63136. * The metallic-roughness texture
  63137. */
  63138. metallicRoughnessTexture?: ITextureInfo;
  63139. }
  63140. /**
  63141. * The material appearance of a primitive
  63142. */
  63143. interface IMaterial extends IChildRootProperty {
  63144. /**
  63145. * 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
  63146. */
  63147. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63148. /**
  63149. * The normal map texture
  63150. */
  63151. normalTexture?: IMaterialNormalTextureInfo;
  63152. /**
  63153. * The occlusion map texture
  63154. */
  63155. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63156. /**
  63157. * The emissive map texture
  63158. */
  63159. emissiveTexture?: ITextureInfo;
  63160. /**
  63161. * 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
  63162. */
  63163. emissiveFactor?: number[];
  63164. /**
  63165. * The alpha rendering mode of the material
  63166. */
  63167. alphaMode?: MaterialAlphaMode;
  63168. /**
  63169. * The alpha cutoff value of the material
  63170. */
  63171. alphaCutoff?: number;
  63172. /**
  63173. * Specifies whether the material is double sided
  63174. */
  63175. doubleSided?: boolean;
  63176. }
  63177. /**
  63178. * Geometry to be rendered with the given material
  63179. */
  63180. interface IMeshPrimitive extends IProperty {
  63181. /**
  63182. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  63183. */
  63184. attributes: {
  63185. [name: string]: number;
  63186. };
  63187. /**
  63188. * The index of the accessor that contains the indices
  63189. */
  63190. indices?: number;
  63191. /**
  63192. * The index of the material to apply to this primitive when rendering
  63193. */
  63194. material?: number;
  63195. /**
  63196. * The type of primitives to render. All valid values correspond to WebGL enums
  63197. */
  63198. mode?: MeshPrimitiveMode;
  63199. /**
  63200. * 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
  63201. */
  63202. targets?: {
  63203. [name: string]: number;
  63204. }[];
  63205. }
  63206. /**
  63207. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  63208. */
  63209. interface IMesh extends IChildRootProperty {
  63210. /**
  63211. * An array of primitives, each defining geometry to be rendered with a material
  63212. */
  63213. primitives: IMeshPrimitive[];
  63214. /**
  63215. * Array of weights to be applied to the Morph Targets
  63216. */
  63217. weights?: number[];
  63218. }
  63219. /**
  63220. * A node in the node hierarchy
  63221. */
  63222. interface INode extends IChildRootProperty {
  63223. /**
  63224. * The index of the camera referenced by this node
  63225. */
  63226. camera?: number;
  63227. /**
  63228. * The indices of this node's children
  63229. */
  63230. children?: number[];
  63231. /**
  63232. * The index of the skin referenced by this node
  63233. */
  63234. skin?: number;
  63235. /**
  63236. * A floating-point 4x4 transformation matrix stored in column-major order
  63237. */
  63238. matrix?: number[];
  63239. /**
  63240. * The index of the mesh in this node
  63241. */
  63242. mesh?: number;
  63243. /**
  63244. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  63245. */
  63246. rotation?: number[];
  63247. /**
  63248. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  63249. */
  63250. scale?: number[];
  63251. /**
  63252. * The node's translation along the x, y, and z axes
  63253. */
  63254. translation?: number[];
  63255. /**
  63256. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  63257. */
  63258. weights?: number[];
  63259. }
  63260. /**
  63261. * Texture sampler properties for filtering and wrapping modes
  63262. */
  63263. interface ISampler extends IChildRootProperty {
  63264. /**
  63265. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  63266. */
  63267. magFilter?: TextureMagFilter;
  63268. /**
  63269. * Minification filter. All valid values correspond to WebGL enums
  63270. */
  63271. minFilter?: TextureMinFilter;
  63272. /**
  63273. * S (U) wrapping mode. All valid values correspond to WebGL enums
  63274. */
  63275. wrapS?: TextureWrapMode;
  63276. /**
  63277. * T (V) wrapping mode. All valid values correspond to WebGL enums
  63278. */
  63279. wrapT?: TextureWrapMode;
  63280. }
  63281. /**
  63282. * The root nodes of a scene
  63283. */
  63284. interface IScene extends IChildRootProperty {
  63285. /**
  63286. * The indices of each root node
  63287. */
  63288. nodes: number[];
  63289. }
  63290. /**
  63291. * Joints and matrices defining a skin
  63292. */
  63293. interface ISkin extends IChildRootProperty {
  63294. /**
  63295. * 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
  63296. */
  63297. inverseBindMatrices?: number;
  63298. /**
  63299. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  63300. */
  63301. skeleton?: number;
  63302. /**
  63303. * 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)
  63304. */
  63305. joints: number[];
  63306. }
  63307. /**
  63308. * A texture and its sampler
  63309. */
  63310. interface ITexture extends IChildRootProperty {
  63311. /**
  63312. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  63313. */
  63314. sampler?: number;
  63315. /**
  63316. * The index of the image used by this texture
  63317. */
  63318. source: number;
  63319. }
  63320. /**
  63321. * Reference to a texture
  63322. */
  63323. interface ITextureInfo extends IProperty {
  63324. /**
  63325. * The index of the texture
  63326. */
  63327. index: number;
  63328. /**
  63329. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  63330. */
  63331. texCoord?: number;
  63332. }
  63333. /**
  63334. * The root object for a glTF asset
  63335. */
  63336. interface IGLTF extends IProperty {
  63337. /**
  63338. * An array of accessors. An accessor is a typed view into a bufferView
  63339. */
  63340. accessors?: IAccessor[];
  63341. /**
  63342. * An array of keyframe animations
  63343. */
  63344. animations?: IAnimation[];
  63345. /**
  63346. * Metadata about the glTF asset
  63347. */
  63348. asset: IAsset;
  63349. /**
  63350. * An array of buffers. A buffer points to binary geometry, animation, or skins
  63351. */
  63352. buffers?: IBuffer[];
  63353. /**
  63354. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  63355. */
  63356. bufferViews?: IBufferView[];
  63357. /**
  63358. * An array of cameras
  63359. */
  63360. cameras?: ICamera[];
  63361. /**
  63362. * Names of glTF extensions used somewhere in this asset
  63363. */
  63364. extensionsUsed?: string[];
  63365. /**
  63366. * Names of glTF extensions required to properly load this asset
  63367. */
  63368. extensionsRequired?: string[];
  63369. /**
  63370. * An array of images. An image defines data used to create a texture
  63371. */
  63372. images?: IImage[];
  63373. /**
  63374. * An array of materials. A material defines the appearance of a primitive
  63375. */
  63376. materials?: IMaterial[];
  63377. /**
  63378. * An array of meshes. A mesh is a set of primitives to be rendered
  63379. */
  63380. meshes?: IMesh[];
  63381. /**
  63382. * An array of nodes
  63383. */
  63384. nodes?: INode[];
  63385. /**
  63386. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  63387. */
  63388. samplers?: ISampler[];
  63389. /**
  63390. * The index of the default scene
  63391. */
  63392. scene?: number;
  63393. /**
  63394. * An array of scenes
  63395. */
  63396. scenes?: IScene[];
  63397. /**
  63398. * An array of skins. A skin is defined by joints and matrices
  63399. */
  63400. skins?: ISkin[];
  63401. /**
  63402. * An array of textures
  63403. */
  63404. textures?: ITexture[];
  63405. }
  63406. /**
  63407. * Interface for glTF validation results
  63408. */
  63409. interface IGLTFValidationResults {
  63410. info: {
  63411. generator: string;
  63412. hasAnimations: boolean;
  63413. hasDefaultScene: boolean;
  63414. hasMaterials: boolean;
  63415. hasMorphTargets: boolean;
  63416. hasSkins: boolean;
  63417. hasTextures: boolean;
  63418. maxAttributesUsed: number;
  63419. primitivesCount: number
  63420. };
  63421. issues: {
  63422. messages: Array<string>;
  63423. numErrors: number;
  63424. numHints: number;
  63425. numInfos: number;
  63426. numWarnings: number;
  63427. truncated: boolean
  63428. };
  63429. mimeType: string;
  63430. uri: string;
  63431. validatedAt: string;
  63432. validatorVersion: string;
  63433. }
  63434. /**
  63435. * Interface for glTF validation options
  63436. */
  63437. interface IGLTFValidationOptions {
  63438. uri?: string;
  63439. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63440. validateAccessorData?: boolean;
  63441. maxIssues?: number;
  63442. ignoredIssues?: Array<string>;
  63443. severityOverrides?: Object;
  63444. }
  63445. /**
  63446. * glTF validator object Tyyings
  63447. */
  63448. interface IGLTFValidatorTypings {
  63449. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63450. }
  63451. }
  63452. /**
  63453. * Interface for glTF validation results
  63454. */
  63455. interface IGLTFValidationResults {
  63456. info: {
  63457. generator: string;
  63458. hasAnimations: boolean;
  63459. hasDefaultScene: boolean;
  63460. hasMaterials: boolean;
  63461. hasMorphTargets: boolean;
  63462. hasSkins: boolean;
  63463. hasTextures: boolean;
  63464. maxAttributesUsed: number;
  63465. primitivesCount: number
  63466. };
  63467. issues: {
  63468. messages: Array<string>;
  63469. numErrors: number;
  63470. numHints: number;
  63471. numInfos: number;
  63472. numWarnings: number;
  63473. truncated: boolean
  63474. };
  63475. mimeType: string;
  63476. uri: string;
  63477. validatedAt: string;
  63478. validatorVersion: string;
  63479. }
  63480. /**
  63481. * Interface for glTF validation options
  63482. */
  63483. interface IGLTFValidationOptions {
  63484. uri?: string;
  63485. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63486. validateAccessorData?: boolean;
  63487. maxIssues?: number;
  63488. ignoredIssues?: Array<string>;
  63489. severityOverrides?: Object;
  63490. }
  63491. /**
  63492. * glTF validator object Tyyings
  63493. */
  63494. interface IGLTFValidatorTypings {
  63495. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63496. }
  63497. declare module BABYLON {
  63498. /** @hidden */
  63499. export var cellPixelShader: {
  63500. name: string;
  63501. shader: string;
  63502. };
  63503. }
  63504. declare module BABYLON {
  63505. /** @hidden */
  63506. export var cellVertexShader: {
  63507. name: string;
  63508. shader: string;
  63509. };
  63510. }
  63511. declare module BABYLON {
  63512. export class CellMaterial extends BABYLON.PushMaterial {
  63513. private _diffuseTexture;
  63514. diffuseTexture: BABYLON.BaseTexture;
  63515. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  63516. computeHighLevel: boolean;
  63517. private _disableLighting;
  63518. disableLighting: boolean;
  63519. private _maxSimultaneousLights;
  63520. maxSimultaneousLights: number;
  63521. private _renderId;
  63522. constructor(name: string, scene: BABYLON.Scene);
  63523. needAlphaBlending(): boolean;
  63524. needAlphaTesting(): boolean;
  63525. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63526. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63527. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63528. getAnimatables(): BABYLON.IAnimatable[];
  63529. getActiveTextures(): BABYLON.BaseTexture[];
  63530. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63531. dispose(forceDisposeEffect?: boolean): void;
  63532. getClassName(): string;
  63533. clone(name: string): CellMaterial;
  63534. serialize(): any;
  63535. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  63536. }
  63537. }
  63538. declare module BABYLON {
  63539. export class CustomShaderStructure {
  63540. FragmentStore: string;
  63541. VertexStore: string;
  63542. constructor();
  63543. }
  63544. export class ShaderSpecialParts {
  63545. constructor();
  63546. Fragment_Begin: string;
  63547. Fragment_Definitions: string;
  63548. Fragment_MainBegin: string;
  63549. Fragment_Custom_Diffuse: string;
  63550. Fragment_Before_Lights: string;
  63551. Fragment_Before_Fog: string;
  63552. Fragment_Custom_Alpha: string;
  63553. Fragment_Before_FragColor: string;
  63554. Vertex_Begin: string;
  63555. Vertex_Definitions: string;
  63556. Vertex_MainBegin: string;
  63557. Vertex_Before_PositionUpdated: string;
  63558. Vertex_Before_NormalUpdated: string;
  63559. Vertex_MainEnd: string;
  63560. }
  63561. export class CustomMaterial extends BABYLON.StandardMaterial {
  63562. static ShaderIndexer: number;
  63563. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63564. FragmentShader: string;
  63565. VertexShader: string;
  63566. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63567. ReviewUniform(name: string, arr: string[]): string[];
  63568. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  63569. constructor(name: string, scene: BABYLON.Scene);
  63570. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  63571. Fragment_Begin(shaderPart: string): CustomMaterial;
  63572. Fragment_Definitions(shaderPart: string): CustomMaterial;
  63573. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  63574. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  63575. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  63576. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  63577. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  63578. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  63579. Vertex_Begin(shaderPart: string): CustomMaterial;
  63580. Vertex_Definitions(shaderPart: string): CustomMaterial;
  63581. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  63582. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  63583. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  63584. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  63585. }
  63586. }
  63587. declare module BABYLON {
  63588. export class ShaderAlebdoParts {
  63589. constructor();
  63590. Fragment_Begin: string;
  63591. Fragment_Definitions: string;
  63592. Fragment_MainBegin: string;
  63593. Fragment_Custom_Albedo: string;
  63594. Fragment_Before_Lights: string;
  63595. Fragment_Before_Fog: string;
  63596. Fragment_Custom_Alpha: string;
  63597. Fragment_Before_FragColor: string;
  63598. Vertex_Begin: string;
  63599. Vertex_Definitions: string;
  63600. Vertex_MainBegin: string;
  63601. Vertex_Before_PositionUpdated: string;
  63602. Vertex_Before_NormalUpdated: string;
  63603. Vertex_MainEnd: string;
  63604. }
  63605. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  63606. static ShaderIndexer: number;
  63607. CustomParts: ShaderAlebdoParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63608. FragmentShader: string;
  63609. VertexShader: string;
  63610. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63611. ReviewUniform(name: string, arr: string[]): string[];
  63612. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  63613. constructor(name: string, scene: BABYLON.Scene);
  63614. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  63615. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  63616. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  63617. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  63618. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  63619. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  63620. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  63621. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  63622. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  63623. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  63624. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  63625. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  63626. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  63627. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  63628. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  63629. }
  63630. }
  63631. declare module BABYLON {
  63632. /** @hidden */
  63633. export var firePixelShader: {
  63634. name: string;
  63635. shader: string;
  63636. };
  63637. }
  63638. declare module BABYLON {
  63639. /** @hidden */
  63640. export var fireVertexShader: {
  63641. name: string;
  63642. shader: string;
  63643. };
  63644. }
  63645. declare module BABYLON {
  63646. export class FireMaterial extends BABYLON.PushMaterial {
  63647. private _diffuseTexture;
  63648. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63649. private _distortionTexture;
  63650. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63651. private _opacityTexture;
  63652. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63653. diffuseColor: BABYLON.Color3;
  63654. speed: number;
  63655. private _scaledDiffuse;
  63656. private _renderId;
  63657. private _lastTime;
  63658. constructor(name: string, scene: BABYLON.Scene);
  63659. needAlphaBlending(): boolean;
  63660. needAlphaTesting(): boolean;
  63661. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63662. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63663. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63664. getAnimatables(): BABYLON.IAnimatable[];
  63665. getActiveTextures(): BABYLON.BaseTexture[];
  63666. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63667. getClassName(): string;
  63668. dispose(forceDisposeEffect?: boolean): void;
  63669. clone(name: string): FireMaterial;
  63670. serialize(): any;
  63671. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  63672. }
  63673. }
  63674. declare module BABYLON {
  63675. /** @hidden */
  63676. export var furPixelShader: {
  63677. name: string;
  63678. shader: string;
  63679. };
  63680. }
  63681. declare module BABYLON {
  63682. /** @hidden */
  63683. export var furVertexShader: {
  63684. name: string;
  63685. shader: string;
  63686. };
  63687. }
  63688. declare module BABYLON {
  63689. export class FurMaterial extends BABYLON.PushMaterial {
  63690. private _diffuseTexture;
  63691. diffuseTexture: BABYLON.BaseTexture;
  63692. private _heightTexture;
  63693. heightTexture: BABYLON.BaseTexture;
  63694. diffuseColor: BABYLON.Color3;
  63695. furLength: number;
  63696. furAngle: number;
  63697. furColor: BABYLON.Color3;
  63698. furOffset: number;
  63699. furSpacing: number;
  63700. furGravity: BABYLON.Vector3;
  63701. furSpeed: number;
  63702. furDensity: number;
  63703. furOcclusion: number;
  63704. furTexture: BABYLON.DynamicTexture;
  63705. private _disableLighting;
  63706. disableLighting: boolean;
  63707. private _maxSimultaneousLights;
  63708. maxSimultaneousLights: number;
  63709. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  63710. private _renderId;
  63711. private _furTime;
  63712. constructor(name: string, scene: BABYLON.Scene);
  63713. furTime: number;
  63714. needAlphaBlending(): boolean;
  63715. needAlphaTesting(): boolean;
  63716. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63717. updateFur(): void;
  63718. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63719. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63720. getAnimatables(): BABYLON.IAnimatable[];
  63721. getActiveTextures(): BABYLON.BaseTexture[];
  63722. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63723. dispose(forceDisposeEffect?: boolean): void;
  63724. clone(name: string): FurMaterial;
  63725. serialize(): any;
  63726. getClassName(): string;
  63727. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  63728. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  63729. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  63730. }
  63731. }
  63732. declare module BABYLON {
  63733. /** @hidden */
  63734. export var gradientPixelShader: {
  63735. name: string;
  63736. shader: string;
  63737. };
  63738. }
  63739. declare module BABYLON {
  63740. /** @hidden */
  63741. export var gradientVertexShader: {
  63742. name: string;
  63743. shader: string;
  63744. };
  63745. }
  63746. declare module BABYLON {
  63747. export class GradientMaterial extends BABYLON.PushMaterial {
  63748. private _maxSimultaneousLights;
  63749. maxSimultaneousLights: number;
  63750. topColor: BABYLON.Color3;
  63751. topColorAlpha: number;
  63752. bottomColor: BABYLON.Color3;
  63753. bottomColorAlpha: number;
  63754. offset: number;
  63755. scale: number;
  63756. smoothness: number;
  63757. private _disableLighting;
  63758. disableLighting: boolean;
  63759. private _renderId;
  63760. constructor(name: string, scene: BABYLON.Scene);
  63761. needAlphaBlending(): boolean;
  63762. needAlphaTesting(): boolean;
  63763. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63764. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63765. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63766. getAnimatables(): BABYLON.IAnimatable[];
  63767. dispose(forceDisposeEffect?: boolean): void;
  63768. clone(name: string): GradientMaterial;
  63769. serialize(): any;
  63770. getClassName(): string;
  63771. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  63772. }
  63773. }
  63774. declare module BABYLON {
  63775. /** @hidden */
  63776. export var gridPixelShader: {
  63777. name: string;
  63778. shader: string;
  63779. };
  63780. }
  63781. declare module BABYLON {
  63782. /** @hidden */
  63783. export var gridVertexShader: {
  63784. name: string;
  63785. shader: string;
  63786. };
  63787. }
  63788. declare module BABYLON {
  63789. /**
  63790. * The grid materials allows you to wrap any shape with a grid.
  63791. * Colors are customizable.
  63792. */
  63793. export class GridMaterial extends BABYLON.PushMaterial {
  63794. /**
  63795. * Main color of the grid (e.g. between lines)
  63796. */
  63797. mainColor: BABYLON.Color3;
  63798. /**
  63799. * Color of the grid lines.
  63800. */
  63801. lineColor: BABYLON.Color3;
  63802. /**
  63803. * The scale of the grid compared to unit.
  63804. */
  63805. gridRatio: number;
  63806. /**
  63807. * Allows setting an offset for the grid lines.
  63808. */
  63809. gridOffset: BABYLON.Vector3;
  63810. /**
  63811. * The frequency of thicker lines.
  63812. */
  63813. majorUnitFrequency: number;
  63814. /**
  63815. * The visibility of minor units in the grid.
  63816. */
  63817. minorUnitVisibility: number;
  63818. /**
  63819. * The grid opacity outside of the lines.
  63820. */
  63821. opacity: number;
  63822. /**
  63823. * Determine RBG output is premultiplied by alpha value.
  63824. */
  63825. preMultiplyAlpha: boolean;
  63826. private _opacityTexture;
  63827. opacityTexture: BABYLON.BaseTexture;
  63828. private _gridControl;
  63829. private _renderId;
  63830. /**
  63831. * constructor
  63832. * @param name The name given to the material in order to identify it afterwards.
  63833. * @param scene The scene the material is used in.
  63834. */
  63835. constructor(name: string, scene: BABYLON.Scene);
  63836. /**
  63837. * Returns wehter or not the grid requires alpha blending.
  63838. */
  63839. needAlphaBlending(): boolean;
  63840. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  63841. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63842. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63843. /**
  63844. * Dispose the material and its associated resources.
  63845. * @param forceDisposeEffect will also dispose the used effect when true
  63846. */
  63847. dispose(forceDisposeEffect?: boolean): void;
  63848. clone(name: string): GridMaterial;
  63849. serialize(): any;
  63850. getClassName(): string;
  63851. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  63852. }
  63853. }
  63854. declare module BABYLON {
  63855. /** @hidden */
  63856. export var lavaPixelShader: {
  63857. name: string;
  63858. shader: string;
  63859. };
  63860. }
  63861. declare module BABYLON {
  63862. /** @hidden */
  63863. export var lavaVertexShader: {
  63864. name: string;
  63865. shader: string;
  63866. };
  63867. }
  63868. declare module BABYLON {
  63869. export class LavaMaterial extends BABYLON.PushMaterial {
  63870. private _diffuseTexture;
  63871. diffuseTexture: BABYLON.BaseTexture;
  63872. noiseTexture: BABYLON.BaseTexture;
  63873. fogColor: BABYLON.Color3;
  63874. speed: number;
  63875. movingSpeed: number;
  63876. lowFrequencySpeed: number;
  63877. fogDensity: number;
  63878. private _lastTime;
  63879. diffuseColor: BABYLON.Color3;
  63880. private _disableLighting;
  63881. disableLighting: boolean;
  63882. private _unlit;
  63883. unlit: boolean;
  63884. private _maxSimultaneousLights;
  63885. maxSimultaneousLights: number;
  63886. private _scaledDiffuse;
  63887. private _renderId;
  63888. constructor(name: string, scene: BABYLON.Scene);
  63889. needAlphaBlending(): boolean;
  63890. needAlphaTesting(): boolean;
  63891. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63892. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63893. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63894. getAnimatables(): BABYLON.IAnimatable[];
  63895. getActiveTextures(): BABYLON.BaseTexture[];
  63896. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63897. dispose(forceDisposeEffect?: boolean): void;
  63898. clone(name: string): LavaMaterial;
  63899. serialize(): any;
  63900. getClassName(): string;
  63901. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  63902. }
  63903. }
  63904. declare module BABYLON {
  63905. /** @hidden */
  63906. export var mixPixelShader: {
  63907. name: string;
  63908. shader: string;
  63909. };
  63910. }
  63911. declare module BABYLON {
  63912. /** @hidden */
  63913. export var mixVertexShader: {
  63914. name: string;
  63915. shader: string;
  63916. };
  63917. }
  63918. declare module BABYLON {
  63919. export class MixMaterial extends BABYLON.PushMaterial {
  63920. /**
  63921. * Mix textures
  63922. */
  63923. private _mixTexture1;
  63924. mixTexture1: BABYLON.BaseTexture;
  63925. private _mixTexture2;
  63926. mixTexture2: BABYLON.BaseTexture;
  63927. /**
  63928. * Diffuse textures
  63929. */
  63930. private _diffuseTexture1;
  63931. diffuseTexture1: BABYLON.Texture;
  63932. private _diffuseTexture2;
  63933. diffuseTexture2: BABYLON.Texture;
  63934. private _diffuseTexture3;
  63935. diffuseTexture3: BABYLON.Texture;
  63936. private _diffuseTexture4;
  63937. diffuseTexture4: BABYLON.Texture;
  63938. private _diffuseTexture5;
  63939. diffuseTexture5: BABYLON.Texture;
  63940. private _diffuseTexture6;
  63941. diffuseTexture6: BABYLON.Texture;
  63942. private _diffuseTexture7;
  63943. diffuseTexture7: BABYLON.Texture;
  63944. private _diffuseTexture8;
  63945. diffuseTexture8: BABYLON.Texture;
  63946. /**
  63947. * Uniforms
  63948. */
  63949. diffuseColor: BABYLON.Color3;
  63950. specularColor: BABYLON.Color3;
  63951. specularPower: number;
  63952. private _disableLighting;
  63953. disableLighting: boolean;
  63954. private _maxSimultaneousLights;
  63955. maxSimultaneousLights: number;
  63956. private _renderId;
  63957. constructor(name: string, scene: BABYLON.Scene);
  63958. needAlphaBlending(): boolean;
  63959. needAlphaTesting(): boolean;
  63960. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63961. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63962. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63963. getAnimatables(): BABYLON.IAnimatable[];
  63964. getActiveTextures(): BABYLON.BaseTexture[];
  63965. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63966. dispose(forceDisposeEffect?: boolean): void;
  63967. clone(name: string): MixMaterial;
  63968. serialize(): any;
  63969. getClassName(): string;
  63970. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  63971. }
  63972. }
  63973. declare module BABYLON {
  63974. /** @hidden */
  63975. export var normalPixelShader: {
  63976. name: string;
  63977. shader: string;
  63978. };
  63979. }
  63980. declare module BABYLON {
  63981. /** @hidden */
  63982. export var normalVertexShader: {
  63983. name: string;
  63984. shader: string;
  63985. };
  63986. }
  63987. declare module BABYLON {
  63988. export class NormalMaterial extends BABYLON.PushMaterial {
  63989. private _diffuseTexture;
  63990. diffuseTexture: BABYLON.BaseTexture;
  63991. diffuseColor: BABYLON.Color3;
  63992. private _disableLighting;
  63993. disableLighting: boolean;
  63994. private _maxSimultaneousLights;
  63995. maxSimultaneousLights: number;
  63996. private _renderId;
  63997. constructor(name: string, scene: BABYLON.Scene);
  63998. needAlphaBlending(): boolean;
  63999. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  64000. needAlphaTesting(): boolean;
  64001. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64002. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64003. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64004. getAnimatables(): BABYLON.IAnimatable[];
  64005. getActiveTextures(): BABYLON.BaseTexture[];
  64006. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64007. dispose(forceDisposeEffect?: boolean): void;
  64008. clone(name: string): NormalMaterial;
  64009. serialize(): any;
  64010. getClassName(): string;
  64011. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  64012. }
  64013. }
  64014. declare module BABYLON {
  64015. /** @hidden */
  64016. export var shadowOnlyPixelShader: {
  64017. name: string;
  64018. shader: string;
  64019. };
  64020. }
  64021. declare module BABYLON {
  64022. /** @hidden */
  64023. export var shadowOnlyVertexShader: {
  64024. name: string;
  64025. shader: string;
  64026. };
  64027. }
  64028. declare module BABYLON {
  64029. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  64030. private _renderId;
  64031. private _activeLight;
  64032. constructor(name: string, scene: BABYLON.Scene);
  64033. shadowColor: BABYLON.Color3;
  64034. needAlphaBlending(): boolean;
  64035. needAlphaTesting(): boolean;
  64036. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64037. activeLight: BABYLON.IShadowLight;
  64038. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64039. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64040. clone(name: string): ShadowOnlyMaterial;
  64041. serialize(): any;
  64042. getClassName(): string;
  64043. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  64044. }
  64045. }
  64046. declare module BABYLON {
  64047. /** @hidden */
  64048. export var simplePixelShader: {
  64049. name: string;
  64050. shader: string;
  64051. };
  64052. }
  64053. declare module BABYLON {
  64054. /** @hidden */
  64055. export var simpleVertexShader: {
  64056. name: string;
  64057. shader: string;
  64058. };
  64059. }
  64060. declare module BABYLON {
  64061. export class SimpleMaterial extends BABYLON.PushMaterial {
  64062. private _diffuseTexture;
  64063. diffuseTexture: BABYLON.BaseTexture;
  64064. diffuseColor: BABYLON.Color3;
  64065. private _disableLighting;
  64066. disableLighting: boolean;
  64067. private _maxSimultaneousLights;
  64068. maxSimultaneousLights: number;
  64069. private _renderId;
  64070. constructor(name: string, scene: BABYLON.Scene);
  64071. needAlphaBlending(): boolean;
  64072. needAlphaTesting(): boolean;
  64073. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64074. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64075. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64076. getAnimatables(): BABYLON.IAnimatable[];
  64077. getActiveTextures(): BABYLON.BaseTexture[];
  64078. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64079. dispose(forceDisposeEffect?: boolean): void;
  64080. clone(name: string): SimpleMaterial;
  64081. serialize(): any;
  64082. getClassName(): string;
  64083. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  64084. }
  64085. }
  64086. declare module BABYLON {
  64087. /** @hidden */
  64088. export var skyPixelShader: {
  64089. name: string;
  64090. shader: string;
  64091. };
  64092. }
  64093. declare module BABYLON {
  64094. /** @hidden */
  64095. export var skyVertexShader: {
  64096. name: string;
  64097. shader: string;
  64098. };
  64099. }
  64100. declare module BABYLON {
  64101. /**
  64102. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  64103. * @see https://doc.babylonjs.com/extensions/sky
  64104. */
  64105. export class SkyMaterial extends BABYLON.PushMaterial {
  64106. /**
  64107. * Defines the overall luminance of sky in interval ]0, 1[.
  64108. */
  64109. luminance: number;
  64110. /**
  64111. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  64112. */
  64113. turbidity: number;
  64114. /**
  64115. * Defines the sky appearance (light intensity).
  64116. */
  64117. rayleigh: number;
  64118. /**
  64119. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  64120. */
  64121. mieCoefficient: number;
  64122. /**
  64123. * Defines the amount of haze particles following the Mie scattering theory.
  64124. */
  64125. mieDirectionalG: number;
  64126. /**
  64127. * Defines the distance of the sun according to the active scene camera.
  64128. */
  64129. distance: number;
  64130. /**
  64131. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  64132. * "inclined".
  64133. */
  64134. inclination: number;
  64135. /**
  64136. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  64137. * an object direction and a reference direction.
  64138. */
  64139. azimuth: number;
  64140. /**
  64141. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  64142. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  64143. */
  64144. sunPosition: BABYLON.Vector3;
  64145. /**
  64146. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  64147. * .sunPosition property.
  64148. */
  64149. useSunPosition: boolean;
  64150. /**
  64151. * Defines an offset vector used to get a horizon offset.
  64152. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  64153. */
  64154. cameraOffset: BABYLON.Vector3;
  64155. private _cameraPosition;
  64156. private _renderId;
  64157. /**
  64158. * Instantiates a new sky material.
  64159. * This material allows to create dynamic and texture free
  64160. * effects for skyboxes by taking care of the atmosphere state.
  64161. * @see https://doc.babylonjs.com/extensions/sky
  64162. * @param name Define the name of the material in the scene
  64163. * @param scene Define the scene the material belong to
  64164. */
  64165. constructor(name: string, scene: BABYLON.Scene);
  64166. /**
  64167. * Specifies if the material will require alpha blending
  64168. * @returns a boolean specifying if alpha blending is needed
  64169. */
  64170. needAlphaBlending(): boolean;
  64171. /**
  64172. * Specifies if this material should be rendered in alpha test mode
  64173. * @returns false as the sky material doesn't need alpha testing.
  64174. */
  64175. needAlphaTesting(): boolean;
  64176. /**
  64177. * Get the texture used for alpha test purpose.
  64178. * @returns null as the sky material has no texture.
  64179. */
  64180. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64181. /**
  64182. * Get if the submesh is ready to be used and all its information available.
  64183. * Child classes can use it to update shaders
  64184. * @param mesh defines the mesh to check
  64185. * @param subMesh defines which submesh to check
  64186. * @param useInstances specifies that instances should be used
  64187. * @returns a boolean indicating that the submesh is ready or not
  64188. */
  64189. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64190. /**
  64191. * Binds the submesh to this material by preparing the effect and shader to draw
  64192. * @param world defines the world transformation matrix
  64193. * @param mesh defines the mesh containing the submesh
  64194. * @param subMesh defines the submesh to bind the material to
  64195. */
  64196. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64197. /**
  64198. * Get the list of animatables in the material.
  64199. * @returns the list of animatables object used in the material
  64200. */
  64201. getAnimatables(): BABYLON.IAnimatable[];
  64202. /**
  64203. * Disposes the material
  64204. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64205. */
  64206. dispose(forceDisposeEffect?: boolean): void;
  64207. /**
  64208. * Makes a duplicate of the material, and gives it a new name
  64209. * @param name defines the new name for the duplicated material
  64210. * @returns the cloned material
  64211. */
  64212. clone(name: string): SkyMaterial;
  64213. /**
  64214. * Serializes this material in a JSON representation
  64215. * @returns the serialized material object
  64216. */
  64217. serialize(): any;
  64218. /**
  64219. * Gets the current class name of the material e.g. "SkyMaterial"
  64220. * Mainly use in serialization.
  64221. * @returns the class name
  64222. */
  64223. getClassName(): string;
  64224. /**
  64225. * Creates a sky material from parsed material data
  64226. * @param source defines the JSON representation of the material
  64227. * @param scene defines the hosting scene
  64228. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64229. * @returns a new sky material
  64230. */
  64231. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  64232. }
  64233. }
  64234. declare module BABYLON {
  64235. /** @hidden */
  64236. export var terrainPixelShader: {
  64237. name: string;
  64238. shader: string;
  64239. };
  64240. }
  64241. declare module BABYLON {
  64242. /** @hidden */
  64243. export var terrainVertexShader: {
  64244. name: string;
  64245. shader: string;
  64246. };
  64247. }
  64248. declare module BABYLON {
  64249. export class TerrainMaterial extends BABYLON.PushMaterial {
  64250. private _mixTexture;
  64251. mixTexture: BABYLON.BaseTexture;
  64252. private _diffuseTexture1;
  64253. diffuseTexture1: BABYLON.Texture;
  64254. private _diffuseTexture2;
  64255. diffuseTexture2: BABYLON.Texture;
  64256. private _diffuseTexture3;
  64257. diffuseTexture3: BABYLON.Texture;
  64258. private _bumpTexture1;
  64259. bumpTexture1: BABYLON.Texture;
  64260. private _bumpTexture2;
  64261. bumpTexture2: BABYLON.Texture;
  64262. private _bumpTexture3;
  64263. bumpTexture3: BABYLON.Texture;
  64264. diffuseColor: BABYLON.Color3;
  64265. specularColor: BABYLON.Color3;
  64266. specularPower: number;
  64267. private _disableLighting;
  64268. disableLighting: boolean;
  64269. private _maxSimultaneousLights;
  64270. maxSimultaneousLights: number;
  64271. private _renderId;
  64272. constructor(name: string, scene: BABYLON.Scene);
  64273. needAlphaBlending(): boolean;
  64274. needAlphaTesting(): boolean;
  64275. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64276. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64277. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64278. getAnimatables(): BABYLON.IAnimatable[];
  64279. getActiveTextures(): BABYLON.BaseTexture[];
  64280. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64281. dispose(forceDisposeEffect?: boolean): void;
  64282. clone(name: string): TerrainMaterial;
  64283. serialize(): any;
  64284. getClassName(): string;
  64285. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  64286. }
  64287. }
  64288. declare module BABYLON {
  64289. /** @hidden */
  64290. export var triplanarPixelShader: {
  64291. name: string;
  64292. shader: string;
  64293. };
  64294. }
  64295. declare module BABYLON {
  64296. /** @hidden */
  64297. export var triplanarVertexShader: {
  64298. name: string;
  64299. shader: string;
  64300. };
  64301. }
  64302. declare module BABYLON {
  64303. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  64304. mixTexture: BABYLON.BaseTexture;
  64305. private _diffuseTextureX;
  64306. diffuseTextureX: BABYLON.BaseTexture;
  64307. private _diffuseTextureY;
  64308. diffuseTextureY: BABYLON.BaseTexture;
  64309. private _diffuseTextureZ;
  64310. diffuseTextureZ: BABYLON.BaseTexture;
  64311. private _normalTextureX;
  64312. normalTextureX: BABYLON.BaseTexture;
  64313. private _normalTextureY;
  64314. normalTextureY: BABYLON.BaseTexture;
  64315. private _normalTextureZ;
  64316. normalTextureZ: BABYLON.BaseTexture;
  64317. tileSize: number;
  64318. diffuseColor: BABYLON.Color3;
  64319. specularColor: BABYLON.Color3;
  64320. specularPower: number;
  64321. private _disableLighting;
  64322. disableLighting: boolean;
  64323. private _maxSimultaneousLights;
  64324. maxSimultaneousLights: number;
  64325. private _renderId;
  64326. constructor(name: string, scene: BABYLON.Scene);
  64327. needAlphaBlending(): boolean;
  64328. needAlphaTesting(): boolean;
  64329. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64330. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64331. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64332. getAnimatables(): BABYLON.IAnimatable[];
  64333. getActiveTextures(): BABYLON.BaseTexture[];
  64334. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64335. dispose(forceDisposeEffect?: boolean): void;
  64336. clone(name: string): TriPlanarMaterial;
  64337. serialize(): any;
  64338. getClassName(): string;
  64339. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  64340. }
  64341. }
  64342. declare module BABYLON {
  64343. /** @hidden */
  64344. export var waterPixelShader: {
  64345. name: string;
  64346. shader: string;
  64347. };
  64348. }
  64349. declare module BABYLON {
  64350. /** @hidden */
  64351. export var waterVertexShader: {
  64352. name: string;
  64353. shader: string;
  64354. };
  64355. }
  64356. declare module BABYLON {
  64357. export class WaterMaterial extends BABYLON.PushMaterial {
  64358. renderTargetSize: BABYLON.Vector2;
  64359. private _bumpTexture;
  64360. bumpTexture: BABYLON.BaseTexture;
  64361. diffuseColor: BABYLON.Color3;
  64362. specularColor: BABYLON.Color3;
  64363. specularPower: number;
  64364. private _disableLighting;
  64365. disableLighting: boolean;
  64366. private _maxSimultaneousLights;
  64367. maxSimultaneousLights: number;
  64368. /**
  64369. * @param {number}: Represents the wind force
  64370. */
  64371. windForce: number;
  64372. /**
  64373. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  64374. */
  64375. windDirection: BABYLON.Vector2;
  64376. /**
  64377. * @param {number}: Wave height, represents the height of the waves
  64378. */
  64379. waveHeight: number;
  64380. /**
  64381. * @param {number}: Bump height, represents the bump height related to the bump map
  64382. */
  64383. bumpHeight: number;
  64384. /**
  64385. * @param {boolean}: Add a smaller moving bump to less steady waves.
  64386. */
  64387. private _bumpSuperimpose;
  64388. bumpSuperimpose: boolean;
  64389. /**
  64390. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  64391. */
  64392. private _fresnelSeparate;
  64393. fresnelSeparate: boolean;
  64394. /**
  64395. * @param {boolean}: bump Waves modify the reflection.
  64396. */
  64397. private _bumpAffectsReflection;
  64398. bumpAffectsReflection: boolean;
  64399. /**
  64400. * @param {number}: The water color blended with the refraction (near)
  64401. */
  64402. waterColor: BABYLON.Color3;
  64403. /**
  64404. * @param {number}: The blend factor related to the water color
  64405. */
  64406. colorBlendFactor: number;
  64407. /**
  64408. * @param {number}: The water color blended with the reflection (far)
  64409. */
  64410. waterColor2: BABYLON.Color3;
  64411. /**
  64412. * @param {number}: The blend factor related to the water color (reflection, far)
  64413. */
  64414. colorBlendFactor2: number;
  64415. /**
  64416. * @param {number}: Represents the maximum length of a wave
  64417. */
  64418. waveLength: number;
  64419. /**
  64420. * @param {number}: Defines the waves speed
  64421. */
  64422. waveSpeed: number;
  64423. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  64424. private _mesh;
  64425. private _refractionRTT;
  64426. private _reflectionRTT;
  64427. private _reflectionTransform;
  64428. private _lastTime;
  64429. private _lastDeltaTime;
  64430. private _renderId;
  64431. private _useLogarithmicDepth;
  64432. private _waitingRenderList;
  64433. /**
  64434. * Gets a boolean indicating that current material needs to register RTT
  64435. */
  64436. readonly hasRenderTargetTextures: boolean;
  64437. /**
  64438. * Constructor
  64439. */
  64440. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  64441. useLogarithmicDepth: boolean;
  64442. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64443. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64444. addToRenderList(node: any): void;
  64445. enableRenderTargets(enable: boolean): void;
  64446. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  64447. readonly renderTargetsEnabled: boolean;
  64448. needAlphaBlending(): boolean;
  64449. needAlphaTesting(): boolean;
  64450. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64451. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64452. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64453. private _createRenderTargets;
  64454. getAnimatables(): BABYLON.IAnimatable[];
  64455. getActiveTextures(): BABYLON.BaseTexture[];
  64456. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64457. dispose(forceDisposeEffect?: boolean): void;
  64458. clone(name: string): WaterMaterial;
  64459. serialize(): any;
  64460. getClassName(): string;
  64461. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  64462. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  64463. }
  64464. }
  64465. declare module BABYLON {
  64466. /** @hidden */
  64467. export var asciiartPixelShader: {
  64468. name: string;
  64469. shader: string;
  64470. };
  64471. }
  64472. declare module BABYLON {
  64473. /**
  64474. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  64475. *
  64476. * It basically takes care rendering the font front the given font size to a texture.
  64477. * This is used later on in the postprocess.
  64478. */
  64479. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  64480. private _font;
  64481. private _text;
  64482. private _charSize;
  64483. /**
  64484. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64485. */
  64486. readonly charSize: number;
  64487. /**
  64488. * Create a new instance of the Ascii Art FontTexture class
  64489. * @param name the name of the texture
  64490. * @param font the font to use, use the W3C CSS notation
  64491. * @param text the caracter set to use in the rendering.
  64492. * @param scene the scene that owns the texture
  64493. */
  64494. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64495. /**
  64496. * Gets the max char width of a font.
  64497. * @param font the font to use, use the W3C CSS notation
  64498. * @return the max char width
  64499. */
  64500. private getFontWidth;
  64501. /**
  64502. * Gets the max char height of a font.
  64503. * @param font the font to use, use the W3C CSS notation
  64504. * @return the max char height
  64505. */
  64506. private getFontHeight;
  64507. /**
  64508. * Clones the current AsciiArtTexture.
  64509. * @return the clone of the texture.
  64510. */
  64511. clone(): AsciiArtFontTexture;
  64512. /**
  64513. * Parses a json object representing the texture and returns an instance of it.
  64514. * @param source the source JSON representation
  64515. * @param scene the scene to create the texture for
  64516. * @return the parsed texture
  64517. */
  64518. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  64519. }
  64520. /**
  64521. * Option available in the Ascii Art Post Process.
  64522. */
  64523. export interface IAsciiArtPostProcessOptions {
  64524. /**
  64525. * The font to use following the w3c font definition.
  64526. */
  64527. font?: string;
  64528. /**
  64529. * The character set to use in the postprocess.
  64530. */
  64531. characterSet?: string;
  64532. /**
  64533. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64534. * This number is defined between 0 and 1;
  64535. */
  64536. mixToTile?: number;
  64537. /**
  64538. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64539. * This number is defined between 0 and 1;
  64540. */
  64541. mixToNormal?: number;
  64542. }
  64543. /**
  64544. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  64545. *
  64546. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64547. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  64548. */
  64549. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  64550. /**
  64551. * The font texture used to render the char in the post process.
  64552. */
  64553. private _asciiArtFontTexture;
  64554. /**
  64555. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64556. * This number is defined between 0 and 1;
  64557. */
  64558. mixToTile: number;
  64559. /**
  64560. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64561. * This number is defined between 0 and 1;
  64562. */
  64563. mixToNormal: number;
  64564. /**
  64565. * Instantiates a new Ascii Art Post Process.
  64566. * @param name the name to give to the postprocess
  64567. * @camera the camera to apply the post process to.
  64568. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  64569. */
  64570. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  64571. }
  64572. }
  64573. declare module BABYLON {
  64574. /** @hidden */
  64575. export var digitalrainPixelShader: {
  64576. name: string;
  64577. shader: string;
  64578. };
  64579. }
  64580. declare module BABYLON {
  64581. /**
  64582. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  64583. *
  64584. * It basically takes care rendering the font front the given font size to a texture.
  64585. * This is used later on in the postprocess.
  64586. */
  64587. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  64588. private _font;
  64589. private _text;
  64590. private _charSize;
  64591. /**
  64592. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64593. */
  64594. readonly charSize: number;
  64595. /**
  64596. * Create a new instance of the Digital Rain FontTexture class
  64597. * @param name the name of the texture
  64598. * @param font the font to use, use the W3C CSS notation
  64599. * @param text the caracter set to use in the rendering.
  64600. * @param scene the scene that owns the texture
  64601. */
  64602. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64603. /**
  64604. * Gets the max char width of a font.
  64605. * @param font the font to use, use the W3C CSS notation
  64606. * @return the max char width
  64607. */
  64608. private getFontWidth;
  64609. /**
  64610. * Gets the max char height of a font.
  64611. * @param font the font to use, use the W3C CSS notation
  64612. * @return the max char height
  64613. */
  64614. private getFontHeight;
  64615. /**
  64616. * Clones the current DigitalRainFontTexture.
  64617. * @return the clone of the texture.
  64618. */
  64619. clone(): DigitalRainFontTexture;
  64620. /**
  64621. * Parses a json object representing the texture and returns an instance of it.
  64622. * @param source the source JSON representation
  64623. * @param scene the scene to create the texture for
  64624. * @return the parsed texture
  64625. */
  64626. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  64627. }
  64628. /**
  64629. * Option available in the Digital Rain Post Process.
  64630. */
  64631. export interface IDigitalRainPostProcessOptions {
  64632. /**
  64633. * The font to use following the w3c font definition.
  64634. */
  64635. font?: string;
  64636. /**
  64637. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64638. * This number is defined between 0 and 1;
  64639. */
  64640. mixToTile?: number;
  64641. /**
  64642. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64643. * This number is defined between 0 and 1;
  64644. */
  64645. mixToNormal?: number;
  64646. }
  64647. /**
  64648. * DigitalRainPostProcess helps rendering everithing in digital rain.
  64649. *
  64650. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64651. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  64652. */
  64653. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  64654. /**
  64655. * The font texture used to render the char in the post process.
  64656. */
  64657. private _digitalRainFontTexture;
  64658. /**
  64659. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64660. * This number is defined between 0 and 1;
  64661. */
  64662. mixToTile: number;
  64663. /**
  64664. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64665. * This number is defined between 0 and 1;
  64666. */
  64667. mixToNormal: number;
  64668. /**
  64669. * Instantiates a new Digital Rain Post Process.
  64670. * @param name the name to give to the postprocess
  64671. * @camera the camera to apply the post process to.
  64672. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  64673. */
  64674. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  64675. }
  64676. }
  64677. declare module BABYLON {
  64678. /** @hidden */
  64679. export var oceanPostProcessPixelShader: {
  64680. name: string;
  64681. shader: string;
  64682. };
  64683. }
  64684. declare module BABYLON {
  64685. /**
  64686. * Option available in the Ocean Post Process.
  64687. */
  64688. export interface IOceanPostProcessOptions {
  64689. /**
  64690. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64691. */
  64692. reflectionSize?: number | {
  64693. width: number;
  64694. height: number;
  64695. } | {
  64696. ratio: number;
  64697. };
  64698. /**
  64699. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64700. */
  64701. refractionSize?: number | {
  64702. width: number;
  64703. height: number;
  64704. } | {
  64705. ratio: number;
  64706. };
  64707. }
  64708. /**
  64709. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  64710. *
  64711. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64712. * Example usage:
  64713. * var pp = new OceanPostProcess("myOcean", camera);
  64714. * pp.reflectionEnabled = true;
  64715. * pp.refractionEnabled = true;
  64716. */
  64717. export class OceanPostProcess extends BABYLON.PostProcess {
  64718. /**
  64719. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  64720. */
  64721. /**
  64722. * Sets weither or not the real-time reflection is enabled on the ocean.
  64723. * Is set to true, the reflection mirror texture will be used as reflection texture.
  64724. */
  64725. reflectionEnabled: boolean;
  64726. /**
  64727. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  64728. */
  64729. /**
  64730. * Sets weither or not the real-time refraction is enabled on the ocean.
  64731. * Is set to true, the refraction render target texture will be used as refraction texture.
  64732. */
  64733. refractionEnabled: boolean;
  64734. /**
  64735. * Gets wether or not the post-processes is supported by the running hardware.
  64736. * This requires draw buffer supports.
  64737. */
  64738. readonly isSupported: boolean;
  64739. /**
  64740. * This is the reflection mirror texture used to display reflections on the ocean.
  64741. * By default, render list is empty.
  64742. */
  64743. reflectionTexture: BABYLON.MirrorTexture;
  64744. /**
  64745. * This is the refraction render target texture used to display refraction on the ocean.
  64746. * By default, render list is empty.
  64747. */
  64748. refractionTexture: BABYLON.RenderTargetTexture;
  64749. private _time;
  64750. private _cameraRotation;
  64751. private _cameraViewMatrix;
  64752. private _reflectionEnabled;
  64753. private _refractionEnabled;
  64754. private _geometryRenderer;
  64755. /**
  64756. * Instantiates a new Ocean Post Process.
  64757. * @param name the name to give to the postprocess.
  64758. * @camera the camera to apply the post process to.
  64759. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  64760. */
  64761. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  64762. /**
  64763. * Returns the appropriate defines according to the current configuration.
  64764. */
  64765. private _getDefines;
  64766. /**
  64767. * Computes the current camera rotation as the shader requires a camera rotation.
  64768. */
  64769. private _computeCameraRotation;
  64770. }
  64771. }
  64772. declare module BABYLON {
  64773. /** @hidden */
  64774. export var brickProceduralTexturePixelShader: {
  64775. name: string;
  64776. shader: string;
  64777. };
  64778. }
  64779. declare module BABYLON {
  64780. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  64781. private _numberOfBricksHeight;
  64782. private _numberOfBricksWidth;
  64783. private _jointColor;
  64784. private _brickColor;
  64785. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64786. updateShaderUniforms(): void;
  64787. numberOfBricksHeight: number;
  64788. numberOfBricksWidth: number;
  64789. jointColor: BABYLON.Color3;
  64790. brickColor: BABYLON.Color3;
  64791. /**
  64792. * Serializes this brick procedural texture
  64793. * @returns a serialized brick procedural texture object
  64794. */
  64795. serialize(): any;
  64796. /**
  64797. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  64798. * @param parsedTexture defines parsed texture data
  64799. * @param scene defines the current scene
  64800. * @param rootUrl defines the root URL containing brick procedural texture information
  64801. * @returns a parsed Brick Procedural BABYLON.Texture
  64802. */
  64803. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  64804. }
  64805. }
  64806. declare module BABYLON {
  64807. /** @hidden */
  64808. export var cloudProceduralTexturePixelShader: {
  64809. name: string;
  64810. shader: string;
  64811. };
  64812. }
  64813. declare module BABYLON {
  64814. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  64815. private _skyColor;
  64816. private _cloudColor;
  64817. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64818. updateShaderUniforms(): void;
  64819. skyColor: BABYLON.Color4;
  64820. cloudColor: BABYLON.Color4;
  64821. /**
  64822. * Serializes this cloud procedural texture
  64823. * @returns a serialized cloud procedural texture object
  64824. */
  64825. serialize(): any;
  64826. /**
  64827. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  64828. * @param parsedTexture defines parsed texture data
  64829. * @param scene defines the current scene
  64830. * @param rootUrl defines the root URL containing cloud procedural texture information
  64831. * @returns a parsed Cloud Procedural BABYLON.Texture
  64832. */
  64833. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  64834. }
  64835. }
  64836. declare module BABYLON {
  64837. /** @hidden */
  64838. export var fireProceduralTexturePixelShader: {
  64839. name: string;
  64840. shader: string;
  64841. };
  64842. }
  64843. declare module BABYLON {
  64844. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  64845. private _time;
  64846. private _speed;
  64847. private _autoGenerateTime;
  64848. private _fireColors;
  64849. private _alphaThreshold;
  64850. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64851. updateShaderUniforms(): void;
  64852. render(useCameraPostProcess?: boolean): void;
  64853. static readonly PurpleFireColors: BABYLON.Color3[];
  64854. static readonly GreenFireColors: BABYLON.Color3[];
  64855. static readonly RedFireColors: BABYLON.Color3[];
  64856. static readonly BlueFireColors: BABYLON.Color3[];
  64857. autoGenerateTime: boolean;
  64858. fireColors: BABYLON.Color3[];
  64859. time: number;
  64860. speed: BABYLON.Vector2;
  64861. alphaThreshold: number;
  64862. /**
  64863. * Serializes this fire procedural texture
  64864. * @returns a serialized fire procedural texture object
  64865. */
  64866. serialize(): any;
  64867. /**
  64868. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  64869. * @param parsedTexture defines parsed texture data
  64870. * @param scene defines the current scene
  64871. * @param rootUrl defines the root URL containing fire procedural texture information
  64872. * @returns a parsed Fire Procedural BABYLON.Texture
  64873. */
  64874. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  64875. }
  64876. }
  64877. declare module BABYLON {
  64878. /** @hidden */
  64879. export var grassProceduralTexturePixelShader: {
  64880. name: string;
  64881. shader: string;
  64882. };
  64883. }
  64884. declare module BABYLON {
  64885. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  64886. private _grassColors;
  64887. private _groundColor;
  64888. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64889. updateShaderUniforms(): void;
  64890. grassColors: BABYLON.Color3[];
  64891. groundColor: BABYLON.Color3;
  64892. /**
  64893. * Serializes this grass procedural texture
  64894. * @returns a serialized grass procedural texture object
  64895. */
  64896. serialize(): any;
  64897. /**
  64898. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  64899. * @param parsedTexture defines parsed texture data
  64900. * @param scene defines the current scene
  64901. * @param rootUrl defines the root URL containing grass procedural texture information
  64902. * @returns a parsed Grass Procedural BABYLON.Texture
  64903. */
  64904. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  64905. }
  64906. }
  64907. declare module BABYLON {
  64908. /** @hidden */
  64909. export var marbleProceduralTexturePixelShader: {
  64910. name: string;
  64911. shader: string;
  64912. };
  64913. }
  64914. declare module BABYLON {
  64915. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  64916. private _numberOfTilesHeight;
  64917. private _numberOfTilesWidth;
  64918. private _amplitude;
  64919. private _jointColor;
  64920. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64921. updateShaderUniforms(): void;
  64922. numberOfTilesHeight: number;
  64923. amplitude: number;
  64924. numberOfTilesWidth: number;
  64925. jointColor: BABYLON.Color3;
  64926. /**
  64927. * Serializes this marble procedural texture
  64928. * @returns a serialized marble procedural texture object
  64929. */
  64930. serialize(): any;
  64931. /**
  64932. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  64933. * @param parsedTexture defines parsed texture data
  64934. * @param scene defines the current scene
  64935. * @param rootUrl defines the root URL containing marble procedural texture information
  64936. * @returns a parsed Marble Procedural BABYLON.Texture
  64937. */
  64938. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  64939. }
  64940. }
  64941. declare module BABYLON {
  64942. /** @hidden */
  64943. export var normalMapProceduralTexturePixelShader: {
  64944. name: string;
  64945. shader: string;
  64946. };
  64947. }
  64948. declare module BABYLON {
  64949. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  64950. private _baseTexture;
  64951. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64952. updateShaderUniforms(): void;
  64953. render(useCameraPostProcess?: boolean): void;
  64954. resize(size: any, generateMipMaps: any): void;
  64955. baseTexture: BABYLON.Texture;
  64956. /**
  64957. * Serializes this normal map procedural texture
  64958. * @returns a serialized normal map procedural texture object
  64959. */
  64960. serialize(): any;
  64961. /**
  64962. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  64963. * @param parsedTexture defines parsed texture data
  64964. * @param scene defines the current scene
  64965. * @param rootUrl defines the root URL containing normal map procedural texture information
  64966. * @returns a parsed Normal Map Procedural BABYLON.Texture
  64967. */
  64968. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  64969. }
  64970. }
  64971. declare module BABYLON {
  64972. /** @hidden */
  64973. export var perlinNoiseProceduralTexturePixelShader: {
  64974. name: string;
  64975. shader: string;
  64976. };
  64977. }
  64978. declare module BABYLON {
  64979. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  64980. time: number;
  64981. timeScale: number;
  64982. translationSpeed: number;
  64983. private _currentTranslation;
  64984. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64985. updateShaderUniforms(): void;
  64986. render(useCameraPostProcess?: boolean): void;
  64987. resize(size: any, generateMipMaps: any): void;
  64988. /**
  64989. * Serializes this perlin noise procedural texture
  64990. * @returns a serialized perlin noise procedural texture object
  64991. */
  64992. serialize(): any;
  64993. /**
  64994. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  64995. * @param parsedTexture defines parsed texture data
  64996. * @param scene defines the current scene
  64997. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  64998. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  64999. */
  65000. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  65001. }
  65002. }
  65003. declare module BABYLON {
  65004. /** @hidden */
  65005. export var roadProceduralTexturePixelShader: {
  65006. name: string;
  65007. shader: string;
  65008. };
  65009. }
  65010. declare module BABYLON {
  65011. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  65012. private _roadColor;
  65013. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65014. updateShaderUniforms(): void;
  65015. roadColor: BABYLON.Color3;
  65016. /**
  65017. * Serializes this road procedural texture
  65018. * @returns a serialized road procedural texture object
  65019. */
  65020. serialize(): any;
  65021. /**
  65022. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  65023. * @param parsedTexture defines parsed texture data
  65024. * @param scene defines the current scene
  65025. * @param rootUrl defines the root URL containing road procedural texture information
  65026. * @returns a parsed Road Procedural BABYLON.Texture
  65027. */
  65028. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  65029. }
  65030. }
  65031. declare module BABYLON {
  65032. /** @hidden */
  65033. export var starfieldProceduralTexturePixelShader: {
  65034. name: string;
  65035. shader: string;
  65036. };
  65037. }
  65038. declare module BABYLON {
  65039. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  65040. private _time;
  65041. private _alpha;
  65042. private _beta;
  65043. private _zoom;
  65044. private _formuparam;
  65045. private _stepsize;
  65046. private _tile;
  65047. private _brightness;
  65048. private _darkmatter;
  65049. private _distfading;
  65050. private _saturation;
  65051. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65052. updateShaderUniforms(): void;
  65053. time: number;
  65054. alpha: number;
  65055. beta: number;
  65056. formuparam: number;
  65057. stepsize: number;
  65058. zoom: number;
  65059. tile: number;
  65060. brightness: number;
  65061. darkmatter: number;
  65062. distfading: number;
  65063. saturation: number;
  65064. /**
  65065. * Serializes this starfield procedural texture
  65066. * @returns a serialized starfield procedural texture object
  65067. */
  65068. serialize(): any;
  65069. /**
  65070. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  65071. * @param parsedTexture defines parsed texture data
  65072. * @param scene defines the current scene
  65073. * @param rootUrl defines the root URL containing startfield procedural texture information
  65074. * @returns a parsed Starfield Procedural BABYLON.Texture
  65075. */
  65076. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  65077. }
  65078. }
  65079. declare module BABYLON {
  65080. /** @hidden */
  65081. export var woodProceduralTexturePixelShader: {
  65082. name: string;
  65083. shader: string;
  65084. };
  65085. }
  65086. declare module BABYLON {
  65087. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  65088. private _ampScale;
  65089. private _woodColor;
  65090. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65091. updateShaderUniforms(): void;
  65092. ampScale: number;
  65093. woodColor: BABYLON.Color3;
  65094. /**
  65095. * Serializes this wood procedural texture
  65096. * @returns a serialized wood procedural texture object
  65097. */
  65098. serialize(): any;
  65099. /**
  65100. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  65101. * @param parsedTexture defines parsed texture data
  65102. * @param scene defines the current scene
  65103. * @param rootUrl defines the root URL containing wood procedural texture information
  65104. * @returns a parsed Wood Procedural BABYLON.Texture
  65105. */
  65106. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  65107. }
  65108. }